Mercurial > pidgin
annotate src/gtkconv.c @ 12288:3897229ccb33
[gaim-migrate @ 14592]
" This patch fixes two serious bugs in the hidden
conversation/queuing code.
First, it removes the need to explicitly present
conversations created under queuing conditions.
Instead, when an incoming message is received and a
conversation does not exist, a hidden conversation is
created in a received-im-msg signal handler by swapping
out the create_conversation function in the gtkconv
ui_ops. This fixes a bug which could allow
conversations to be created in a hidden state when they
should be visible (i.e. buddy pounce open an im window
action). This required a second search for a
conversation in server.c after the signal is emitted.
Second, it fixes a bug which would cause gaim to crash
when quitting with a queued message. Fixing this
simplified the code a bit by removing the
private_remove_gtkconv function and instead adding a
check in gaim_gtk_conv_window_remove_gtkconv to prevent
the hidden_convwin from being destroyed when the last
conversation is removed." --charkins
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Fri, 02 Dec 2005 00:40:32 +0000 |
parents | 255e6912607b |
children | a532eccfc7bb |
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" |
12272 | 45 #include "idle.h" |
6982 | 46 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
47 #include "log.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5402
diff
changeset
|
48 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
49 #include "prpl.h" |
6038 | 50 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
51 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
52 |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
53 #include "gtkdnd-hints.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
54 #include "gtkblist.h" |
5717 | 55 #include "gtkconv.h" |
11583 | 56 #include "gtkconvwin.h" |
9709 | 57 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
58 #include "gtkimhtml.h" |
8317 | 59 #include "gtkimhtmltoolbar.h" |
7431 | 60 #include "gtklog.h" |
11554
f8443218b7fe
[gaim-migrate @ 13814]
Gary Kramlich <grim@reaperworld.com>
parents:
11552
diff
changeset
|
61 #include "gtkmenutray.h" |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
62 #include "gtkpounce.h" |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
63 #include "gtkprefs.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
64 #include "gtkprivacy.h" |
11525 | 65 #include "gtkthemes.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
66 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
67 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
68 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
69 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
70 |
12190 | 71 #define SEND_COLOR "#204a87" |
72 #define RECV_COLOR "#cc0000" | |
7854 | 73 |
10108 | 74 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
75 | |
76 /* These colors come from the default GNOME palette */ | |
77 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
78 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
79 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
80 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
81 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
82 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
83 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
84 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
85 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
86 {0, 34816, 17920, 12544}, /* Red Dark */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
87 {0, 49408, 14336, 8704}, /* Red Shadow */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
88 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
89 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
90 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
91 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
92 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
93 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
94 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
95 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
96 {0, 57088, 16896, 7680}, /* Accent Red */ |
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
97 {0, 39168, 0, 0}, /* Accent Red Dark */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
98 {0, 17920, 40960, 17920}, /* Accent Green */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
99 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 100 }; |
6291 | 101 |
4359 | 102 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
103 | |
11581 | 104 typedef struct { |
4359 | 105 GtkWidget *window; |
106 | |
107 GtkWidget *entry; | |
108 GtkWidget *message; | |
109 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
110 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
111 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
112 } InviteBuddyInfo; |
4359 | 113 |
114 static GtkWidget *invite_dialog = NULL; | |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
115 static GtkWidget *warn_close_dialog = NULL; |
4359 | 116 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
117 static GaimGtkWindow *hidden_convwin = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
118 static GList *window_list = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
119 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
120 |
11594 | 121 static gboolean update_send_to_selection(GaimGtkWindow *win); |
122 static void generate_send_to_items(GaimGtkWindow *win); | |
11581 | 123 |
4359 | 124 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
10810 | 125 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
11604 | 126 static void gray_stuff_out(GaimGtkConversation *gtkconv); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
127 static GList *generate_invite_user_names(GaimConnection *gc); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
128 static void add_chat_buddy_common(GaimConversation *conv, const char *name, |
11869 | 129 GaimConvChatBuddyFlags flags, const char *alias, const char *old_name); |
9605 | 130 static gboolean tab_complete(GaimConversation *conv); |
11604 | 131 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); |
11613 | 132 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); |
10810 | 133 static void update_typing_icon(GaimGtkConversation *gtkconv); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
134 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
|
135 gboolean gaim_gtkconv_has_focus(GaimConversation *conv); |
4359 | 136 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
137 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
138 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
139 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
140 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
141 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
142 col = nick_colors[g_str_hash(name) % NUM_NICK_COLORS]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
143 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
144 (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
|
145 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
146 /* 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
|
147 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
148 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
149 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
150 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
151 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
152 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
153 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
154 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
155 |
4359 | 156 /************************************************************************** |
157 * Callbacks | |
158 **************************************************************************/ | |
10971 | 159 |
4359 | 160 static gint |
10810 | 161 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 162 { |
10810 | 163 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 164 |
10810 | 165 l = list; |
166 while (l) { | |
167 GaimConversation *conv = l->data; | |
168 gaim_conversation_destroy(conv); | |
169 l = l->next; | |
170 } | |
11508 | 171 |
10810 | 172 g_list_free(list); |
11508 | 173 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
174 return TRUE; |
4359 | 175 } |
176 | |
8914 | 177 static gboolean |
10810 | 178 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 179 { |
10810 | 180 GaimConversation *conv = gtkconv->active_conv; |
11508 | 181 |
8914 | 182 if (!GTK_WIDGET_VISIBLE(w)) |
183 return FALSE; | |
184 | |
185 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
186 return FALSE; | |
187 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
188 /* 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
|
189 * 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
|
190 * 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
|
191 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
192 /* 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
|
193 * negate it anyway. --luke */ |
11338 | 194 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 195 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
196 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
197 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
|
198 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
|
199 } |
8914 | 200 if (w == gtkconv->entry) |
201 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
202 } | |
11338 | 203 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 204 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
205 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
206 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
|
207 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
|
208 } |
8914 | 209 if (w == gtkconv->entry) |
210 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
211 } | |
212 | |
213 return FALSE; | |
214 } | |
215 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
216 static void |
10810 | 217 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
218 { |
10810 | 219 GaimConversation *conv = c->active_conv; |
11508 | 220 |
10665 | 221 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
222 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
223 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
224 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
225 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
226 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
|
227 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
228 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
229 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
|
230 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
231 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
232 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
|
233 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
234 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
235 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
236 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
237 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
238 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
239 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
240 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
241 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
242 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
|
243 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
244 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
245 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
246 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
247 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
248 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
249 fg_color.blue / 256); |
8061 | 250 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
251 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
252 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
253 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
254 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
255 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
256 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
259 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
261 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
262 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
264 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
266 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
267 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
268 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
269 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
270 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
271 g_free(color); |
8677 | 272 |
9025 | 273 |
10665 | 274 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 275 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
276 else | |
277 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 278 } |
279 } | |
9130 | 280 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
281 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
282 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
283 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
284 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
285 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
286 |
9130 | 287 static const char * |
288 gaim_gtk_get_cmd_prefix(void) | |
289 { | |
290 return "/"; | |
291 } | |
292 | |
9167 | 293 static GaimCmdRet |
9829 | 294 say_command_cb(GaimConversation *conv, |
295 const char *cmd, char **args, char **error, void *data) | |
296 { | |
11338 | 297 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 298 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 299 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 300 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
301 | |
302 return GAIM_CMD_RET_OK; | |
303 } | |
304 | |
305 static GaimCmdRet | |
9167 | 306 me_command_cb(GaimConversation *conv, |
9597 | 307 const char *cmd, char **args, char **error, void *data) |
9167 | 308 { |
309 char *tmp; | |
310 | |
311 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 312 |
11338 | 313 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 314 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 315 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 316 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
317 | |
318 g_free(tmp); | |
319 return GAIM_CMD_RET_OK; | |
320 } | |
321 | |
9212 | 322 static GaimCmdRet |
323 debug_command_cb(GaimConversation *conv, | |
9597 | 324 const char *cmd, char **args, char **error, void *data) |
9212 | 325 { |
326 char *tmp, *markup; | |
327 GaimCmdStatus status; | |
328 | |
329 if (!g_ascii_strcasecmp(args[0], "version")) { | |
330 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
|
331 markup = g_markup_escape_text(tmp, -1); |
9212 | 332 |
333 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
334 | |
335 g_free(tmp); | |
336 g_free(markup); | |
337 return status; | |
338 } else { | |
339 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
340 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
341 return GAIM_CMD_STATUS_OK; | |
342 } | |
343 } | |
344 | |
9213 | 345 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
346 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
347 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
348 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
349 GaimGtkConversation *gtkconv = NULL; |
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 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
352 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
353 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
354 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
355 } |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
356 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
357 static GaimCmdRet |
9213 | 358 help_command_cb(GaimConversation *conv, |
9597 | 359 const char *cmd, char **args, char **error, void *data) |
9213 | 360 { |
9597 | 361 GList *l, *text; |
9213 | 362 GString *s; |
9597 | 363 |
364 if (args[0] != NULL) { | |
365 s = g_string_new(""); | |
366 text = gaim_cmd_help(conv, args[0]); | |
367 | |
368 if (text) { | |
369 for (l = text; l; l = l->next) | |
370 if (l->next) | |
9816 | 371 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 372 else |
9816 | 373 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 374 } else { |
375 g_string_append(s, _("No such command (in this context).")); | |
376 } | |
377 } else { | |
378 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
379 "The following commands are available in this context:\n")); | |
380 | |
381 text = gaim_cmd_list(conv); | |
382 for (l = text; l; l = l->next) | |
9213 | 383 if (l->next) |
9597 | 384 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 385 else |
9597 | 386 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 387 } |
388 | |
389 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
390 g_string_free(s, TRUE); | |
391 | |
392 return GAIM_CMD_STATUS_OK; | |
393 } | |
394 | |
4359 | 395 static void |
9374 | 396 send_history_add(GaimConversation *conv, const char *message) |
397 { | |
398 GList *first; | |
399 | |
400 first = g_list_first(conv->send_history); | |
401 | |
402 if (first->data) | |
403 g_free(first->data); | |
404 | |
405 first->data = g_strdup(message); | |
406 | |
407 conv->send_history = g_list_prepend(first, NULL); | |
408 } | |
409 | |
9832 | 410 static gboolean |
411 check_for_and_do_command(GaimConversation *conv) | |
412 { | |
413 GaimGtkConversation *gtkconv; | |
414 char *cmd; | |
415 const char *prefix; | |
416 GaimAccount *account; | |
417 GtkTextIter start; | |
418 | |
419 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
420 account = gaim_conversation_get_account(conv); | |
421 prefix = gaim_gtk_get_cmd_prefix(); | |
422 | |
423 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
424 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
425 | |
426 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
427 && !gtk_text_iter_get_child_anchor(&start)) { | |
428 GaimCmdStatus status; | |
429 char *error, *cmdline, *markup, *send_history; | |
430 GtkTextIter end; | |
431 | |
432 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
433 send_history_add(conv, send_history); | |
434 g_free(send_history); | |
435 | |
436 cmdline = cmd + strlen(prefix); | |
437 | |
438 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
439 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
440 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
441 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
442 g_free(cmd); | |
443 g_free(markup); | |
444 | |
445 switch (status) { | |
446 case GAIM_CMD_STATUS_OK: | |
447 return TRUE; | |
448 case GAIM_CMD_STATUS_NOT_FOUND: | |
449 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
450 gaim_conversation_write(conv, "", _("No such command."), | |
451 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
452 | |
453 return TRUE; | |
454 } | |
455 return FALSE; | |
456 case GAIM_CMD_STATUS_WRONG_ARGS: | |
457 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
458 "to that command."), | |
459 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
460 return TRUE; | |
461 case GAIM_CMD_STATUS_FAILED: | |
462 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
463 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
464 if(error) | |
465 g_free(error); | |
466 return TRUE; | |
467 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 468 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 469 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 470 GAIM_MESSAGE_NO_LOG, time(NULL)); |
471 else | |
10843 | 472 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 473 GAIM_MESSAGE_NO_LOG, time(NULL)); |
474 return TRUE; | |
475 case GAIM_CMD_STATUS_WRONG_PRPL: | |
476 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
477 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
478 return TRUE; | |
479 } | |
480 } | |
481 | |
482 g_free(cmd); | |
483 return FALSE; | |
484 } | |
485 | |
9374 | 486 static void |
10810 | 487 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 488 { |
10810 | 489 GaimConversation *conv = gtkconv->active_conv; |
8655 | 490 GaimAccount *account; |
8677 | 491 GaimConnection *gc; |
12216 | 492 GaimMessageFlags flags = 0; |
8448 | 493 char *buf, *clean; |
4359 | 494 |
8655 | 495 account = gaim_conversation_get_account(conv); |
9130 | 496 |
9471 | 497 if (!gaim_account_is_connected(account)) |
498 return; | |
499 | |
11338 | 500 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 501 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 502 return; |
503 | |
9832 | 504 if (check_for_and_do_command(conv)) { |
505 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
506 return; | |
9130 | 507 } |
508 | |
8442 | 509 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 510 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 511 |
4359 | 512 gtk_widget_grab_focus(gtkconv->entry); |
513 | |
8448 | 514 if (strlen(clean) == 0) { |
515 g_free(clean); | |
4359 | 516 return; |
517 } | |
518 | |
12272 | 519 gaim_idle_touch(); |
520 | |
12216 | 521 /* XXX: is there a better way to tell if the message has images? */ |
522 if (GTK_IMHTML(gtkconv->entry)->im_images != NULL) | |
523 flags |= GAIM_MESSAGE_IMAGES; | |
524 | |
8677 | 525 gc = gaim_account_get_connection(account); |
10665 | 526 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 527 char **bufs; |
528 int i; | |
529 | |
530 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
531 for (i = 0; bufs[i]; i++) { | |
9374 | 532 send_history_add(conv, bufs[i]); |
11338 | 533 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 534 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), bufs[i], flags); |
11338 | 535 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 536 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), bufs[i], flags); |
8677 | 537 } |
538 | |
539 g_strfreev(bufs); | |
540 | |
541 } else { | |
9374 | 542 send_history_add(conv, buf); |
11338 | 543 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 544 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), buf, flags); |
11338 | 545 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 546 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), buf, flags); |
8677 | 547 } |
4359 | 548 |
8677 | 549 g_free(clean); |
4359 | 550 g_free(buf); |
551 | |
8061 | 552 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 553 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 554 } |
555 | |
556 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
557 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 558 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
559 GaimAccount *account; |
4359 | 560 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
561 GaimConversation *conv = gtkconv->active_conv; |
4359 | 562 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
563 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
564 name = gaim_conversation_get_name(conv); |
7879 | 565 |
11338 | 566 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 567 GaimBuddy *b; |
568 | |
569 b = gaim_find_buddy(account, name); | |
570 if (b != NULL) | |
9730 | 571 gaim_gtkdialogs_remove_buddy(b); |
7859 | 572 else if (account != NULL && gaim_account_is_connected(account)) |
573 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 574 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 575 GaimChat *c; |
576 | |
577 c = gaim_blist_find_chat(account, name); | |
578 if (c != NULL) | |
9730 | 579 gaim_gtkdialogs_remove_chat(c); |
7859 | 580 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 581 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 582 } |
4359 | 583 |
584 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
585 } | |
586 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
587 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 588 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
589 GaimConversation *conv = gtkconv->active_conv; |
7975 | 590 GaimPluginProtocolInfo *prpl_info = NULL; |
591 GaimConnection *gc; | |
592 | |
593 if ((gc = gaim_conversation_get_gc(conv))) { | |
594 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
595 | |
596 /* | |
597 * If there are special needs for getting info on users in | |
598 * buddy chat "rooms"... | |
599 */ | |
600 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
601 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
602 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
603 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
604 } |
7975 | 605 else |
606 prpl_info->get_info(gc, who); | |
607 } | |
608 } | |
609 | |
610 | |
4359 | 611 static void |
10810 | 612 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 613 { |
10810 | 614 GaimConversation *conv = gtkconv->active_conv; |
4359 | 615 |
11338 | 616 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 617 serv_get_info(gaim_conversation_get_gc(conv), |
618 gaim_conversation_get_name(conv)); | |
619 | |
620 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 621 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 622 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
623 GaimGtkChatPane *gtkchat; |
4359 | 624 GtkTreeIter iter; |
625 GtkTreeModel *model; | |
626 GtkTreeSelection *sel; | |
9554 | 627 char *name; |
4359 | 628 |
629 gtkchat = gtkconv->u.chat; | |
630 | |
631 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
632 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
633 | |
634 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 635 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 636 else |
637 return; | |
638 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
639 chat_do_info(gtkconv, name); |
9554 | 640 g_free(name); |
4359 | 641 } |
642 } | |
643 | |
644 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
645 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 646 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
647 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
648 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
649 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
650 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
651 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
652 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
653 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 654 |
655 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
656 } | |
657 | |
658 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
659 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 660 { |
661 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
662 GaimGtkConversation *gtkconv; |
4359 | 663 |
664 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
665 | |
666 if (resp == GTK_RESPONSE_OK) { | |
667 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
668 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
669 | |
10113 | 670 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 671 return; |
672 | |
673 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
674 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 675 message, buddy); |
676 } | |
677 | |
678 gtk_widget_destroy(invite_dialog); | |
679 invite_dialog = NULL; | |
680 | |
681 g_free(info); | |
682 } | |
683 | |
684 static void | |
9909 | 685 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
686 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
687 { | |
688 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
689 const char *convprotocol; | |
690 | |
691 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
692 | |
693 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
694 { | |
695 GaimBlistNode *node = NULL; | |
696 GaimBuddy *buddy; | |
697 | |
698 memcpy(&node, sd->data, sizeof(node)); | |
699 | |
700 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
701 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
702 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
703 buddy = (GaimBuddy *)node; | |
704 else | |
705 return; | |
706 | |
707 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
708 { | |
709 gaim_notify_error(NULL, NULL, | |
710 _("That buddy is not on the same protocol as this " | |
10843 | 711 "chat."), NULL); |
9909 | 712 } |
713 else | |
714 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
715 | |
716 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
717 } | |
718 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
719 { | |
720 char *protocol = NULL; | |
721 char *username = NULL; | |
722 GaimAccount *account; | |
723 | |
11137 | 724 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 725 &protocol, &username, NULL)) |
726 { | |
727 if (account == NULL) | |
728 { | |
729 gaim_notify_error(NULL, NULL, | |
730 _("You are not currently signed on with an account that " | |
731 "can invite that buddy."), NULL); | |
732 } | |
733 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
734 { | |
735 gaim_notify_error(NULL, NULL, | |
736 _("That buddy is not on the same protocol as this " | |
10843 | 737 "chat."), NULL); |
9909 | 738 } |
739 else | |
740 { | |
741 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
742 } | |
743 } | |
744 | |
745 if (username != NULL) g_free(username); | |
746 if (protocol != NULL) g_free(protocol); | |
747 | |
748 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
749 } | |
750 } | |
751 | |
752 static const GtkTargetEntry dnd_targets[] = | |
753 { | |
754 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
755 {"application/x-im-contact", 0, 1} | |
756 }; | |
757 | |
758 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
759 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 760 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
761 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
762 InviteBuddyInfo *info = NULL; |
4359 | 763 |
764 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
765 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
766 GaimGtkWindow *gtkwin; |
4359 | 767 GtkWidget *label; |
768 GtkWidget *vbox, *hbox; | |
769 GtkWidget *table; | |
770 GtkWidget *img; | |
771 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
772 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 773 GTK_ICON_SIZE_DIALOG); |
4359 | 774 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
775 info = g_new0(InviteBuddyInfo, 1); |
4359 | 776 info->conv = conv; |
777 | |
11581 | 778 gc = gaim_conversation_get_gc(conv); |
779 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 780 |
781 /* Create the new dialog. */ | |
782 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 783 _("Invite Buddy Into Chat Room"), |
7879 | 784 GTK_WINDOW(gtkwin->window), 0, |
785 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
786 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 787 |
788 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 789 GTK_RESPONSE_OK); |
11243 | 790 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 791 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
792 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
793 | |
9909 | 794 info->window = GTK_WIDGET(invite_dialog); |
795 | |
4359 | 796 /* Setup the outside spacing. */ |
797 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
798 | |
11243 | 799 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
800 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 801 |
802 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 803 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 804 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
805 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
806 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
807 | |
808 /* Setup the right vbox. */ | |
809 vbox = gtk_vbox_new(FALSE, 0); | |
810 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
811 | |
812 /* Put our happy label in it. */ | |
813 label = gtk_label_new(_("Please enter the name of the user you wish " | |
814 "to invite, along with an optional invite " | |
815 "message.")); | |
816 gtk_widget_set_size_request(label, 350, -1); | |
817 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
818 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
819 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
820 | |
821 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 822 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 823 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
824 | |
825 /* Setup the table we're going to use to lay stuff out. */ | |
826 table = gtk_table_new(2, 2, FALSE); | |
11243 | 827 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
828 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
829 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 830 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
831 | |
832 /* Now the Buddy label */ | |
833 label = gtk_label_new(NULL); | |
834 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
835 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
836 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
837 | |
838 /* Now the Buddy drop-down entry field. */ | |
839 info->entry = gtk_combo_new(); | |
840 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
841 gtk_entry_set_activates_default( | |
842 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
843 | |
844 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
845 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
846 | |
847 /* Fill in the names. */ | |
848 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
849 generate_invite_user_names(gc)); | |
850 | |
851 | |
852 /* Now the label for "Message" */ | |
853 label = gtk_label_new(NULL); | |
854 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
855 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
856 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
857 | |
858 | |
859 /* And finally, the Message entry field. */ | |
860 info->message = gtk_entry_new(); | |
861 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
862 | |
863 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
864 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
865 | |
866 /* Connect the signals. */ | |
867 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
868 G_CALLBACK(do_invite), info); | |
9909 | 869 /* Setup drag-and-drop */ |
870 gtk_drag_dest_set(info->window, | |
871 GTK_DEST_DEFAULT_MOTION | | |
872 GTK_DEST_DEFAULT_DROP, | |
873 dnd_targets, | |
874 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
875 GDK_ACTION_COPY); | |
876 gtk_drag_dest_set(info->entry, | |
877 GTK_DEST_DEFAULT_MOTION | | |
878 GTK_DEST_DEFAULT_DROP, | |
879 dnd_targets, | |
880 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
881 GDK_ACTION_COPY); | |
882 | |
883 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
884 G_CALLBACK(invite_dnd_recv), info); | |
885 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
886 G_CALLBACK(invite_dnd_recv), info); | |
887 | |
4359 | 888 } |
889 | |
890 gtk_widget_show_all(invite_dialog); | |
891 | |
892 if (info != NULL) | |
893 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
894 } | |
895 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
896 static void |
7748 | 897 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
898 { | |
9714 | 899 gaim_gtkdialogs_im(); |
7748 | 900 } |
901 | |
902 static void | |
9504 | 903 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 904 { |
9504 | 905 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 906 FILE *fp; |
907 const char *name; | |
10849 | 908 gchar *text; |
9489 | 909 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
910 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9504 | 911 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 912 return; |
913 } | |
914 | |
915 name = gaim_conversation_get_name(conv); | |
10849 | 916 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 917 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 918 |
919 text = gtk_imhtml_get_markup( | |
920 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
921 fprintf(fp, "%s", text); | |
922 g_free(text); | |
923 | |
924 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 925 fclose(fp); |
926 } | |
927 | |
10849 | 928 /* |
929 * It would be kinda cool if this gave the option of saving a | |
930 * plaintext v. HTML file. | |
931 */ | |
9489 | 932 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
933 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
934 { |
11581 | 935 GaimGtkWindow *win = data; |
936 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 937 gchar *buf; |
938 | |
939 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 940 |
10849 | 941 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
942 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 943 |
944 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
945 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
946 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
947 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
948 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
949 { |
11581 | 950 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
951 GaimConversation *conv; |
9917 | 952 GaimLogType type; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
953 GaimGtkBuddyList *gtkblist; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
954 GdkCursor *cursor; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
955 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
956 GaimAccount *account; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
957 GSList *buddies; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
958 GSList *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
959 |
11581 | 960 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
961 |
11338 | 962 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 963 type = GAIM_LOG_IM; |
11338 | 964 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 965 type = GAIM_LOG_CHAT; |
966 else | |
967 return; | |
968 | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
969 gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
970 cursor = gdk_cursor_new(GDK_WATCH); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
971 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
972 gdk_window_set_cursor(gtkblist->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
973 gdk_window_set_cursor(win->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
974 gdk_cursor_unref(cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
975 while (gtk_events_pending()) |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
976 gtk_main_iteration(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
977 |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
978 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
979 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
980 |
10845 | 981 buddies = gaim_find_buddies(account, name); |
982 for (cur = buddies; cur != NULL; cur = cur->next) | |
983 { | |
984 GaimBlistNode *node = cur->data; | |
10846 | 985 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 986 { |
987 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
988 g_slist_free(buddies); | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
989 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
990 gdk_window_set_cursor(win->window->window, NULL); |
10845 | 991 return; |
992 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
993 } |
10845 | 994 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
995 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
996 gaim_gtk_log_show(type, name, account); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
997 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
998 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
999 gdk_window_set_cursor(win->window->window, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1000 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1001 |
8974 | 1002 static void |
1003 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
1004 { | |
11581 | 1005 GaimGtkWindow *win = data; |
8974 | 1006 GaimConversation *conv; |
1007 GaimGtkConversation *gtkconv; | |
1008 | |
11581 | 1009 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 1010 gtkconv = GAIM_GTK_CONVERSATION(conv); |
1011 | |
1012 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1013 } | |
1014 | |
7295 | 1015 struct _search { |
1016 GaimGtkConversation *gtkconv; | |
1017 GtkWidget *entry; | |
1018 }; | |
1019 | |
7929 | 1020 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 1021 { |
7929 | 1022 switch (resp) { |
1023 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1024 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1025 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1026 break; |
1027 | |
1028 case GTK_RESPONSE_DELETE_EVENT: | |
1029 case GTK_RESPONSE_CLOSE: | |
1030 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1031 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1032 s->gtkconv->dialogs.search = NULL; | |
1033 g_free(s); | |
1034 break; | |
1035 } | |
7295 | 1036 } |
1037 | |
1038 static void | |
7751 | 1039 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1040 { |
11581 | 1041 GaimGtkWindow *gtkwin = data; |
1042 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1043 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1044 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1045 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1046 GTK_ICON_SIZE_DIALOG); |
7929 | 1047 GtkWidget *label; |
7295 | 1048 struct _search *s; |
1049 | |
7798 | 1050 if (gtkconv->dialogs.search) { |
1051 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1052 return; |
7798 | 1053 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1054 |
7295 | 1055 s = g_malloc(sizeof(struct _search)); |
1056 s->gtkconv = gtkconv; | |
7929 | 1057 |
1058 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1059 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1060 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1061 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1062 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1063 GTK_RESPONSE_OK); |
7929 | 1064 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1065 G_CALLBACK(do_search_cb), s); | |
1066 | |
11243 | 1067 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1068 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1069 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1070 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
|
1071 gtk_container_set_border_width( |
11243 | 1072 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1073 | |
1074 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1075 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1076 hbox); |
7929 | 1077 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1078 | |
1079 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1080 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1081 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1082 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1083 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1084 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1085 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1086 | |
1087 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1088 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1089 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1090 g_signal_connect(G_OBJECT(s->entry), "changed", |
1091 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1092 gtkconv->dialogs.search); | |
1093 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
|
1094 |
7295 | 1095 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1096 gtk_widget_grab_focus(s->entry); |
7295 | 1097 } |
1098 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1099 static void |
9468 | 1100 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1101 { | |
11581 | 1102 GaimGtkWindow *win = data; |
1103 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1104 |
11338 | 1105 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1106 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1107 } | |
1108 | |
1109 } | |
1110 | |
1111 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1112 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1113 { |
11581 | 1114 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1115 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1116 |
11581 | 1117 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
|
1118 |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1119 gaim_gtk_pounce_editor_show(gaim_conversation_get_account(conv), |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1120 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1121 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1122 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1123 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1124 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1125 { |
11581 | 1126 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1127 GaimGtkConversation *gtkconv; |
8756 | 1128 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1129 |
11581 | 1130 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1131 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1132 | |
1133 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1134 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1135 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1136 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1137 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1138 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1139 { |
11581 | 1140 GaimGtkWindow *win = data; |
8756 | 1141 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1142 GaimGtkConversation *gtkconv; |
8756 | 1143 GtkIMHtmlToolbar *toolbar; |
1144 | |
11581 | 1145 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1146 conv = gtkconv->active_conv; | |
8756 | 1147 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1148 | |
1149 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1150 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1151 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1152 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1153 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1154 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1155 { |
11581 | 1156 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1157 GaimConversation *conv; |
7879 | 1158 GaimAccount *account; |
1159 const char *name; | |
1160 | |
11581 | 1161 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1162 account = gaim_conversation_get_account(conv); |
1163 name = gaim_conversation_get_name(conv); | |
1164 | |
11338 | 1165 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1166 GaimBuddy *b; |
1167 | |
1168 b = gaim_find_buddy(account, name); | |
1169 if (b != NULL) | |
9730 | 1170 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1171 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1172 GaimChat *c; |
1173 | |
1174 c = gaim_blist_find_chat(account, name); | |
1175 if (c != NULL) | |
9730 | 1176 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1177 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1178 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1179 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1180 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1181 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1182 { |
11581 | 1183 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1184 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1185 |
11581 | 1186 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1187 |
10810 | 1188 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1189 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1190 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1191 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1192 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1193 { |
11581 | 1194 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1195 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1196 |
11581 | 1197 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1198 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1199 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1200 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1201 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1202 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1203 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1204 { |
11581 | 1205 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1206 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1207 |
11581 | 1208 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1209 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1210 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
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 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 { |
11581 | 1216 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1218 |
11581 | 1219 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1220 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1221 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1222 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1223 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1224 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1225 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1226 { |
11581 | 1227 GaimGtkWindow *win = data; |
1228 | |
1229 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
|
1230 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1231 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1232 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1233 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1234 { |
11581 | 1235 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1236 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1237 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1238 |
11581 | 1239 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1240 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1241 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1242 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1243 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1244 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
|
1245 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1246 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1247 return; |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1248 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1249 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1250 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1251 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1252 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1253 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1254 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1255 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1256 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1257 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1258 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1259 } |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1260 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1261 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1262 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1263 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1264 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1265 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1266 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1267 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1268 /* 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
|
1269 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1270 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1271 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1272 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1273 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1274 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1275 { |
11581 | 1276 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1277 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1278 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1279 |
11581 | 1280 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1281 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1282 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1283 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1284 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1285 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1286 |
10377 | 1287 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1288 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
|
1289 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1290 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1291 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1292 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1293 { |
11581 | 1294 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1295 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1296 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1297 |
11581 | 1298 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1299 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1300 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1301 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1302 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1303 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1304 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1305 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1306 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1307 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 |
7961 | 1309 static void |
9188 | 1310 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1311 { | |
11581 | 1312 GaimGtkWindow *win = data; |
9188 | 1313 GaimConversation *conv; |
1314 GaimGtkConversation *gtkconv; | |
1315 | |
11581 | 1316 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1317 |
1318 if (!conv) | |
1319 return; | |
1320 | |
1321 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1322 | |
12188 | 1323 gaim_prefs_set_bool("/gaim/gtk/conversations/show_timestamps", |
9188 | 1324 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
1325 } | |
1326 | |
1327 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1328 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1329 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1330 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1331 GaimAccount *account; |
1332 GaimConnection *gc; | |
7961 | 1333 GaimPluginProtocolInfo *prpl_info = NULL; |
1334 char *real_who; | |
1335 | |
1336 account = gaim_conversation_get_account(conv); | |
10431 | 1337 g_return_if_fail(account != NULL); |
1338 | |
1339 gc = gaim_account_get_connection(account); | |
1340 g_return_if_fail(gc != NULL); | |
1341 | |
1342 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1343 | |
1344 if (prpl_info && prpl_info->get_cb_real_name) | |
1345 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1346 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1347 else | |
1348 real_who = g_strdup(who); | |
1349 | |
1350 if(!real_who) | |
1351 return; | |
1352 | |
10431 | 1353 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1354 |
1355 g_free(real_who); | |
1356 } | |
1357 | |
1358 static void | |
10810 | 1359 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1360 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1361 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1362 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1363 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1364 GtkTreeSelection *sel; |
9554 | 1365 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1366 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1367 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1368 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1369 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1370 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1371 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1372 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1373 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
|
1374 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1375 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1376 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1377 chat_do_im(gtkconv, name); |
9554 | 1378 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1379 } |
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 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1382 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1383 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1384 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1385 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1386 GaimConvChat *chat; |
11869 | 1387 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1388 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1389 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1390 GtkTreeSelection *sel; |
10504 | 1391 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1392 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1393 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1394 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1395 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1396 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1397 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1398 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1399 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1401 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1402 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1403 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1404 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1405 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1406 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1407 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1408 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1409 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1410 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1411 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1412 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1413 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1414 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1415 |
11869 | 1416 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1417 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1418 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1419 } |
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 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1422 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1423 { |
1424 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1425 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1426 chat_do_im(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1427 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1428 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1429 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1430 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1431 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1432 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1433 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1434 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1435 | |
1436 serv_send_file(gc, who, NULL); | |
1437 } | |
1438 | |
1439 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1440 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1441 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1442 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1443 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1444 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1445 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1446 chat_do_info(gtkconv, who); |
5908
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 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1449 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1450 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1451 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1452 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1453 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1454 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1455 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1456 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1457 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1458 who = g_object_get_data(G_OBJECT(w), "user_data"); |
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 (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1461 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1462 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1463 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1464 * 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
|
1465 */ |
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 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1468 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1469 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1470 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1471 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1472 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1473 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1474 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1475 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1476 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1477 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1478 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1479 GaimAccount *account; |
6695 | 1480 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1481 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1482 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1483 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1484 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1485 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1486 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1487 if (b != NULL) |
9730 | 1488 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1489 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1490 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1491 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1492 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1493 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1494 |
8143 | 1495 static GtkWidget * |
10504 | 1496 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1497 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1498 { | |
1499 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1500 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1501 gboolean is_me = FALSE; |
8143 | 1502 GtkWidget *button; |
1503 | |
1504 /* | |
1505 * If a menu already exists, destroy it before creating a new one, | |
1506 * thus freeing-up the memory it occupied. | |
1507 */ | |
1508 if (menu) | |
1509 gtk_widget_destroy(menu); | |
1510 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1511 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1512 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1513 |
8143 | 1514 menu = gtk_menu_new(); |
1515 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1516 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1517 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1518 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
|
1519 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
|
1520 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1521 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1522 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1523 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1524 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1525 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1526 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
|
1527 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1528 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1529 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
|
1530 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
|
1531 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1532 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1533 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1534 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1535 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1536 } |
9498 | 1537 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1538 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1539 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
|
1540 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1541 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1542 } |
1543 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1544 if (prpl_info->get_cb_away) { |
10221 | 1545 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
|
1546 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1547 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1548 } |
1549 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1550 if (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1551 if (gaim_find_buddy(gc->account, who)) |
10221 | 1552 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
|
1553 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1554 else |
10221 | 1555 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
|
1556 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1557 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1558 } |
1559 | |
1560 return menu; | |
1561 } | |
1562 | |
1563 | |
1564 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1565 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1566 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1567 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1568 GaimPluginProtocolInfo *prpl_info = NULL; |
1569 GaimGtkChatPane *gtkchat; | |
1570 GaimConnection *gc; | |
1571 GaimAccount *account; | |
1572 GtkTreeSelection *sel; | |
1573 GtkTreeIter iter; | |
1574 GtkTreeModel *model; | |
1575 GtkWidget *menu; | |
1576 gchar *who; | |
1577 | |
1578 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1579 gtkchat = gtkconv->u.chat; | |
1580 account = gaim_conversation_get_account(conv); | |
1581 gc = account->gc; | |
1582 | |
1583 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1584 | |
1585 if (gc != NULL) | |
1586 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1587 | |
1588 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1589 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1590 return FALSE; | |
1591 | |
9498 | 1592 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1593 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1594 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1595 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1596 0, GDK_CURRENT_TIME); |
10504 | 1597 g_free(who); |
8143 | 1598 |
1599 return TRUE; | |
1600 } | |
1601 | |
1602 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1603 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1604 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1605 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1606 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1607 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1608 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1609 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1610 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1611 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1612 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1613 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1614 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1615 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1616 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1617 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1618 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1619 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1620 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1621 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1622 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1623 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1624 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1625 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
|
1626 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1627 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1628 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1629 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1630 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1631 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1632 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1633 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1634 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1635 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1636 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1637 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1638 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
|
1639 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1640 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1641 chat_do_im(gtkconv, who); |
7398 | 1642 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1643 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1644 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1645 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1646 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1647 |
10504 | 1648 g_free(who); |
1649 gtk_tree_path_free(path); | |
1650 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1651 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1652 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1653 |
8133 | 1654 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1655 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1656 { |
10827 | 1657 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1658 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1659 int index, i, total, found = 0; |
8133 | 1660 |
11581 | 1661 win = gtkconv->win; |
1662 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1663 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1664 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1665 /* 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
|
1666 for (i = forward ? index + 1 : index - 1; |
11581 | 1667 !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
|
1668 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1669 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1670 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1671 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1672 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1673 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1674 found = 1; |
8133 | 1675 } |
11252 | 1676 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1677 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1678 /* 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
|
1679 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1680 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1681 (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
|
1682 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1683 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1684 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1685 found = 1; |
8133 | 1686 } |
10827 | 1687 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1688 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1689 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1690 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1691 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1692 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1693 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1694 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1695 } |
11581 | 1696 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1697 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1698 } |
8133 | 1699 } |
1700 | |
10827 | 1701 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1702 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1703 } |
1704 | |
4359 | 1705 static gboolean |
8105 | 1706 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1707 { |
11581 | 1708 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1709 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1710 GaimGtkConversation *gtkconv; |
8105 | 1711 int curconv; |
1712 | |
10810 | 1713 gtkconv = (GaimGtkConversation *)data; |
10849 | 1714 conv = gtkconv->active_conv; |
11581 | 1715 win = gtkconv->win; |
1716 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1717 |
8105 | 1718 /* If CTRL was held down... */ |
1719 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1720 switch (event->keyval) { |
1721 case GDK_Up: | |
1722 if (!conv->send_history) | |
1723 break; | |
1724 | |
1725 if (!conv->send_history->prev) { | |
1726 GtkTextIter start, end; | |
1727 | |
1728 if (conv->send_history->data) | |
1729 g_free(conv->send_history->data); | |
1730 | |
1731 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1732 &start); | |
1733 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1734 | |
1735 conv->send_history->data = | |
8506 | 1736 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1737 } |
8677 | 1738 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1739 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1740 GObject *object; |
8677 | 1741 GtkTextIter iter; |
1742 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1743 |
1744 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1745 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1746 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1747 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1748 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
|
1749 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1750 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1751 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1752 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1753 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
|
1754 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1755 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1756 |
8061 | 1757 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1758 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1759 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1760 0, NULL); |
8677 | 1761 /* this is mainly just a hack so the formatting at the |
1762 * cursor gets picked up. */ | |
1763 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1764 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1765 } |
1766 | |
8105 | 1767 return TRUE; |
4359 | 1768 break; |
1769 | |
1770 case GDK_Down: | |
1771 if (!conv->send_history) | |
1772 break; | |
1773 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1774 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1775 GObject *object; |
8677 | 1776 GtkTextIter iter; |
1777 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1778 |
4359 | 1779 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1780 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1781 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1782 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1783 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
|
1784 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1785 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1786 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1787 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1788 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
|
1789 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1790 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1791 |
8105 | 1792 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1793 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1794 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1795 0, NULL); |
8677 | 1796 /* this is mainly just a hack so the formatting at the |
1797 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1798 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1799 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1800 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1801 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1802 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1803 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1804 } |
4359 | 1805 } |
1806 | |
8105 | 1807 return TRUE; |
4359 | 1808 break; |
8105 | 1809 |
8108 | 1810 case GDK_Page_Down: |
8143 | 1811 case ']': |
11581 | 1812 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1813 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1814 else |
11581 | 1815 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1816 return TRUE; |
1817 break; | |
1818 | |
8108 | 1819 case GDK_Page_Up: |
8143 | 1820 case '[': |
11581 | 1821 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1822 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1823 else |
11581 | 1824 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1825 return TRUE; |
1826 break; | |
1827 | |
8108 | 1828 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1829 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1830 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1831 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1832 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1833 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1834 } |
8108 | 1835 |
1836 return TRUE; | |
1837 break; | |
1838 | |
11252 | 1839 case GDK_comma: |
11581 | 1840 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1841 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1842 curconv - 1); |
1843 break; | |
1844 | |
1845 case GDK_period: | |
11581 | 1846 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1847 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1848 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1849 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1850 #else |
1851 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1852 #endif | |
11252 | 1853 break; |
1854 | |
8105 | 1855 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1856 } |
8758 | 1857 |
8105 | 1858 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1859 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1860 { |
10864 | 1861 if (event->keyval > '0' && event->keyval <= '9') |
1862 { | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1863 guint switchto = event->keyval - '1'; |
11581 | 1864 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1865 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1866 |
1867 return TRUE; | |
1868 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1869 } |
8758 | 1870 |
8105 | 1871 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1872 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1873 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1874 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1875 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1876 case GDK_Tab: |
9605 | 1877 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1878 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1879 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1880 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1881 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1882 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1883 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1884 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1885 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1886 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1887 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1888 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1889 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1890 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1891 } |
4359 | 1892 return FALSE; |
1893 } | |
1894 | |
1895 /* | |
1896 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1897 * 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
|
1898 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1899 * 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
|
1900 * going all the way down to the notebook. I suspect a bug in |
4359 | 1901 * GtkTextView, but I'm not ready to point any fingers yet. |
1902 */ | |
1903 static gboolean | |
1904 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1905 { | |
1906 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1907 /* Right single click */ | |
1908 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1909 | |
1910 return TRUE; | |
1911 } | |
1912 | |
1913 return FALSE; | |
1914 } | |
1915 | |
8173 | 1916 /* |
1917 * If someone tries to type into the conversation backlog of a | |
1918 * conversation window then we yank focus from the conversation backlog | |
1919 * and give it to the text entry box so that people can type | |
1920 * all the live long day and it will get entered into the entry box. | |
1921 */ | |
6057 | 1922 static gboolean |
8105 | 1923 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1924 { |
1925 GaimGtkConversation *gtkconv = data; | |
1926 | |
8237 | 1927 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1928 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1929 (event->keyval == GDK_F10) || |
1930 (event->keyval == GDK_Shift_L) || | |
1931 (event->keyval == GDK_Shift_R) || | |
1932 (event->keyval == GDK_Escape) || | |
8177 | 1933 (event->keyval == GDK_Up) || |
1934 (event->keyval == GDK_Down) || | |
1935 (event->keyval == GDK_Left) || | |
8191 | 1936 (event->keyval == GDK_Right) || |
1937 (event->keyval == GDK_Home) || | |
9297 | 1938 (event->keyval == GDK_End) || |
1939 (event->keyval == GDK_Tab) || | |
1940 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1941 return FALSE; |
1942 | |
1943 if (event->type == GDK_KEY_RELEASE) | |
1944 gtk_widget_grab_focus(gtkconv->entry); | |
1945 | |
1946 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1947 | |
1948 return TRUE; | |
6057 | 1949 } |
1950 | |
4359 | 1951 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1952 gaim_gtkconv_set_active_conversation(GaimConversation *conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1953 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1954 GaimGtkConversation *gtkconv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1955 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1956 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1957 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1958 gtkconv = GAIM_GTK_CONVERSATION(conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1959 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1960 if (gtkconv->active_conv == conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1961 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1962 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1963 gaim_conversation_close_logs(gtkconv->active_conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1964 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1965 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1966 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1967 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1968 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
|
1969 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1970 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
1971 void |
11604 | 1972 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
1973 { | |
1974 GaimGtkConversation *gtkconv; | |
1975 | |
1976 g_return_if_fail(conv != NULL); | |
1977 | |
1978 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1979 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1980 gaim_gtkconv_set_active_conversation(conv); |
11604 | 1981 |
1982 gray_stuff_out(gtkconv); | |
1983 update_typing_icon(gtkconv); | |
1984 | |
1985 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
1986 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
1987 | |
11671
4ebd27e664c4
[gaim-migrate @ 13957]
Luke Schierer <lschiere@pidgin.im>
parents:
11669
diff
changeset
|
1988 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT); |
11604 | 1989 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
1990 gaim_account_get_protocol_name(conv->account)); | |
1991 } | |
1992 | |
1993 static void | |
4673 | 1994 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1995 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
1996 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 1997 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1998 GaimConversation *conv; |
4359 | 1999 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2000 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2001 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2002 |
11594 | 2003 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 2004 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 2005 } |
2006 | |
2007 static void | |
2008 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
2009 gchar *new_text, gint new_text_length, gpointer user_data) | |
2010 { | |
10810 | 2011 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2012 GaimConversation *conv; | |
2013 | |
2014 g_return_if_fail(gtkconv != NULL); | |
11508 | 2015 |
10810 | 2016 conv = gtkconv->active_conv; |
4359 | 2017 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2018 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2019 return; |
2020 | |
10810 | 2021 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2022 gtk_text_iter_is_end(position))); | |
4359 | 2023 } |
2024 | |
2025 static void | |
2026 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2027 GtkTextIter *end_pos, gpointer user_data) | |
2028 { | |
10810 | 2029 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2030 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2031 GaimConvIm *im; |
4359 | 2032 |
10810 | 2033 g_return_if_fail(gtkconv != NULL); |
11508 | 2034 |
10810 | 2035 conv = gtkconv->active_conv; |
4359 | 2036 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2037 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2038 return; |
2039 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2040 im = GAIM_CONV_IM(conv); |
4359 | 2041 |
2042 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2043 | |
2044 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2045 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2046 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2047 |
2048 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2049 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2050 GAIM_NOT_TYPING); |
4359 | 2051 } |
2052 else { | |
2053 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2054 got_typing_keypress(gtkconv, FALSE); |
4359 | 2055 } |
2056 } | |
2057 | |
8189 | 2058 /************************************************************************** |
2059 * A bunch of buddy icon functions | |
2060 **************************************************************************/ | |
11581 | 2061 GdkPixbuf * |
2062 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2063 { |
10116 | 2064 GaimAccount *account = NULL; |
2065 const char *name = NULL; | |
7143 | 2066 GdkPixbuf *status = NULL; |
2067 | |
10116 | 2068 g_return_val_if_fail(conv != NULL, NULL); |
2069 | |
2070 account = gaim_conversation_get_account(conv); | |
2071 name = gaim_conversation_get_name(conv); | |
2072 | |
2073 g_return_val_if_fail(account != NULL, NULL); | |
2074 g_return_val_if_fail(name != NULL, NULL); | |
2075 | |
11338 | 2076 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2077 GaimBuddy *b = gaim_find_buddy(account, name); |
2078 if (b != NULL) { | |
2079 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2080 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2081 } |
2082 } | |
2083 | |
2084 if (!status) { | |
2085 GdkPixbuf *pixbuf; | |
10884 | 2086 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2087 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2088 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2089 { |
7143 | 2090 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2091 GDK_INTERP_BILINEAR); | |
2092 g_object_unref(pixbuf); | |
2093 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2094 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2095 status = pixbuf; |
7143 | 2096 } |
2097 return status; | |
2098 } | |
2099 | |
8189 | 2100 static void |
2101 update_tab_icon(GaimConversation *conv) | |
2102 { | |
2103 GaimGtkConversation *gtkconv; | |
11581 | 2104 GaimGtkWindow *win; |
8189 | 2105 GaimAccount *account; |
2106 const char *name; | |
2107 GdkPixbuf *status = NULL; | |
2108 | |
10116 | 2109 g_return_if_fail(conv != NULL); |
2110 | |
8189 | 2111 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2112 win = gtkconv->win; |
8189 | 2113 name = gaim_conversation_get_name(conv); |
2114 account = gaim_conversation_get_account(conv); | |
2115 | |
11581 | 2116 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2117 |
10116 | 2118 g_return_if_fail(status != NULL); |
2119 | |
8189 | 2120 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2121 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2122 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2123 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2124 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2125 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2126 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2127 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2128 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2129 { |
11581 | 2130 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2131 | |
2132 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2133 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2134 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2135 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2136 } |
8189 | 2137 } |
2138 | |
2139 static gboolean | |
2140 redraw_icon(gpointer data) | |
2141 { | |
10810 | 2142 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2143 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2144 GaimAccount *account; |
2145 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2146 |
2147 GdkPixbuf *buf; | |
2148 GdkPixbuf *scale; | |
2149 GdkPixmap *pm; | |
2150 GdkBitmap *bm; | |
2151 gint delay; | |
9318 | 2152 int scale_width, scale_height; |
8189 | 2153 |
2154 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2155 account = gaim_conversation_get_account(conv); |
2156 if(account && account->gc) | |
2157 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2158 |
2159 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2160 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2161 | |
10483 | 2162 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2163 NULL, &scale_width, &scale_height); |
2164 | |
2165 /* this code is ugly, and scares me */ | |
8189 | 2166 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2167 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2168 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2169 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2170 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2171 GDK_INTERP_BILINEAR); |
8189 | 2172 |
2173 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2174 g_object_unref(G_OBJECT(scale)); | |
2175 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2176 g_object_unref(G_OBJECT(pm)); | |
2177 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2178 | |
2179 if (bm) | |
2180 g_object_unref(G_OBJECT(bm)); | |
2181 | |
9131 | 2182 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2183 |
2184 if (delay < 100) | |
9131 | 2185 delay = 100; |
2186 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2187 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2188 |
2189 return FALSE; | |
2190 } | |
2191 | |
2192 static void | |
10810 | 2193 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2194 { |
2195 int delay; | |
2196 | |
8228 | 2197 if (gtkconv->u.im->anim == NULL) |
2198 return; | |
2199 | |
8202 | 2200 if (gtkconv->u.im->icon_timer != 0) |
2201 return; | |
2202 | |
8189 | 2203 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2204 return; | |
2205 | |
10639 | 2206 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2207 | |
2208 if (delay < 100) | |
2209 delay = 100; | |
2210 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2211 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2212 } |
2213 | |
2214 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2215 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2216 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2217 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2218 GaimGtkWindow *gtkwin; |
2219 | |
2220 g_return_if_fail(conv != NULL); | |
2221 | |
9887 | 2222 if (gtkconv->u.im->icon_container != NULL) |
2223 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2224 |
2225 if (gtkconv->u.im->anim != NULL) | |
2226 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2227 | |
2228 if (gtkconv->u.im->icon_timer != 0) | |
2229 g_source_remove(gtkconv->u.im->icon_timer); | |
2230 | |
2231 if (gtkconv->u.im->iter != NULL) | |
2232 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2233 | |
2234 gtkconv->u.im->icon_timer = 0; | |
2235 gtkconv->u.im->icon = NULL; | |
2236 gtkconv->u.im->anim = NULL; | |
2237 gtkconv->u.im->iter = NULL; | |
10456 | 2238 gtkconv->u.im->icon_container = NULL; |
9687 | 2239 gtkconv->u.im->show_icon = FALSE; |
10456 | 2240 |
11581 | 2241 gtkwin = gtkconv->win; |
10456 | 2242 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2243 } |
2244 | |
9497 | 2245 static void |
9504 | 2246 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2247 { |
10810 | 2248 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2249 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2250 FILE *fp; |
2251 GaimBuddyIcon *icon; | |
2252 const void *data; | |
2253 size_t len; | |
2254 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2255 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2256 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2257 return; |
2258 } | |
2259 | |
2260 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2261 data = gaim_buddy_icon_get_data(icon, &len); | |
2262 | |
2263 if ((len <= 0) || (data == NULL)) { | |
9504 | 2264 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2265 return; |
2266 } | |
2267 | |
2268 fwrite(data, 1, len, fp); | |
2269 fclose(fp); | |
2270 } | |
2271 | |
2272 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2273 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2274 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2275 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2276 const gchar *ext; |
9497 | 2277 gchar *buf; |
2278 | |
2279 g_return_if_fail(conv != NULL); | |
9504 | 2280 |
10953 | 2281 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2282 if (ext == NULL) | |
2283 ext = "icon"; | |
2284 | |
2285 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2286 |
2287 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2288 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2289 |
2290 g_free(buf); | |
2291 } | |
2292 | |
11581 | 2293 static void |
2294 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2295 { | |
2296 if (gtkconv->u.im->icon_timer != 0) | |
2297 g_source_remove(gtkconv->u.im->icon_timer); | |
2298 | |
2299 gtkconv->u.im->icon_timer = 0; | |
2300 } | |
2301 | |
2302 | |
2303 static void | |
2304 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2305 { | |
2306 gtkconv->u.im->animate = | |
2307 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2308 | |
2309 if (gtkconv->u.im->animate) | |
2310 start_anim(NULL, gtkconv); | |
2311 else | |
2312 stop_anim(NULL, gtkconv); | |
2313 } | |
2314 | |
8189 | 2315 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2316 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2317 { |
2318 static GtkWidget *menu = NULL; | |
2319 GtkWidget *button; | |
2320 | |
2321 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2322 return FALSE; | |
2323 | |
2324 /* | |
2325 * If a menu already exists, destroy it before creating a new one, | |
2326 * thus freeing-up the memory it occupied. | |
2327 */ | |
2328 if (menu != NULL) | |
2329 gtk_widget_destroy(menu); | |
2330 | |
2331 menu = gtk_menu_new(); | |
2332 | |
2333 if (gtkconv->u.im->anim && | |
2334 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2335 { | |
2336 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2337 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2338 gtkconv->u.im->icon_timer); |
2339 } | |
2340 | |
2341 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2342 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2343 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2344 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2345 gtk_widget_show(button); | |
2346 | |
2347 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
|
2348 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2349 0, 0, NULL); |
2350 | |
2351 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2352 | |
2353 return TRUE; | |
2354 } | |
10456 | 2355 |
2356 static void | |
2357 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2358 { | |
11581 | 2359 GaimGtkWindow *win = data; |
10456 | 2360 GaimConversation *conv; |
2361 GaimGtkConversation *gtkconv; | |
2362 gboolean active; | |
2363 | |
11581 | 2364 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2365 |
2366 if (!conv) | |
2367 return; | |
2368 | |
11338 | 2369 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2370 |
2371 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2372 | |
2373 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2374 gtkconv->u.im->show_icon = active; | |
2375 if (active) | |
2376 gaim_gtkconv_update_buddy_icon(conv); | |
2377 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2378 remove_icon(gtkconv); |
10456 | 2379 } |
2380 | |
8189 | 2381 /************************************************************************** |
2382 * End of the bunch of buddy icon functions | |
2383 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2384 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2385 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2386 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2387 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2388 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2389 if(gtkconv->win==hidden_convwin) { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
2390 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2391 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2392 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2393 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2394 gaim_gtkconv_set_active_conversation(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2395 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2396 gaim_gtk_conv_window_raise(gtkconv->win); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2397 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2398 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2399 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2400 GaimConversation * |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2401 gaim_gtk_conversations_get_first_unseen(GaimConversationType type, |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2402 GaimUnseenState min_state) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2403 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2404 GList *l; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2405 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2406 if(type==GAIM_CONV_TYPE_IM) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2407 l = gaim_get_ims(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2408 } else if(type==GAIM_CONV_TYPE_CHAT) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2409 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2410 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2411 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2412 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2413 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2414 for(; l!=NULL; l=l->next) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2415 GaimConversation *conv = (GaimConversation*)l->data; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2416 if (GAIM_GTK_CONVERSATION(conv)->unseen_state >= min_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2417 return conv; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2418 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2419 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2420 return NULL; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2421 } |
8189 | 2422 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2423 static void |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2424 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2425 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2426 g_return_if_fail(conv != NULL); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2427 gaim_gtkconv_present_conversation(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2428 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2429 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2430 guint |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2431 gaim_gtk_conversations_fill_unseen_menu(GtkWidget *menu, |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2432 GaimConversationType type, |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2433 GaimUnseenState min_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2434 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2435 GList *l; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2436 guint ret = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2437 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2438 g_return_val_if_fail(menu != NULL, 0); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2439 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2440 if (type == GAIM_CONV_TYPE_IM) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2441 l = gaim_get_ims(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2442 } else if (type == GAIM_CONV_TYPE_CHAT) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2443 l = gaim_get_chats(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2444 } else { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2445 l = gaim_get_conversations(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2446 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2447 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2448 for (; l != NULL ; l = l->next) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2449 GaimConversation *conv = (GaimConversation*)l->data; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2450 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2451 |
12239 | 2452 if (gtkconv->unseen_state >= min_state && gtkconv->win == hidden_convwin) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2453 GtkWidget *icon = gtk_image_new(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2454 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2455 GtkWidget *item; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2456 gchar *text = g_strdup_printf("%s (%d)", |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2457 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2458 gtkconv->unseen_count); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2459 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2460 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2461 g_object_unref(pbuf); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2462 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2463 item = gtk_image_menu_item_new_with_label(text); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2464 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), icon); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2465 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(unseen_conv_menu_cb), conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2466 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2467 g_free(text); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2468 ret++; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2469 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2470 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2471 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2472 return ret; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2473 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2474 |
11581 | 2475 GaimGtkWindow * |
2476 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2477 { | |
2478 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2479 return gtkconv->win; | |
2480 } | |
2481 | |
2482 static GtkItemFactoryEntry menu_items[] = | |
2483 { | |
2484 /* Conversation menu */ | |
2485 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, | |
2486 | |
2487 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2488 0, "<StockItem>", GAIM_STOCK_IM }, | |
2489 | |
2490 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
2491 | |
2492 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2493 "<StockItem>", GTK_STOCK_FIND }, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2494 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", GAIM_STOCK_LOG }, |
11581 | 2495 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2496 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
12240 | 2497 { N_("/Conversation/Clea_r"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
11581 | 2498 |
2499 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, | |
2500 | |
2501 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2502 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2503 0, "<StockItem>", GAIM_STOCK_POUNCE }, |
11581 | 2504 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2505 "<StockItem>", GAIM_STOCK_INFO }, | |
2506 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2507 "<StockItem>", GAIM_STOCK_INVITE }, | |
2508 | |
2509 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
2510 | |
2511 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2512 "<StockItem>", GAIM_STOCK_EDIT }, | |
2513 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2514 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2515 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2516 "<StockItem>", GTK_STOCK_ADD }, | |
2517 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2518 "<StockItem>", GTK_STOCK_REMOVE }, | |
2519 | |
2520 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, | |
2521 | |
2522 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2523 "<StockItem>", GAIM_STOCK_LINK }, | |
2524 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2525 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2526 | |
2527 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, | |
2528 | |
2529 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2530 "<StockItem>", GTK_STOCK_CLOSE }, | |
2531 | |
2532 /* Options */ | |
2533 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, | |
2534 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2535 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
2536 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, | |
2537 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, | |
2538 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>" }, | |
2539 }; | |
2540 | |
2541 static const int menu_item_count = | |
2542 sizeof(menu_items) / sizeof(*menu_items); | |
2543 | |
2544 static char * | |
2545 item_factory_translate_func (const char *path, gpointer func_data) | |
2546 { | |
2547 return _((char *)path); | |
2548 } | |
2549 | |
2550 static GtkWidget * | |
2551 setup_menubar(GaimGtkWindow *win) | |
2552 { | |
2553 GtkAccelGroup *accel_group; | |
2554 | |
2555 accel_group = gtk_accel_group_new (); | |
2556 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2557 g_object_unref(accel_group); | |
2558 | |
2559 win->menu.item_factory = | |
2560 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2561 | |
2562 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2563 item_factory_translate_func, | |
2564 NULL, NULL); | |
2565 | |
2566 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2567 menu_items, win); | |
2568 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2569 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2570 | |
2571 | |
2572 win->menu.menubar = | |
2573 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2574 | |
2575 | |
2576 win->menu.view_log = | |
2577 gtk_item_factory_get_widget(win->menu.item_factory, | |
2578 N_("/Conversation/View Log")); | |
2579 | |
2580 /* --- */ | |
2581 | |
2582 win->menu.send_file = | |
2583 gtk_item_factory_get_widget(win->menu.item_factory, | |
2584 N_("/Conversation/Send File...")); | |
2585 | |
2586 win->menu.add_pounce = | |
2587 gtk_item_factory_get_widget(win->menu.item_factory, | |
2588 N_("/Conversation/Add Buddy Pounce...")); | |
2589 | |
2590 /* --- */ | |
2591 | |
2592 win->menu.get_info = | |
2593 gtk_item_factory_get_widget(win->menu.item_factory, | |
2594 N_("/Conversation/Get Info")); | |
2595 | |
2596 win->menu.invite = | |
2597 gtk_item_factory_get_widget(win->menu.item_factory, | |
2598 N_("/Conversation/Invite...")); | |
2599 | |
2600 /* --- */ | |
2601 | |
2602 win->menu.alias = | |
2603 gtk_item_factory_get_widget(win->menu.item_factory, | |
2604 N_("/Conversation/Alias...")); | |
2605 | |
2606 win->menu.block = | |
2607 gtk_item_factory_get_widget(win->menu.item_factory, | |
2608 N_("/Conversation/Block...")); | |
2609 | |
2610 win->menu.add = | |
2611 gtk_item_factory_get_widget(win->menu.item_factory, | |
2612 N_("/Conversation/Add...")); | |
2613 | |
2614 win->menu.remove = | |
2615 gtk_item_factory_get_widget(win->menu.item_factory, | |
2616 N_("/Conversation/Remove...")); | |
2617 | |
2618 /* --- */ | |
2619 | |
2620 win->menu.insert_link = | |
2621 gtk_item_factory_get_widget(win->menu.item_factory, | |
2622 N_("/Conversation/Insert Link...")); | |
2623 | |
2624 win->menu.insert_image = | |
2625 gtk_item_factory_get_widget(win->menu.item_factory, | |
2626 N_("/Conversation/Insert Image...")); | |
2627 | |
2628 /* --- */ | |
2629 | |
2630 win->menu.logging = | |
2631 gtk_item_factory_get_widget(win->menu.item_factory, | |
2632 N_("/Options/Enable Logging")); | |
2633 win->menu.sounds = | |
2634 gtk_item_factory_get_widget(win->menu.item_factory, | |
2635 N_("/Options/Enable Sounds")); | |
2636 win->menu.show_formatting_toolbar = | |
2637 gtk_item_factory_get_widget(win->menu.item_factory, | |
2638 N_("/Options/Show Formatting Toolbars")); | |
2639 win->menu.show_timestamps = | |
2640 gtk_item_factory_get_widget(win->menu.item_factory, | |
2641 N_("/Options/Show Timestamps")); | |
2642 win->menu.show_icon = | |
2643 gtk_item_factory_get_widget(win->menu.item_factory, | |
2644 N_("/Options/Show Buddy Icon")); | |
2645 | |
2646 | |
2647 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2648 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2649 win->menu.tray); | |
2650 gtk_widget_show(win->menu.tray); | |
2651 | |
2652 gtk_widget_show(win->menu.menubar); | |
2653 | |
2654 return win->menu.menubar; | |
2655 } | |
2656 | |
4359 | 2657 |
2658 /************************************************************************** | |
2659 * Utility functions | |
2660 **************************************************************************/ | |
2661 | |
2662 static void | |
10810 | 2663 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2664 { |
10810 | 2665 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2666 GaimConvIm *im; |
4685 | 2667 |
4359 | 2668 /* |
2669 * 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
|
2670 * send GAIM_TYPED any time soon. |
4359 | 2671 */ |
2672 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2673 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2674 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2675 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2676 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2677 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2678 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2679 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2680 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2681 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2682 |
2683 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2684 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2685 GAIM_TYPING); |
4359 | 2686 |
2687 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2688 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2689 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2690 gaim_conv_im_set_type_again(im, 0); |
4359 | 2691 } |
2692 } | |
2693 | |
4736 | 2694 static void |
10810 | 2695 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2696 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2697 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2698 GaimConvIm *im = NULL; |
10810 | 2699 GaimConversation *conv = gtkconv->active_conv; |
12008 | 2700 char *stock_id, *tooltip; |
11508 | 2701 |
11581 | 2702 gtkwin = gtkconv->win; |
4736 | 2703 |
12008 | 2704 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2705 im = GAIM_CONV_IM(conv); |
4736 | 2706 |
12008 | 2707 if (gtkwin->menu.typing_icon) { |
2708 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2709 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2710 |
12008 | 2711 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2712 return; | |
2713 | |
2714 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2715 stock_id = GAIM_STOCK_TYPING; | |
2716 tooltip = _("User is typing..."); | |
2717 } else { | |
2718 stock_id = GAIM_STOCK_TYPED; | |
2719 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2720 } |
12008 | 2721 |
2722 if (gtkwin->menu.typing_icon == NULL) | |
2723 { | |
2724 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
|
2725 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
|
2726 gtkwin->menu.typing_icon, |
12008 | 2727 tooltip); |
4736 | 2728 } |
12008 | 2729 else |
2730 { | |
2731 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2732 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2733 gtkwin->menu.typing_icon, | |
2734 tooltip); | |
2735 } | |
2736 | |
2737 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2738 } |
2739 | |
4685 | 2740 static gboolean |
11594 | 2741 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2742 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2743 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2744 GaimConversation *conv; |
4359 | 2745 GtkWidget *menu; |
2746 GList *child; | |
11594 | 2747 GaimBuddy *b; |
11581 | 2748 |
2749 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2750 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2751 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2752 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2753 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2754 account = gaim_conversation_get_account(conv); |
11581 | 2755 |
11594 | 2756 if (win->menu.send_to == NULL) |
4685 | 2757 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2758 |
11594 | 2759 if (!(b = gaim_find_buddy(account, conv->name))) |
2760 return FALSE; | |
2761 | |
2762 | |
2763 gtk_widget_show(win->menu.send_to); | |
4359 | 2764 |
2765 menu = gtk_menu_item_get_submenu( | |
11594 | 2766 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2767 |
2768 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2769 child != NULL; | |
2770 child = child->next) { | |
2771 | |
2772 GtkWidget *item = child->data; | |
11594 | 2773 GaimBuddy *item_buddy; |
2774 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2775 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2776 "gaim_buddy_name"); | |
2777 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2778 | |
2779 if (b == item_buddy) { | |
4359 | 2780 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2781 break; | |
2782 } | |
2783 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2784 |
4685 | 2785 return FALSE; |
4359 | 2786 } |
2787 | |
2788 static void | |
11594 | 2789 create_sendto_item(GtkWidget *menu, GtkSizeGroup *sg, GSList **group, GaimBuddy *bud) |
2790 { | |
2791 GaimAccount *account; | |
2792 GtkWidget *box; | |
2793 GtkWidget *label; | |
2794 GtkWidget *image; | |
2795 GtkWidget *menuitem; | |
11625 | 2796 GdkPixbuf *pixbuf; |
11616 | 2797 gchar *text; |
11594 | 2798 |
2799 account = bud->account; | |
2800 | |
2801 /* Create a pixmap for the protocol icon. */ | |
11625 | 2802 pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)bud, GAIM_STATUS_ICON_SMALL); |
11594 | 2803 /* Now convert it to GtkImage */ |
2804 if (pixbuf == NULL) | |
2805 image = gtk_image_new(); | |
2806 else | |
11625 | 2807 image = gtk_image_new_from_pixbuf(pixbuf); |
11594 | 2808 |
2809 gtk_size_group_add_widget(sg, image); | |
2810 | |
2811 g_object_unref(G_OBJECT(pixbuf)); | |
2812 | |
2813 /* Make our menu item */ | |
11616 | 2814 text = g_strdup_printf("%s (%s)", gaim_buddy_get_name(bud), gaim_account_get_username(bud->account)); |
2815 menuitem = gtk_radio_menu_item_new_with_label(*group, text); | |
2816 g_free(text); | |
11594 | 2817 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2818 | |
2819 /* Do some evil, see some evil, speak some evil. */ | |
2820 box = gtk_hbox_new(FALSE, 0); | |
2821 | |
2822 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
2823 g_object_ref(label); | |
2824 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
2825 | |
2826 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
2827 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
2828 | |
2829 g_object_unref(label); | |
2830 | |
2831 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
2832 | |
2833 gtk_widget_show(label); | |
2834 gtk_widget_show(image); | |
2835 gtk_widget_show(box); | |
2836 | |
2837 /* Set our data and callbacks. */ | |
2838 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
2839 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(gaim_buddy_get_name(bud)), g_free); | |
2840 | |
2841 g_signal_connect(G_OBJECT(menuitem), "activate", | |
2842 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2843 | |
2844 gtk_widget_show(menuitem); | |
2845 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2846 } | |
2847 | |
2848 static void | |
2849 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 2850 { |
4359 | 2851 GtkWidget *menu; |
2852 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2853 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 2854 GaimGtkConversation *gtkconv; |
2855 GSList *l, *buds; | |
2856 | |
2857 g_return_if_fail(win != NULL); | |
2858 | |
2859 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
2860 | |
11604 | 2861 g_return_if_fail(gtkconv != NULL); |
2862 | |
11594 | 2863 if (win->menu.send_to != NULL) |
2864 gtk_widget_destroy(win->menu.send_to); | |
2865 | |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12272
diff
changeset
|
2866 /* Build the Send To menu */ |
11594 | 2867 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
2868 gtk_widget_show(win->menu.send_to); | |
4359 | 2869 |
2870 menu = gtk_menu_new(); | |
11581 | 2871 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 2872 win->menu.send_to, 2); |
2873 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 2874 |
2875 gtk_widget_show(menu); | |
2876 | |
11604 | 2877 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
2878 buds = gaim_find_buddies(gtkconv->active_conv->account, gtkconv->active_conv->name); | |
2879 for (l = buds; l != NULL; l = l->next) { | |
2880 GaimBuddy *b; | |
2881 GaimBlistNode *node; | |
2882 | |
2883 b = l->data; | |
2884 node = (GaimBlistNode *) gaim_buddy_get_contact(b); | |
2885 | |
2886 for (node = node->child; node != NULL; node = node->next) | |
2887 if (GAIM_BLIST_NODE_IS_BUDDY(node) && gaim_account_is_connected(((GaimBuddy *)node)->account)) | |
2888 create_sendto_item(menu, sg, &group, (GaimBuddy *) node); | |
2889 } | |
2890 | |
2891 g_slist_free(buds); | |
4359 | 2892 } |
2893 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2894 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2895 |
11594 | 2896 gtk_widget_show(win->menu.send_to); |
2897 if (!group) | |
2898 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
2899 update_send_to_selection(win); | |
4359 | 2900 } |
2901 | |
2902 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2903 generate_invite_user_names(GaimConnection *gc) |
4359 | 2904 { |
6695 | 2905 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 2906 static GList *tmp = NULL; |
2907 | |
2908 if (tmp) | |
2909 g_list_free(tmp); | |
2910 | |
2911 tmp = g_list_append(NULL, ""); | |
2912 | |
2913 if (gc != NULL) { | |
4785 | 2914 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2915 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2916 continue; | |
6695 | 2917 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2918 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 2919 continue; |
6695 | 2920 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
2921 GaimBuddy *buddy; | |
2922 | |
2923 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2924 continue; | |
2925 | |
2926 buddy = (GaimBuddy *)bnode; | |
2927 | |
2928 if (buddy->account == gc->account && | |
2929 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 2930 tmp = g_list_insert_sorted(tmp, buddy->name, |
2931 (GCompareFunc)g_utf8_collate); | |
6695 | 2932 } |
4359 | 2933 } |
2934 } | |
2935 } | |
2936 | |
2937 return tmp; | |
2938 } | |
2939 | |
9498 | 2940 static GdkPixbuf * |
9554 | 2941 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 2942 { |
9554 | 2943 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 2944 char *filename; |
10274 | 2945 const char *image = NULL; |
9554 | 2946 |
2947 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 2948 image = "founder.png"; |
9554 | 2949 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 2950 image = "op.png"; |
9554 | 2951 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 2952 image = "halfop.png"; |
9554 | 2953 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 2954 image = "voice.png"; |
9554 | 2955 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 2956 image = "ignored.png"; |
2957 } else { | |
2958 return NULL; | |
9554 | 2959 } |
10274 | 2960 |
2961 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2962 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
2963 g_free(filename); | |
2964 | |
2965 if (!pixbuf) | |
2966 return NULL; | |
2967 | |
2968 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
2969 g_object_unref(pixbuf); | |
2970 | |
2971 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
2972 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 2973 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
2974 g_free(filename); | |
10274 | 2975 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 2976 g_object_unref(pixbuf); |
10274 | 2977 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
2978 g_object_unref(scale2); | |
9498 | 2979 } |
2980 | |
10274 | 2981 return scale; |
9498 | 2982 } |
2983 | |
4359 | 2984 static void |
11869 | 2985 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 2986 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2987 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2988 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2989 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2990 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2991 GaimPluginProtocolInfo *prpl_info; |
4359 | 2992 GtkListStore *ls; |
9498 | 2993 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2994 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2995 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2996 gboolean is_buddy; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2997 GdkColor send_color; |
11508 | 2998 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2999 gdk_color_parse(SEND_COLOR, &send_color); |
4359 | 3000 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3001 chat = GAIM_CONV_CHAT(conv); |
4359 | 3002 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3003 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3004 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3005 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3006 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3007 return; |
4359 | 3008 |
3009 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3010 | |
9554 | 3011 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 3012 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3013 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
|
3014 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3015 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3016 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3017 |
4359 | 3018 gtk_list_store_append(ls, &iter); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3019 gtk_list_store_set(ls, &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3020 CHAT_USERS_ICON_COLUMN, pixbuf, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3021 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3022 CHAT_USERS_NAME_COLUMN, name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3023 CHAT_USERS_FLAGS_COLUMN, flags, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3024 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
|
3025 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3026 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3027 |
9554 | 3028 if (pixbuf) |
3029 g_object_unref(pixbuf); | |
4359 | 3030 } |
3031 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3032 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3033 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
|
3034 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3035 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3036 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3037 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3038 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3039 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3040 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3041 /* if we're here, it's a possible completion */ |
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 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3044 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3045 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3046 * on *most_matched is >= 0 |
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 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3049 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3050 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3051 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3052 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3053 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3054 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3055 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3056 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3057 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3058 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3059 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3060 (*most_matched)++; |
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 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3063 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3064 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3065 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3066 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3067 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3068 |
9605 | 3069 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3070 tab_complete(GaimConversation *conv) |
4359 | 3071 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3072 GaimGtkConversation *gtkconv; |
4359 | 3073 GtkTextIter cursor, word_start, start_buffer; |
3074 int start; | |
3075 int most_matched = -1; | |
3076 char *entered, *partial = NULL; | |
3077 char *text; | |
8021 | 3078 char *nick_partial; |
9605 | 3079 const char *prefix; |
4359 | 3080 GList *matches = NULL; |
9605 | 3081 gboolean command = FALSE; |
4359 | 3082 |
3083 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3084 | |
3085 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3086 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3087 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3088 | |
3089 word_start = cursor; | |
3090 | |
3091 /* if there's nothing there just return */ | |
3092 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3093 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
|
3094 |
4359 | 3095 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3096 &cursor, FALSE); | |
3097 | |
3098 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3099 start = strlen(text) - 1; | |
3100 | |
8021 | 3101 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3102 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3103 start-=2; |
3104 } | |
4359 | 3105 |
3106 /* find the start of the word that we're tabbing */ | |
3107 while (start >= 0 && text[start] != ' ') { | |
3108 gtk_text_iter_backward_char(&word_start); | |
3109 start--; | |
3110 } | |
3111 | |
9605 | 3112 prefix = gaim_gtk_get_cmd_prefix(); |
3113 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3114 command = TRUE; | |
3115 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3116 } | |
3117 | |
4359 | 3118 g_free(text); |
3119 | |
3120 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3121 &cursor, FALSE); | |
3122 | |
8021 | 3123 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3124 g_free(entered); |
11338 | 3125 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3126 } |
3127 | |
8021 | 3128 nick_partial = g_malloc(strlen(entered)+1); |
3129 | |
9605 | 3130 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3131 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3132 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3133 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3134 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3135 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3136 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3137 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3138 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3139 g_list_free(list); |
11338 | 3140 } 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
|
3141 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3142 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3143 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
|
3144 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3145 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3146 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3147 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3148 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3149 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3150 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3151 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3152 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3153 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3154 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3155 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
|
3156 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3157 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3158 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3159 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3160 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3161 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3162 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3163 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3164 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3165 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3166 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3167 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3168 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3169 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3170 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3171 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3172 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3173 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3174 } |
9605 | 3175 } else { |
3176 g_free(nick_partial); | |
3177 g_free(entered); | |
3178 return FALSE; | |
3179 } | |
3180 | |
8021 | 3181 g_free(nick_partial); |
3182 | |
4359 | 3183 /* we're only here if we're doing new style */ |
3184 | |
3185 /* if there weren't any matches, return */ | |
3186 if (!matches) { | |
3187 /* if matches isn't set partials won't be either */ | |
3188 g_free(entered); | |
11338 | 3189 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3190 } |
3191 | |
3192 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3193 | |
3194 if (!matches->next) { | |
3195 /* there was only one match. fill it in. */ | |
3196 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3197 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3198 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3199 | |
3200 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3201 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3202 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3203 g_free(tmp); | |
3204 } | |
3205 else | |
3206 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3207 matches->data, -1); | |
3208 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3209 g_free(matches->data); |
4359 | 3210 matches = g_list_remove(matches, matches->data); |
3211 } | |
3212 else { | |
3213 /* | |
3214 * there were lots of matches, fill in as much as possible | |
3215 * and display all of them | |
3216 */ | |
3217 char *addthis = g_malloc0(1); | |
3218 | |
3219 while (matches) { | |
3220 char *tmp = addthis; | |
3221 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3222 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3223 g_free(matches->data); |
4359 | 3224 matches = g_list_remove(matches, matches->data); |
3225 } | |
3226 | |
6982 | 3227 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3228 time(NULL)); |
3229 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3230 g_free(addthis); | |
3231 } | |
3232 | |
3233 g_free(entered); | |
3234 g_free(partial); | |
9605 | 3235 |
3236 return TRUE; | |
4359 | 3237 } |
3238 | |
10810 | 3239 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3240 { |
3241 GaimPluginProtocolInfo *prpl_info = NULL; | |
3242 GaimConnection *gc; | |
10810 | 3243 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3244 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3245 char *new_topic; |
8858 | 3246 const char *current_topic; |
7971 | 3247 |
3248 gc = gaim_conversation_get_gc(conv); | |
3249 | |
3250 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3251 return; | |
3252 | |
3253 if(prpl_info->set_chat_topic == NULL) | |
3254 return; | |
3255 | |
3256 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3257 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3258 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3259 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3260 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3261 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3262 g_free(new_topic); |
7971 | 3263 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3264 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3265 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3266 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3267 |
8858 | 3268 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3269 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3270 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3271 g_free(new_topic); |
7971 | 3272 } |
3273 | |
9554 | 3274 static gint |
3275 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3276 { | |
3277 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3278 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3279 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3280 gint ret = 0; |
3281 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3282 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3283 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3284 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3285 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3286 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3287 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3288 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3289 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3290 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3291 -1); |
9554 | 3292 |
3293 if (user1 == NULL || user2 == NULL) { | |
3294 if (!(user1 == NULL && user2 == NULL)) | |
3295 ret = (user1 == NULL) ? -1: 1; | |
3296 } else if (f1 != f2) { | |
3297 /* sort more important users first */ | |
3298 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3299 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3300 ret = buddy1 ? -1 : 1; |
9554 | 3301 } else { |
10904 | 3302 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3303 } |
3304 | |
3305 g_free(user1); | |
3306 g_free(user2); | |
3307 | |
3308 return ret; | |
3309 } | |
3310 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3311 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3312 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
|
3313 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3314 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3315 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3316 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3317 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3318 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3319 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3320 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3321 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3322 g_return_if_fail(conv != NULL); |
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 /* 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
|
3325 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
|
3326 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3327 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
|
3328 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3329 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3330 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->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 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3333 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3334 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3335 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
|
3336 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3339 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3340 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3341 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3342 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3343 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3344 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3345 alias = gaim_buddy_get_contact_alias(buddy2); |
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 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3348 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3349 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3350 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3351 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3352 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3353 break; |
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 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3357 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3358 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3359 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3360 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3361 g_free(normalized_name); |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3364 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3365 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
|
3366 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3367 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3368 GaimPluginProtocolInfo *prpl_info; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3369 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3370 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3371 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3372 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3373 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3374 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3375 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3376 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3377 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3378 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3379 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3380 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3381 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3382 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3383 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3384 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3385 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3386 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3387 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3388 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3389 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3390 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3391 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3392 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3393 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3394 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3395 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3396 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3397 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3398 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3399 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3400 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3401 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3402 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3403 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3404 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3405 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3406 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3407 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3408 /* 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
|
3409 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3410 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3411 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3412 /* 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
|
3413 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
|
3414 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3415 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
|
3416 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3417 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3418 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3419 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3420 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3421 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3422 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3423 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
|
3424 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3425 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3426 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
|
3427 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3428 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3429 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3430 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3431 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3432 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3433 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3434 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3435 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3436 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3437 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3438 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3439 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3440 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3441 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3442 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3443 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3444 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3445 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3446 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3447 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3448 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3449 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3450 /* 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
|
3451 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3452 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3453 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3454 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3455 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3456 |
4359 | 3457 static GtkWidget * |
10810 | 3458 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3459 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3460 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3461 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3462 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3463 GaimConnection *gc; |
4359 | 3464 GtkWidget *vpaned, *hpaned; |
10175 | 3465 GtkWidget *vbox, *hbox, *frame; |
4359 | 3466 GtkWidget *lbox, *bbox; |
3467 GtkWidget *label; | |
3468 GtkWidget *list; | |
3469 GtkWidget *button; | |
7949 | 3470 GtkWidget *sw; |
4359 | 3471 GtkListStore *ls; |
3472 GtkCellRenderer *rend; | |
3473 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3474 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3475 GList *focus_chain = NULL; |
4359 | 3476 |
3477 gtkchat = gtkconv->u.chat; | |
3478 gc = gaim_conversation_get_gc(conv); | |
3479 | |
3480 /* Setup the outer pane. */ | |
3481 vpaned = gtk_vpaned_new(); | |
3482 gtk_widget_show(vpaned); | |
3483 | |
3484 /* Setup the top part of the pane. */ | |
11243 | 3485 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3486 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3487 gtk_widget_show(vbox); |
3488 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3489 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3490 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3491 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3492 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3493 { |
11243 | 3494 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3495 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3496 gtk_widget_show(hbox); |
3497 | |
3498 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3499 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3500 gtk_widget_show(label); |
3501 | |
3502 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3503 |
7971 | 3504 if(prpl_info->set_chat_topic == NULL) { |
3505 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3506 } else { | |
3507 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3508 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3509 } |
3510 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3511 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3512 gtk_widget_show(gtkchat->topic_text); |
3513 } | |
3514 | |
3515 /* Setup the horizontal pane. */ | |
3516 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3517 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3518 gtk_widget_show(hpaned); |
3519 | |
10175 | 3520 /* Setup gtkihmtml. */ |
3521 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3522 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3523 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3524 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3525 gtk_widget_show(frame); | |
3526 | |
3527 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3528 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3529 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3530 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3531 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3532 |
4359 | 3533 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3534 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3535 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3536 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3537 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3538 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3539 |
3540 /* Build the right pane. */ | |
11243 | 3541 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3542 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3543 gtk_widget_show(lbox); |
3544 | |
3545 /* Setup the label telling how many people are in the room. */ | |
3546 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3547 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3548 gtk_widget_show(gtkchat->count); | |
3549 | |
3550 /* Setup the list of users. */ | |
7949 | 3551 sw = gtk_scrolled_window_new(NULL, NULL); |
3552 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3553 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3554 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3555 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3556 gtk_widget_show(sw); | |
4359 | 3557 |
9554 | 3558 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
|
3559 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
|
3560 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3561 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3562 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3563 GTK_SORT_ASCENDING); |
3564 | |
3565 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3566 | |
9498 | 3567 rend = gtk_cell_renderer_pixbuf_new(); |
3568 | |
4359 | 3569 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3570 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3571 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3572 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3573 |
3574 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3575 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3576 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3577 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3578 |
9498 | 3579 rend = gtk_cell_renderer_text_new(); |
3580 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3581 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3582 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3583 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3584 NULL); |
4359 | 3585 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3586 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3587 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3588 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3589 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3590 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3591 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3592 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3593 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3594 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3595 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3596 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3597 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3598 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3599 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3600 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3601 #endif |
4359 | 3602 |
3603 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3604 | |
3605 gtk_widget_set_size_request(list, 150, -1); | |
3606 | |
3607 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3608 gtk_widget_show(list); | |
3609 | |
3610 gtkchat->list = list; | |
3611 | |
7949 | 3612 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3613 |
3614 /* Setup the user list toolbar. */ | |
11243 | 3615 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3616 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3617 gtk_widget_show(bbox); | |
3618 | |
3619 /* IM */ | |
10221 | 3620 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3621 GAIM_BUTTON_VERTICAL); |
10500 | 3622 gtkchat->userlist_im = button; |
4359 | 3623 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3624 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
|
3625 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3626 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3627 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3628 |
3629 gtk_widget_show(button); | |
3630 | |
3631 /* Ignore */ | |
3632 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3633 GAIM_BUTTON_VERTICAL); | |
10500 | 3634 gtkchat->userlist_ignore = button; |
4359 | 3635 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3636 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
|
3637 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3638 _("Ignore the user"), NULL); |
4359 | 3639 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3640 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3641 gtk_widget_show(button); |
3642 | |
3643 /* Info */ | |
3644 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3645 GAIM_BUTTON_VERTICAL); | |
10500 | 3646 gtkchat->userlist_info = button; |
4359 | 3647 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3648 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3649 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3650 _("Get the user's information"), NULL); |
4359 | 3651 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3652 G_CALLBACK(info_cb), gtkconv); |
4359 | 3653 |
3654 gtk_widget_show(button); | |
3655 | |
10175 | 3656 /* Setup the bottom half of the conversation window */ |
11243 | 3657 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3658 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3659 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3660 |
11243 | 3661 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3662 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3663 gtk_widget_show(gtkconv->lower_hbox); | |
3664 | |
11243 | 3665 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3666 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3667 gtk_widget_show(vbox); | |
3668 | |
10175 | 3669 /* Setup the toolbar, entry widget and all signals */ |
3670 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3671 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3672 gtk_widget_show(frame); |
3673 | |
9005 | 3674 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3675 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3676 gaim_account_get_protocol_name(conv->account)); |
10175 | 3677 gtk_widget_set_size_request(gtkconv->entry, -1, |
3678 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3679 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3680 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3681 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3682 |
3683 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3684 G_CALLBACK(entry_key_press_cb), gtkconv); |
10115 | 3685 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
10810 | 3686 G_CALLBACK(send_cb), gtkconv); |
4359 | 3687 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3688 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3689 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3690 G_CALLBACK(size_allocate_cb), gtkconv); |
3691 | |
3692 default_formatize(gtkconv); | |
4359 | 3693 |
9080 | 3694 /* |
3695 * Focus for chat windows should be as follows: | |
3696 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3697 * user list buttons -> entry -> buttons at bottom | |
3698 */ | |
9332 | 3699 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3700 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3701 | |
4359 | 3702 return vpaned; |
3703 } | |
3704 | |
3705 static GtkWidget * | |
10810 | 3706 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 3707 { |
10810 | 3708 GaimConversation *conv = gtkconv->active_conv; |
10175 | 3709 GtkWidget *frame; |
4359 | 3710 GtkWidget *paned; |
10175 | 3711 GtkWidget *vbox; |
3712 GtkWidget *vbox2; | |
9080 | 3713 GList *focus_chain = NULL; |
4359 | 3714 |
10175 | 3715 /* Setup the outer pane */ |
4359 | 3716 paned = gtk_vpaned_new(); |
3717 gtk_widget_show(paned); | |
3718 | |
10175 | 3719 /* Setup the top part of the pane */ |
11243 | 3720 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3721 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3722 gtk_widget_show(vbox); |
3723 | |
10175 | 3724 /* Setup the gtkimhtml widget */ |
3725 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3726 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3727 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 3728 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
3729 gtk_widget_show(frame); | |
3730 | |
3731 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3732 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3733 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 3734 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3735 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3736 |
3737 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 3738 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 3739 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 3740 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3741 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 3742 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 3743 |
10175 | 3744 /* Setup the bottom half of the conversation window */ |
11243 | 3745 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3746 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3747 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3748 |
11243 | 3749 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3750 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3751 gtk_widget_show(gtkconv->lower_hbox); | |
3752 | |
11243 | 3753 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3754 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
3755 gtk_widget_show(vbox2); | |
8821 | 3756 |
10175 | 3757 /* Setup the toolbar, entry widget and all signals */ |
3758 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3759 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 3760 gtk_widget_show(frame); |
3761 | |
9005 | 3762 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3763 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3764 gaim_account_get_protocol_name(conv->account)); |
10175 | 3765 gtk_widget_set_size_request(gtkconv->entry, -1, |
3766 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3767 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3768 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3769 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
|
3770 |
4359 | 3771 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 3772 G_CALLBACK(entry_key_press_cb), gtkconv); |
3773 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), gtkconv); | |
4359 | 3774 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3775 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3776 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3777 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3778 |
3779 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 3780 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 3781 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 3782 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 3783 |
8481 | 3784 /* had to move this after the imtoolbar is attached so that the |
3785 * signals get fired to toggle the buttons on the toolbar as well. | |
3786 */ | |
10810 | 3787 default_formatize(gtkconv); |
4359 | 3788 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3789 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3790 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3791 |
8758 | 3792 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 3793 gtkconv->u.im->show_icon = TRUE; |
4359 | 3794 |
9080 | 3795 /* |
3796 * Focus for IM windows should be as follows: | |
10356 | 3797 * Tab title -> conversation scrollback -> entry |
9080 | 3798 */ |
9332 | 3799 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3800 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 3801 |
4359 | 3802 return paned; |
3803 } | |
3804 | |
3805 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3806 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 3807 GtkSelectionData *sd, guint info, guint t, |
3808 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3809 { |
10810 | 3810 GaimConversation *conv = gtkconv->active_conv; |
11581 | 3811 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3812 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3813 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3814 { |
4781 | 3815 GaimBlistNode *n = NULL; |
6695 | 3816 GaimBuddy *b; |
11581 | 3817 GaimGtkConversation *gtkconv = NULL; |
9622 | 3818 |
11812 | 3819 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3820 |
6695 | 3821 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
3822 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
3823 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
3824 b = (GaimBuddy*)n; | |
3825 else | |
4781 | 3826 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3827 |
9622 | 3828 /* |
3829 * If we already have an open conversation with this buddy, then | |
3830 * just move the conv to this window. Otherwise, create a new | |
3831 * conv and add it to this window. | |
3832 */ | |
11338 | 3833 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 3834 if (c != NULL) { |
11581 | 3835 GaimGtkWindow *oldwin; |
3836 gtkconv = GAIM_GTK_CONVERSATION(c); | |
3837 oldwin = gtkconv->win; | |
9622 | 3838 if (oldwin != win) { |
11581 | 3839 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
3840 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 3841 } |
3842 } else { | |
11338 | 3843 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 3844 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3845 if (gtkconv->win != win) |
3846 { | |
3847 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3848 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3849 } | |
9622 | 3850 } |
3851 | |
3852 /* Make this conversation the active conversation */ | |
11581 | 3853 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3854 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3855 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 3856 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3857 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
|
3858 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3859 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3860 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3861 GaimAccount *account; |
11581 | 3862 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3863 |
11137 | 3864 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 3865 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3866 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3867 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3868 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3869 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3870 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3871 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3872 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3873 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3874 { |
11338 | 3875 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 3876 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3877 if (gtkconv->win != win) |
3878 { | |
3879 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3880 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3881 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3882 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3883 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3884 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3885 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3886 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3887 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3888 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3889 } |
9525 | 3890 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 3891 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 3892 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 3893 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 3894 } |
10145 | 3895 else |
3896 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3897 } |
4359 | 3898 |
3899 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3900 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3901 { |
10145 | 3902 GTK_IMHTML_DND_TARGETS, |
3903 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
3904 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3905 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3906 |
10810 | 3907 static GaimGtkConversation * |
3908 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
3909 { | |
3910 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
3911 GaimContact *c; | |
3912 GaimBlistNode *cn; | |
10935 | 3913 |
10810 | 3914 if (!bud) |
3915 return NULL; | |
10935 | 3916 |
10810 | 3917 if (!(c = gaim_buddy_get_contact(bud))) |
3918 return NULL; | |
10935 | 3919 |
10810 | 3920 cn = (GaimBlistNode *)c; |
3921 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
3922 GaimConversation *conv; | |
11338 | 3923 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 3924 if (conv->ui_data) |
3925 return conv->ui_data; | |
3926 } | |
3927 } | |
10935 | 3928 |
10810 | 3929 return NULL; |
3930 } | |
3931 | |
11855 | 3932 static void |
3933 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
3934 { | |
3935 GList *list; | |
3936 | |
3937 g_return_if_fail(bnode); | |
3938 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
3939 | |
3940 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
3941 { | |
3942 GaimGtkWindow *win = list->data; | |
3943 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
3944 | |
3945 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
3946 continue; | |
3947 | |
3948 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); | |
3949 } | |
3950 } | |
3951 | |
11581 | 3952 /************************************************************************** |
3953 * Conversation UI operations | |
3954 **************************************************************************/ | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
3955 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
3956 private_gtkconv_new(GaimConversation *conv, gboolean hidden) |
11581 | 3957 { |
3958 GaimGtkConversation *gtkconv; | |
3959 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 3960 GtkWidget *pane = NULL; |
3961 GtkWidget *tab_cont; | |
11581 | 3962 |
3963 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 3964 conv->ui_data = gtkconv; |
3965 if (!g_list_find(gtkconv->convs, conv)) | |
3966 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 3967 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 3968 return; |
4359 | 3969 } |
3970 | |
11581 | 3971 gtkconv = g_new0(GaimGtkConversation, 1); |
3972 conv->ui_data = gtkconv; | |
3973 gtkconv->active_conv = conv; | |
3974 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
3975 | |
3976 /* Setup some initial variables. */ | |
3977 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
3978 gtkconv->tooltips = gtk_tooltips_new(); | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
3979 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
3980 gtkconv->unseen_count = 0; |
11581 | 3981 |
3982 if (conv_type == GAIM_CONV_TYPE_IM) { | |
3983 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
3984 | |
3985 pane = setup_im_pane(gtkconv); | |
3986 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
3987 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
3988 pane = setup_chat_pane(gtkconv); | |
3989 } | |
3990 | |
12101 | 3991 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
3992 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
3993 | |
11581 | 3994 if (pane == NULL) { |
3995 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
3996 g_free(gtkconv->u.chat); | |
3997 else if (conv_type == GAIM_CONV_TYPE_IM) | |
3998 g_free(gtkconv->u.im); | |
3999 | |
4000 g_free(gtkconv); | |
4001 conv->ui_data = NULL; | |
4002 return; | |
10449 | 4003 } |
11581 | 4004 |
4005 /* Setup drag-and-drop */ | |
4006 gtk_drag_dest_set(pane, | |
4007 GTK_DEST_DEFAULT_MOTION | | |
4008 GTK_DEST_DEFAULT_DROP, | |
4009 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4010 GDK_ACTION_COPY); | |
4011 gtk_drag_dest_set(pane, | |
4012 GTK_DEST_DEFAULT_MOTION | | |
4013 GTK_DEST_DEFAULT_DROP, | |
4014 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4015 GDK_ACTION_COPY); | |
4016 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4017 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4018 GDK_ACTION_COPY); | |
4019 | |
4020 gtk_drag_dest_set(gtkconv->entry, 0, | |
4021 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4022 GDK_ACTION_COPY); | |
4023 | |
4024 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
4025 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4026 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
4027 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4028 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
4029 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4030 | |
4031 /* Setup the container for the tab. */ | |
4032 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
4033 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
4034 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
4035 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
4036 gtk_widget_show(pane); | |
4037 | |
4038 gtkconv->make_sound = TRUE; | |
4039 | |
4040 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
4041 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4042 else |
11581 | 4043 gtk_widget_hide(gtkconv->toolbar); |
4044 | |
12188 | 4045 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), |
4046 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4047 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4048 gaim_account_get_protocol_name(conv->account)); |
11581 | 4049 |
4050 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
4051 G_CALLBACK(gtk_widget_grab_focus), | |
4052 gtkconv->entry); | |
4053 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4054 if (hidden) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4055 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4056 else |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4057 gaim_gtkconv_placement_place(gtkconv); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4058 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4059 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4060 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4061 gaim_gtkconv_new_hidden(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4062 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4063 private_gtkconv_new(conv, TRUE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4064 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4065 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4066 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4067 gaim_gtkconv_new(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4068 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4069 private_gtkconv_new(conv, FALSE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4070 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4071 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4072 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4073 received_im_msg_cb(GaimAccount *account, char *sender, char *message, |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4074 GaimConversation *conv, int flags) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4075 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4076 GaimConversationUiOps *ui_ops = gaim_gtk_conversations_get_conv_ui_ops(); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4077 if(conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4078 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4079 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4080 /* create hidden conv if hide_new pref is always */ |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4081 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "always")==0) { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4082 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4083 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4084 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4085 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4086 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4087 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4088 /* create hidden conv if hide_new pref is away and account is away */ |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4089 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away")==0 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4090 && gaim_status_type_get_primitive( |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4091 gaim_status_get_type( |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4092 gaim_account_get_active_status(account))) == GAIM_STATUS_AWAY) { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4093 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4094 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4095 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4096 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4097 } |
11581 | 4098 } |
4099 | |
4359 | 4100 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4101 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4102 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4103 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4104 |
10810 | 4105 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4106 /* Don't destroy ourselves until all our convos are gone */ | |
4107 if (gtkconv->convs) | |
4108 return; | |
11508 | 4109 |
11581 | 4110 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4111 | |
9504 | 4112 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4113 gaim_request_close_with_handle(conv); | |
4359 | 4114 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4115 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4116 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4117 |
11338 | 4118 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4119 if (gtkconv->u.im->icon_timer != 0) |
4120 g_source_remove(gtkconv->u.im->icon_timer); | |
4121 | |
4359 | 4122 if (gtkconv->u.im->anim != NULL) |
4793 | 4123 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4124 |
4125 g_free(gtkconv->u.im); | |
11581 | 4126 } 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
|
4127 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4128 g_free(gtkconv->u.chat); |
4129 } | |
4130 | |
4633 | 4131 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4132 | |
4359 | 4133 g_free(gtkconv); |
4134 } | |
4135 | |
4136 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4137 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4138 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4139 time_t mtime) |
4359 | 4140 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4141 GaimGtkConversation *gtkconv; |
4359 | 4142 |
4143 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4144 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4145 |
6982 | 4146 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4147 } |
4148 | |
4149 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4150 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4151 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4152 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4153 GaimGtkConversation *gtkconv; |
4359 | 4154 |
4155 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4156 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4157 |
10398 | 4158 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4159 |
6982 | 4160 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4161 } |
4162 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4163 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4164 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4165 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4166 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4167 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4168 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4169 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4170 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4171 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4172 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4173 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4174 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4175 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4176 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4177 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4178 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4179 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4180 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4181 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4182 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4183 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4184 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4185 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4186 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4187 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4188 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4189 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4190 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4191 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4192 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4193 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4194 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4195 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4196 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4197 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4198 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4199 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4200 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4201 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4202 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4203 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4204 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4205 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4206 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4207 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4208 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4209 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4210 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4211 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4212 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4213 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4214 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4215 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4216 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4217 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4218 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4219 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4220 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4221 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4222 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4223 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4224 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4225 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4226 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4227 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4228 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4229 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4230 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4231 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4232 buddytag = gtk_text_buffer_create_tag( |
11096 | 4233 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4234 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4235 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4236 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4237 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4238 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4239 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4240 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4241 |
4359 | 4242 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4243 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4244 const char *message, GaimMessageFlags flags, |
4359 | 4245 time_t mtime) |
4246 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4247 GaimGtkConversation *gtkconv; |
11581 | 4248 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4249 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4250 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4251 GaimPluginProtocolInfo *prpl_info; |
4359 | 4252 int gtk_font_options = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4253 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4254 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4255 int line_count; |
4359 | 4256 char buf2[BUF_LONG]; |
4257 char mdate[64]; | |
4258 char color[10]; | |
4259 char *str; | |
4260 char *with_font_tag; | |
4896 | 4261 char *sml_attrib = NULL; |
6982 | 4262 size_t length = strlen(message) + 1; |
4895 | 4263 |
4359 | 4264 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4265 |
4266 /* Set the active conversation to the one that just messaged us. */ | |
4267 /* 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
|
4268 gaim_gtkconv_set_active_conversation(conv); |
11581 | 4269 |
4359 | 4270 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4271 account = gaim_conversation_get_account(conv); |
11581 | 4272 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4273 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4274 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4275 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4276 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4277 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4278 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4279 /* 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
|
4280 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4281 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4282 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4283 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4284 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4285 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4286 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4287 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4288 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4289 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4290 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4291 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4292 |
8677 | 4293 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
4294 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
4295 | |
5133 | 4296 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4297 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4298 else | |
4299 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4300 |
4896 | 4301 if(gc) |
9699 | 4302 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4303 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4304 |
10503 | 4305 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4306 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4307 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4308 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4309 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4310 |
7956 | 4311 /* this is gonna crash one day, I can feel it. */ |
4312 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4313 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4314 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4315 } |
4359 | 4316 |
10737 | 4317 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4318 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4319 g_snprintf(buf2, sizeof(buf2), |
8690 | 4320 "<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
|
4321 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4322 |
8962 | 4323 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 4324 |
8722 | 4325 } else if (flags & GAIM_MESSAGE_ERROR) { |
4326 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4327 "<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
|
4328 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4329 |
8962 | 4330 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
4331 | |
7431 | 4332 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4333 g_snprintf(buf2, BUF_LONG, |
8690 | 4334 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4335 sml_attrib ? sml_attrib : "", message); |
7440 | 4336 |
10884 | 4337 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
10346 | 4338 } else if (flags & GAIM_MESSAGE_RAW) { |
10348 | 4339 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); |
10346 | 4340 } else { |
4895 | 4341 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4342 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
|
4343 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4344 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4345 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
|
4346 int tag_end_offset = 0; |
7440 | 4347 |
6621 | 4348 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4349 str = g_malloc(1024); |
7440 | 4350 |
4359 | 4351 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4352 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4353 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4354 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4355 tag_start_offset += 3; |
4359 | 4356 } |
4357 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4358 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4359 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4360 tag_end_offset = 2; |
4359 | 4361 strcpy(color, "#00FF00"); |
4362 } | |
7440 | 4363 } |
4359 | 4364 else { |
10504 | 4365 if (gaim_message_meify(new_message, -1)) { |
4359 | 4366 str = g_malloc(1024); |
7440 | 4367 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4368 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4369 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
|
4370 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4371 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4372 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4373 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4374 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4375 } |
7440 | 4376 |
6621 | 4377 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4378 strcpy(color, "#AF7F00"); |
4379 else | |
4380 strcpy(color, "#062585"); | |
4381 } | |
4382 else { | |
4383 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4384 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4385 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
|
4386 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4387 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4388 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4389 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4390 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4391 } |
6621 | 4392 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4393 strcpy(color, "#AF7F00"); |
6621 | 4394 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4395 if (flags & GAIM_MESSAGE_COLORIZE) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4396 GdkColor *col = get_nick_color(gtkconv, alias); |
10346 | 4397 |
10108 | 4398 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4399 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4400 } else |
7854 | 4401 strcpy(color, RECV_COLOR); |
4359 | 4402 } |
6621 | 4403 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4404 strcpy(color, SEND_COLOR); |
10892 | 4405 else { |
4406 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4407 strcpy(color, "#000000"); | |
4408 } | |
4359 | 4409 } |
4410 } | |
10892 | 4411 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4412 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4413 g_free(alias_escaped); |
11508 | 4414 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4415 /* 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
|
4416 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4417 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4418 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4419 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4420 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4421 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4422 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4423 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4424 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4425 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4426 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4427 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4428 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4429 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4430 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4431 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4432 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4433 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4434 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4435 /* 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
|
4436 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4437 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4438 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4439 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4440 } |
7440 | 4441 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4442 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4443 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4444 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4445 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4446 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4447 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4448 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4449 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4450 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4451 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4452 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4453 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4454 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4455 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4456 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4457 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4458 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4459 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4460 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4461 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4462 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4463 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4464 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4465 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4466 |
4359 | 4467 g_free(str); |
4468 | |
4895 | 4469 if(gc){ |
4896 | 4470 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4471 char *post = "</font>"; |
4472 int pre_len = strlen(pre); | |
4473 int post_len = strlen(post); | |
7440 | 4474 |
4895 | 4475 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4476 |
4895 | 4477 strcpy(with_font_tag, pre); |
4478 memcpy(with_font_tag + pre_len, new_message, length); | |
4479 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4480 |
4895 | 4481 length += pre_len + post_len; |
4482 g_free(pre); | |
4483 } | |
4608 | 4484 else |
4895 | 4485 with_font_tag = g_memdup(new_message, length); |
7440 | 4486 |
8962 | 4487 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
4488 with_font_tag, gtk_font_options); | |
7440 | 4489 |
4490 g_free(with_font_tag); | |
7447 | 4491 g_free(new_message); |
7440 | 4492 } |
4493 | |
5012 | 4494 if(sml_attrib) |
4495 g_free(sml_attrib); | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4496 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4497 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4498 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4499 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4500 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4501 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4502 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4503 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4504 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4505 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4506 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4507 else if ((flags & GAIM_MESSAGE_NO_LOG) == GAIM_MESSAGE_NO_LOG) |
12132
95bffda9b762
[gaim-migrate @ 14432]
Richard Laager <rlaager@wiktel.com>
parents:
12131
diff
changeset
|
4508 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4509 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4510 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4511 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4512 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4513 } |
4359 | 4514 } |
4515 | |
4516 static void | |
11869 | 4517 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
|
4518 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4519 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4520 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4521 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4522 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4523 GList *ll; |
11869 | 4524 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4525 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4526 int num_users; |
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 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4529 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4530 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4531 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4532 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
|
4533 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4534 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4535 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4536 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4537 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4538 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4539 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4540 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4541 l = users; |
11869 | 4542 ll = flags; |
4543 lll = aliases; | |
4544 while (l != NULL && ll != NULL && lll != NULL) { | |
4545 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
|
4546 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4547 ll = ll->next; |
11869 | 4548 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4549 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4550 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4551 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4552 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4553 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
|
4554 const char *new_name, const char *new_alias) |
4359 | 4555 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4556 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4557 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4558 GaimGtkChatPane *gtkchat; |
11869 | 4559 GaimConvChatBuddyFlags flags; |
4359 | 4560 GtkTreeIter iter; |
4561 GtkTreeModel *model; | |
4562 int f = 1; | |
4563 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4564 chat = GAIM_CONV_CHAT(conv); |
4359 | 4565 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4566 gtkchat = gtkconv->u.chat; | |
4567 | |
9554 | 4568 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4569 | |
4570 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4571 return; | |
4572 | |
4573 while (f != 0) { | |
4574 char *val; | |
4575 | |
11869 | 4576 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4577 |
4578 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4579 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4580 g_free(val); | |
4359 | 4581 break; |
4582 } | |
9554 | 4583 |
4584 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4585 | |
4586 g_free(val); | |
4359 | 4587 } |
4588 | |
9554 | 4589 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4590 return; |
4591 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4592 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4593 |
11869 | 4594 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4595 } |
4596 | |
4597 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4598 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 4599 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4600 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4601 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4602 GaimGtkChatPane *gtkchat; |
4359 | 4603 GtkTreeIter iter; |
4604 GtkTreeModel *model; | |
4605 char tmp[BUF_LONG]; | |
4606 int num_users; | |
4607 int f = 1; | |
4608 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4609 chat = GAIM_CONV_CHAT(conv); |
4359 | 4610 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4611 gtkchat = gtkconv->u.chat; | |
4612 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4613 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
|
4614 |
9554 | 4615 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4616 | |
4617 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4618 return; | |
4619 | |
4620 while (f != 0) { | |
4621 char *val; | |
4622 | |
4623 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4624 | |
4625 if (!gaim_utf8_strcasecmp(user, val)) { | |
4626 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4627 g_free(val); | |
4359 | 4628 break; |
4629 } | |
9554 | 4630 |
4631 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4632 | |
4633 g_free(val); | |
4359 | 4634 } |
4635 | |
9554 | 4636 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 4637 return; |
4638 | |
4639 g_snprintf(tmp, sizeof(tmp), | |
9554 | 4640 ngettext("%d person in room", "%d people in room", |
4641 num_users), num_users); | |
4359 | 4642 |
4643 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4644 | |
4645 } | |
4646 | |
4647 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4648 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4649 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4650 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4651 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4652 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4653 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4654 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4655 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4656 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4657 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4658 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4659 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4660 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4661 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4662 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4663 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4664 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
|
4665 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4666 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4667 for (l = users; l != NULL; l = l->next) { |
9554 | 4668 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4669 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4670 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4671 continue; |
4672 | |
4673 do { | |
4674 char *val; | |
4675 | |
4676 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4677 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4678 | |
9696 | 4679 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4680 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4681 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4682 #else |
4683 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4684 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4685 #endif | |
4686 } | |
9554 | 4687 else |
4688 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4689 | |
4690 g_free(val); | |
4691 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4692 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4693 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4694 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4695 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4696 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4697 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4698 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4699 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4700 |
9554 | 4701 static void |
4702 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4703 { | |
4704 GaimConvChat *chat; | |
11869 | 4705 GaimConvChatBuddyFlags flags; |
9554 | 4706 GaimGtkConversation *gtkconv; |
4707 GaimGtkChatPane *gtkchat; | |
4708 GtkTreeIter iter; | |
4709 GtkTreeModel *model; | |
4710 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4711 char *alias = NULL; |
9554 | 4712 |
4713 chat = GAIM_CONV_CHAT(conv); | |
4714 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4715 gtkchat = gtkconv->u.chat; | |
4716 | |
4717 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4718 | |
4719 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4720 return; | |
4721 | |
4722 while (f != 0) { | |
4723 char *val; | |
4724 | |
4725 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4726 | |
4727 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4728 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4729 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4730 g_free(val); | |
4731 break; | |
4732 } | |
4733 | |
4734 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4735 | |
4736 g_free(val); | |
4737 } | |
4738 | |
4739 if (!gaim_conv_chat_find_user(chat, user)) | |
4740 return; | |
4741 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4742 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4743 |
11869 | 4744 flags = gaim_conv_chat_user_get_flags(chat, user); |
4745 | |
4746 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4747 g_free(alias); |
9554 | 4748 } |
4749 | |
11581 | 4750 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4751 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4752 { |
11581 | 4753 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4754 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4755 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4756 |
11581 | 4757 win = gtkconv->win; |
4758 | |
4759 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
|
4760 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4761 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4762 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4763 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4764 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4765 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4766 |
10526 | 4767 static gboolean |
4768 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
4769 { | |
4770 GaimGtkConversation *gtkconv; | |
4771 GtkIMHtmlSmiley *smiley; | |
4772 GdkPixbufLoader *loader; | |
11525 | 4773 struct smiley_list *list; |
4774 const char *sml = NULL, *conv_sml; | |
4775 | |
4776 if (!conv || !smile || !*smile) { | |
10526 | 4777 return FALSE; |
4778 } | |
4779 | |
11525 | 4780 /* If smileys are off, return false */ |
4781 if (gaim_gtkthemes_smileys_disabled()) | |
4782 return FALSE; | |
4783 | |
4784 /* If possible add this smiley to the current theme. | |
4785 * The addition is only temporary: custom smilies aren't saved to disk. */ | |
4786 conv_sml = gaim_account_get_protocol_name(conv->account); | |
10526 | 4787 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11525 | 4788 |
4789 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | |
4790 if (!strcmp(list->sml, conv_sml)) { | |
4791 sml = list->sml; | |
4792 break; | |
4793 } | |
4794 } | |
4795 | |
10526 | 4796 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
4797 | |
4798 if (smiley) { | |
11525 | 4799 |
4800 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
4801 return FALSE; | |
4802 } | |
4803 | |
4804 /* Close the old GdkPixbufAnimation, then create a new one for | |
4805 * the smiley we are about to receive */ | |
4806 g_object_unref(G_OBJECT(smiley->icon)); | |
4807 | |
4808 smiley->loader = gdk_pixbuf_loader_new(); | |
4809 smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); | |
4810 if (smiley->icon) | |
4811 g_object_ref(G_OBJECT(smiley->icon)); | |
4812 | |
4813 /* A custom smiley is already associated */ | |
4814 return TRUE; | |
10526 | 4815 } |
4816 | |
4817 loader = gdk_pixbuf_loader_new(); | |
4818 | |
4819 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
4820 /* 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
|
4821 GtkIMHtmlSmiley by opaque */ |
10526 | 4822 smiley = g_new0(GtkIMHtmlSmiley, 1); |
4823 smiley->file = NULL; | |
4824 smiley->smile = g_strdup(smile); | |
4825 smiley->loader = loader; | |
11525 | 4826 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 4827 |
4828 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
4829 if (smiley->icon) | |
4830 g_object_ref(G_OBJECT(smiley->icon)); | |
4831 | |
11525 | 4832 |
10526 | 4833 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); |
10537 | 4834 |
10526 | 4835 return TRUE; |
4836 } | |
4837 | |
10537 | 4838 static void |
10526 | 4839 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 4840 const guchar *data, gsize size) |
10526 | 4841 { |
4842 GaimGtkConversation *gtkconv; | |
4843 GtkIMHtmlSmiley *smiley; | |
10537 | 4844 GdkPixbufLoader *loader; |
10526 | 4845 const char *sml; |
4846 | |
4847 sml = gaim_account_get_protocol_name(conv->account); | |
4848 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4849 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4850 | |
10537 | 4851 if (!smiley) |
10526 | 4852 return; |
10537 | 4853 |
10526 | 4854 loader = smiley->loader; |
10537 | 4855 if (!loader) |
10526 | 4856 return; |
4857 | |
4858 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
4859 } | |
4860 | |
4861 static void | |
4862 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
4863 { | |
4864 GaimGtkConversation *gtkconv; | |
4865 GtkIMHtmlSmiley *smiley; | |
4866 GdkPixbufLoader *loader; | |
4867 const char *sml; | |
11525 | 4868 GtkWidget *icon = NULL; |
4869 GtkTextChildAnchor *anchor = NULL; | |
4870 GtkTextIter end; | |
4871 GtkIMHtml *imhtml; | |
4872 GSList *current = NULL; | |
10526 | 4873 |
4874 g_return_if_fail(conv != NULL); | |
4875 g_return_if_fail(smile != NULL); | |
4876 | |
4877 sml = gaim_account_get_protocol_name(conv->account); | |
4878 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4879 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4880 | |
10537 | 4881 if (!smiley) |
10526 | 4882 return; |
4883 | |
4884 loader = smiley->loader; | |
4885 | |
10537 | 4886 if (!loader) |
10526 | 4887 return; |
10537 | 4888 |
11525 | 4889 smiley->icon = gdk_pixbuf_loader_get_animation(loader); |
4890 if (smiley->icon) | |
4891 g_object_ref(G_OBJECT(smiley->icon)); | |
4892 | |
4893 for (current = smiley->anchors; current != NULL; current = g_slist_next(current)) { | |
4894 | |
4895 icon = gtk_image_new_from_animation(smiley->icon); | |
4896 | |
4897 if (icon) { | |
12047 | 4898 gtk_widget_show(icon); |
4899 | |
11525 | 4900 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
4901 | |
4902 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smile)), g_free); | |
4903 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smile), g_free); | |
4904 | |
4905 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(gtkconv->imhtml), icon, anchor); | |
4906 } | |
4907 | |
4908 } | |
4909 | |
4910 g_slist_free(smiley->anchors); | |
4911 smiley->anchors = NULL; | |
4912 | |
4913 /* Scroll to the end of the widget in case the smiley height was big... */ | |
4914 /* FIXME: need to test this actually works, previous dealings with scrolling | |
4915 * makes me question it */ | |
4916 imhtml = GTK_IMHTML(gtkconv->imhtml); | |
4917 gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(imhtml->text_buffer), &end); | |
4918 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &end, 0, TRUE, 0, 0); | |
4919 | |
10526 | 4920 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
4921 | |
4922 gdk_pixbuf_loader_close(loader, NULL); | |
4923 g_object_unref(G_OBJECT(loader)); | |
4924 smiley->loader = NULL; | |
4925 } | |
4926 | |
11581 | 4927 /* |
4928 * Makes sure all the menu items and all the buttons are hidden/shown and | |
4929 * sensitive/insensitive. This is called after changing tabs and when an | |
4930 * account signs on or off. | |
4931 */ | |
4932 static void | |
4933 gray_stuff_out(GaimGtkConversation *gtkconv) | |
4934 { | |
4935 GaimGtkWindow *win; | |
4936 GaimConversation *conv = gtkconv->active_conv; | |
4937 GaimConnection *gc; | |
4938 GaimPluginProtocolInfo *prpl_info = NULL; | |
4939 GdkPixbuf *window_icon = NULL; | |
4940 GtkIMHtmlButtons buttons; | |
4941 GaimAccount *account; | |
4942 | |
4943 win = gaim_gtkconv_get_window(gtkconv); | |
4944 gc = gaim_conversation_get_gc(conv); | |
4945 account = gaim_conversation_get_account(conv); | |
4946 | |
4947 if (gc != NULL) | |
4948 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
4949 | |
11594 | 4950 if (win->menu.send_to != NULL) |
11734 | 4951 update_send_to_selection(win); |
11581 | 4952 |
4953 /* | |
4954 * Handle hiding and showing stuff based on what type of conv this is. | |
4955 * Stuff that Gaim IMs support in general should be shown for IM | |
4956 * conversations. Stuff that Gaim chats support in general should be | |
4957 * shown for chat conversations. It doesn't matter whether the PRPL | |
4958 * supports it or not--that only affects if the button or menu item | |
4959 * is sensitive or not. | |
4960 */ | |
4961 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
4962 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
4963 | |
4964 /* Deal with menu items */ | |
4965 gtk_widget_show(win->menu.view_log); | |
4966 gtk_widget_show(win->menu.send_file); | |
4967 gtk_widget_show(win->menu.add_pounce); | |
4968 gtk_widget_show(win->menu.get_info); | |
4969 gtk_widget_hide(win->menu.invite); | |
4970 gtk_widget_show(win->menu.alias); | |
4971 gtk_widget_show(win->menu.block); | |
4972 | |
4973 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
4974 gtk_widget_show(win->menu.add); | |
4975 gtk_widget_hide(win->menu.remove); | |
4976 } else { | |
4977 gtk_widget_show(win->menu.remove); | |
4978 gtk_widget_hide(win->menu.add); | |
4979 } | |
4980 | |
4981 gtk_widget_show(win->menu.insert_link); | |
4982 gtk_widget_show(win->menu.insert_image); | |
4983 gtk_widget_show(win->menu.show_icon); | |
4984 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
4985 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
4986 | |
4987 /* Deal with menu items */ | |
4988 gtk_widget_show(win->menu.view_log); | |
4989 gtk_widget_hide(win->menu.send_file); | |
4990 gtk_widget_hide(win->menu.add_pounce); | |
4991 gtk_widget_hide(win->menu.get_info); | |
4992 gtk_widget_show(win->menu.invite); | |
4993 gtk_widget_show(win->menu.alias); | |
4994 gtk_widget_hide(win->menu.block); | |
4995 gtk_widget_hide(win->menu.show_icon); | |
4996 | |
4997 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
4998 /* If the chat is NOT in the buddy list */ | |
4999 gtk_widget_show(win->menu.add); | |
5000 gtk_widget_hide(win->menu.remove); | |
5001 } else { | |
5002 /* If the chat IS in the buddy list */ | |
5003 gtk_widget_hide(win->menu.add); | |
5004 gtk_widget_show(win->menu.remove); | |
5005 } | |
5006 | |
5007 gtk_widget_show(win->menu.insert_link); | |
5008 gtk_widget_hide(win->menu.insert_image); | |
5009 } | |
5010 | |
5011 /* | |
5012 * Handle graying stuff out based on whether an account is connected | |
5013 * and what features that account supports. | |
5014 */ | |
5015 if ((gc != NULL) && | |
12012 | 5016 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
5017 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
5018 { | |
11581 | 5019 /* Account is online */ |
5020 /* Deal with the toolbar */ | |
12012 | 5021 if (conv->features & GAIM_CONNECTION_HTML) |
5022 { | |
5023 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
5024 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
5025 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
5026 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
5027 { | |
5028 buttons &= ~GTK_IMHTML_GROW; | |
5029 buttons &= ~GTK_IMHTML_SHRINK; | |
5030 } | |
5031 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
5032 buttons &= ~GTK_IMHTML_LINKDESC; | |
5033 } else { | |
12216 | 5034 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
12012 | 5035 } |
12216 | 5036 |
5037 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
5038 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
5039 buttons &= ~GTK_IMHTML_IMAGE; | |
5040 | |
12012 | 5041 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); |
5042 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 5043 |
5044 /* Deal with menu items */ | |
12012 | 5045 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5046 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5047 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
5048 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
5049 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
5050 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 5051 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 5052 |
5053 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
5054 { | |
5055 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
5056 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
5057 gtk_widget_set_sensitive(win->menu.send_file, | |
5058 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
5059 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
5060 gtk_widget_set_sensitive(win->menu.alias, | |
5061 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
5062 } | |
5063 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5064 { | |
5065 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
5066 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
5067 gtk_widget_set_sensitive(win->menu.alias, | |
5068 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
5069 } | |
11581 | 5070 |
5071 /* Deal with chat userlist buttons */ | |
12012 | 5072 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5073 { | |
5074 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
5075 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
5076 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
5077 } | |
5078 } else { | |
11581 | 5079 /* Account is offline */ |
5080 /* Or it's a chat that we've left. */ | |
5081 | |
5082 /* Then deal with menu items */ | |
12012 | 5083 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5084 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
5085 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5086 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
5087 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
5088 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
5089 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
5090 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
5091 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
5092 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
5093 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 5094 |
5095 /* Deal with chat userlist buttons */ | |
12012 | 5096 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5097 { | |
5098 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5099 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5100 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5101 } | |
5102 } | |
11581 | 5103 |
5104 /* | |
5105 * Update the window's icon | |
5106 */ | |
12171 | 5107 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5108 { |
12171 | 5109 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
5110 (gtkconv->u.im->anim)) | |
5111 { | |
5112 window_icon = | |
5113 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5114 g_object_ref(window_icon); | |
5115 } else { | |
5116 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5117 } | |
5118 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5119 if (window_icon != NULL) | |
5120 g_object_unref(G_OBJECT(window_icon)); | |
5121 } | |
11581 | 5122 } |
5123 | |
10526 | 5124 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5125 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5126 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 5127 { |
11581 | 5128 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5129 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5130 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5131 GaimConvChat *chat; |
4359 | 5132 |
10116 | 5133 g_return_if_fail(conv != NULL); |
5134 | |
4359 | 5135 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5136 win = gtkconv->win; |
10810 | 5137 conv = gtkconv->active_conv; /* Gross hack */ |
11581 | 5138 /* Maybe we should just ignore it if conv != gtkconv->active_conv, |
5139 * instead of the gross hack? | |
5140 */ | |
4359 | 5141 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5142 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5143 { |
4359 | 5144 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5145 |
11338 | 5146 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5147 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5148 |
4359 | 5149 gaim_gtkconv_update_buttons_by_protocol(conv); |
5150 | |
11734 | 5151 update_send_to_selection(win); |
4359 | 5152 |
11525 | 5153 gaim_gtkthemes_smiley_themeize(gtkconv->imhtml); |
6394 | 5154 |
6395 | 5155 update_tab_icon(conv); |
4359 | 5156 } |
5157 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5158 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5159 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5160 { |
9472 | 5161 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5162 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5163 GaimAccount *account = gaim_conversation_get_account(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5164 /* 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
|
5165 char style[51]; |
4736 | 5166 |
11338 | 5167 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5168 im = GAIM_CONV_IM(conv); |
4359 | 5169 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5170 if (!gaim_account_is_connected(account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5171 || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5172 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5173 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5174 else | |
5175 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5176 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5177 *style = '\0'; |
4359 | 5178 |
5179 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5180 gtk_widget_realize(gtkconv->tab_label); | |
5181 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5182 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5183 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5184 { |
11759 | 5185 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5186 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5187 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5188 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5189 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5190 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5191 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5192 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5193 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5194 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5195 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5196 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5197 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5198 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5199 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5200 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5201 { |
11758 | 5202 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5203 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5204 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5205 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5206 { |
8536 | 5207 char *html_title,*label; |
5208 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5209 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5210 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5211 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5212 style, html_title); |
8536 | 5213 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5214 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5215 g_free(label); |
4359 | 5216 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5217 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5218 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5219 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5220 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5221 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5222 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5223 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5224 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5225 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5226 gtk_window_set_title(GTK_WINDOW(win->window), title); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5227 } |
9472 | 5228 |
5229 g_free(title); | |
4359 | 5230 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5231 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5232 { |
7154 | 5233 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5234 chat = GAIM_CONV_CHAT(conv); |
4359 | 5235 gtkchat = gtkconv->u.chat; |
5236 | |
7154 | 5237 topic = gaim_conv_chat_get_topic(chat); |
5238 | |
9554 | 5239 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5240 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5241 topic ? topic : "", NULL); |
4359 | 5242 } |
5243 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5244 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5245 { |
11581 | 5246 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); |
11594 | 5247 generate_send_to_items(win); |
8946 | 5248 update_tab_icon(conv); |
9472 | 5249 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5250 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5251 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5252 { |
8946 | 5253 update_tab_icon(conv); |
4359 | 5254 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5255 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
|
5256 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5257 { |
9472 | 5258 gaim_conversation_autoset_title(conv); |
10810 | 5259 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5260 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5261 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5262 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5263 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5264 } |
10665 | 5265 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5266 { | |
10810 | 5267 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5268 } |
4359 | 5269 } |
5270 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5271 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5272 { |
11581 | 5273 gaim_gtkconv_new, |
4359 | 5274 gaim_gtkconv_destroy, /* destroy_conversation */ |
5275 gaim_gtkconv_write_chat, /* write_chat */ | |
5276 gaim_gtkconv_write_im, /* write_im */ | |
5277 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5278 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5279 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5280 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5281 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5282 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5283 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5284 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5285 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5286 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5287 gaim_gtkconv_updated /* updated */ |
5288 }; | |
5289 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5290 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5291 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5292 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5293 return &conversation_ui_ops; |
4359 | 5294 } |
5295 | |
5296 /************************************************************************** | |
5297 * Public conversation utility functions | |
5298 **************************************************************************/ | |
5299 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5300 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5301 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5302 GaimGtkConversation *gtkconv; |
11581 | 5303 GaimGtkWindow *win; |
4359 | 5304 |
10381 | 5305 GdkPixbufLoader *loader; |
5306 GdkPixbufAnimation *anim; | |
4359 | 5307 GError *err = NULL; |
5308 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5309 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5310 size_t len; |
4359 | 5311 |
5312 GdkPixbuf *buf; | |
5313 | |
5314 GtkWidget *event; | |
5315 GtkWidget *frame; | |
5316 GdkPixbuf *scale; | |
5317 GdkPixmap *pm; | |
5318 GdkBitmap *bm; | |
9318 | 5319 int scale_width, scale_height; |
5320 | |
5321 GaimAccount *account; | |
5322 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5323 |
9324 | 5324 GaimBuddyIcon *icon; |
5325 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5326 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5327 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5328 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5329 |
5330 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5331 win = gtkconv->win; |
10175 | 5332 |
9687 | 5333 if (!gtkconv->u.im->show_icon) |
5334 return; | |
5335 | |
9318 | 5336 account = gaim_conversation_get_account(conv); |
5337 if(account && account->gc) | |
5338 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5339 |
9845 | 5340 /* Remove the current icon stuff */ |
9885 | 5341 if (gtkconv->u.im->icon_container != NULL) |
5342 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5343 gtkconv->u.im->icon_container = NULL; | |
9845 | 5344 |
5345 if (gtkconv->u.im->anim != NULL) | |
5346 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5347 | |
9887 | 5348 gtkconv->u.im->anim = NULL; |
5349 | |
9845 | 5350 if (gtkconv->u.im->icon_timer != 0) |
5351 g_source_remove(gtkconv->u.im->icon_timer); | |
5352 | |
5353 gtkconv->u.im->icon_timer = 0; | |
5354 | |
5355 if (gtkconv->u.im->iter != NULL) | |
5356 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5357 |
10116 | 5358 gtkconv->u.im->iter = NULL; |
5359 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5360 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5361 return; |
5362 | |
5363 if (gaim_conversation_get_gc(conv) == NULL) | |
5364 return; | |
5365 | |
9324 | 5366 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5367 | |
5368 if (icon == NULL) | |
5369 return; | |
5370 | |
5371 data = gaim_buddy_icon_get_data(icon, &len); | |
5372 | |
10381 | 5373 loader = gdk_pixbuf_loader_new(); |
5374 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5375 anim = gdk_pixbuf_loader_get_animation(loader); | |
5376 if (anim) | |
5377 g_object_ref(G_OBJECT(anim)); | |
5378 gdk_pixbuf_loader_close(loader, &err); | |
5379 g_object_unref(loader); | |
5380 | |
5381 if (!anim) | |
9324 | 5382 return; |
10381 | 5383 gtkconv->u.im->anim = anim; |
9324 | 5384 |
4359 | 5385 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5386 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5387 "Buddy icon error: %s\n", err->message); |
4359 | 5388 g_error_free(err); |
5389 } | |
5390 | |
5391 if (!gtkconv->u.im->anim) | |
5392 return; | |
5393 | |
5394 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5395 gtkconv->u.im->iter = NULL; | |
5396 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5397 } else { | |
5398 gtkconv->u.im->iter = | |
8496 | 5399 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5400 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5401 if (gtkconv->u.im->animate) |
10810 | 5402 start_anim(NULL, gtkconv); |
4359 | 5403 } |
5404 | |
10483 | 5405 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5406 NULL, &scale_width, &scale_height); |
4359 | 5407 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5408 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5409 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5410 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5411 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5412 GDK_INTERP_BILINEAR); |
4359 | 5413 |
5414 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5415 g_object_unref(G_OBJECT(scale)); |
4359 | 5416 |
8821 | 5417 |
9885 | 5418 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5419 |
4359 | 5420 frame = gtk_frame_new(NULL); |
5421 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5422 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5423 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5424 FALSE, FALSE, 0); | |
8821 | 5425 |
4359 | 5426 event = gtk_event_box_new(); |
5427 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5428 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5429 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5430 gtk_widget_show(event); |
5431 | |
4635 | 5432 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5433 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5434 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5435 gtk_widget_show(gtkconv->u.im->icon); | |
5436 | |
4793 | 5437 g_object_unref(G_OBJECT(pm)); |
4359 | 5438 |
5439 if (bm) | |
4793 | 5440 g_object_unref(G_OBJECT(bm)); |
7143 | 5441 |
10356 | 5442 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5443 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5444 |
9885 | 5445 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5446 gtk_widget_show(frame); |
5447 | |
7143 | 5448 /* The buddy icon code needs badly to be fixed. */ |
5449 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5450 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5451 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
4359 | 5452 } |
5453 | |
5454 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5455 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5456 { |
11581 | 5457 GaimGtkWindow *win; |
4359 | 5458 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5459 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5460 return; |
5461 | |
11581 | 5462 win = GAIM_GTK_CONVERSATION(conv)->win; |
5463 | |
5464 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5465 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5466 } |
5467 | |
5468 int | |
11614 | 5469 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5470 { |
4359 | 5471 gint nb_x, nb_y, x_rel, y_rel; |
5472 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5473 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5474 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5475 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5476 gboolean horiz; |
4359 | 5477 |
11614 | 5478 if (to_right) |
5479 *to_right = FALSE; | |
5480 | |
11581 | 5481 notebook = GTK_NOTEBOOK(win->notebook); |
5482 | |
5483 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5484 x_rel = x - nb_x; |
5485 y_rel = y - nb_y; | |
5486 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5487 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5488 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5489 |
11780 | 5490 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5491 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5492 #else |
5493 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5494 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5495 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5496 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5497 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5498 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5499 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5500 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5501 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5502 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5503 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5504 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
|
5505 page_num = i; |
11614 | 5506 |
5507 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5508 *to_right = TRUE; | |
5509 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5510 break; |
4359 | 5511 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5512 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5513 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5514 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
|
5515 page_num = i; |
11614 | 5516 |
5517 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5518 *to_right = TRUE; | |
5519 | |
4359 | 5520 break; |
5521 } | |
5522 } | |
5523 } | |
5524 | |
5525 return page_num; | |
5526 } | |
5527 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5528 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5529 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
|
5530 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5531 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5532 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5533 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5534 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5535 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5536 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5537 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5538 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5539 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5540 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5541 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5542 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5543 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5544 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5545 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5546 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5547 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5548 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5549 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5550 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5551 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5552 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5553 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5554 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5555 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5556 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5557 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5558 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5559 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5560 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5561 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5562 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5563 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5564 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5565 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5566 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5567 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5568 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5569 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5570 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5571 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5572 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5573 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5574 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5575 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5576 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5577 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5578 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5579 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5580 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5581 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5582 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5583 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5584 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5585 GtkPositionType pos; |
11581 | 5586 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5587 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5588 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5589 |
11581 | 5590 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5591 win = l->data; | |
5592 | |
11619 | 5593 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
|
5594 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5595 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5596 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5597 static void |
12188 | 5598 show_timestamps_pref_cb(const char *name, GaimPrefType type, |
5599 gpointer value, gpointer data) | |
5600 { | |
5601 GList *l; | |
5602 GaimConversation *conv; | |
5603 GaimGtkConversation *gtkconv; | |
5604 GaimGtkWindow *win; | |
5605 | |
5606 for (l = gaim_get_conversations(); l != NULL; l = l->next) | |
5607 { | |
5608 conv = (GaimConversation *)l->data; | |
5609 | |
5610 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
5611 continue; | |
5612 | |
5613 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5614 win = gtkconv->win; | |
5615 | |
5616 gtk_check_menu_item_set_active( | |
5617 GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
5618 (gboolean)GPOINTER_TO_INT(value)); | |
5619 | |
5620 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
5621 (gboolean)GPOINTER_TO_INT(value)); | |
5622 } | |
5623 } | |
5624 | |
5625 static void | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5626 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5627 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5628 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5629 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5630 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5631 GaimGtkConversation *gtkconv; |
11581 | 5632 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5633 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5634 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5635 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5636 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5637 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5638 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5639 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5640 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5641 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5642 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5643 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5644 gtk_check_menu_item_set_active( |
11581 | 5645 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5646 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5647 |
5648 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5649 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5650 else |
8317 | 5651 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5652 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5653 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5654 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5655 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5656 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5657 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5658 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5659 GList *l; |
8189 | 5660 GaimConversation *conv; |
5661 GaimGtkConversation *gtkconv; | |
11581 | 5662 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5663 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5664 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
|
5665 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5666 |
8189 | 5667 /* Set the "animate" flag for each icon based on the new preference */ |
5668 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5669 conv = (GaimConversation *)l->data; | |
5670 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5671 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5672 } |
8189 | 5673 |
5674 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5675 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5676 win = l->data; | |
5677 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5678 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5679 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5680 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5681 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5682 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5683 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
|
5684 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5685 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5686 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5687 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5688 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5689 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5690 |
11338 | 5691 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 5692 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5693 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5694 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5695 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
5696 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5697 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5698 gpointer value, gpointer data) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5699 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5700 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5701 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5702 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5703 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5704 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5705 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5706 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5707 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5708 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5709 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5710 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5711 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away")!=0) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5712 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5713 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5714 if(gaim_status_type_get_primitive(gaim_status_get_type(oldstatus))!=GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5715 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5716 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5717 if(gaim_status_type_get_primitive(gaim_status_get_type(newstatus))==GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5718 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5719 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5720 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5721 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5722 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5723 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5724 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5725 if(gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5726 gaim_status_get_type(gaim_account_get_active_status( |
12239 | 5727 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5728 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5729 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5730 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5731 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5732 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5733 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5734 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5735 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5736 hide_new_pref_cb(const char *name, GaimPrefType type, gpointer value, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5737 gpointer data) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5738 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5739 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5740 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5741 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5742 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5743 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5744 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5745 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5746 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5747 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "always")==0) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5748 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5749 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5750 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away")==0) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5751 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5752 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5753 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5754 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5755 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5756 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5757 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5758 if(when_away && gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5759 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5760 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5761 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5762 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5763 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5764 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5765 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5766 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5767 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5768 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5769 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5770 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5771 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5772 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5773 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5774 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5775 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5776 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5777 |
11581 | 5778 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5779 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5780 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5781 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5782 |
11581 | 5783 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5784 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5785 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5786 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5787 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5788 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5789 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5790 GaimAccount *account; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5791 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5792 account = gaim_connection_get_account(gc); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5793 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5794 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5795 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5796 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5797 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5798 if (gaim_conversation_get_account(conv) == account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5799 gaim_conversation_update(conv, GPOINTER_TO_INT(event)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5800 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5801 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5802 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5803 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5804 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5805 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5806 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5807 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5808 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5809 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5810 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5811 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5812 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5813 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5814 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5815 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5816 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5817 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5818 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5819 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5820 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5821 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5822 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5823 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5824 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5825 |
12264 | 5826 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5827 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 5828 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 5829 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5830 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 5831 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 5832 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5833 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5834 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5835 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5836 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5837 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
|
5838 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5839 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5840 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5841 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5842 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5843 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5844 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5845 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5846 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5847 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 5848 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5849 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 5850 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5851 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5852 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5853 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 5854 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
|
5855 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5856 /* convert old queuing prefs to hide_new 3-way pref */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5857 if(gaim_prefs_exists("/plugins/gtk/docklet/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5858 gaim_prefs_get_bool("/plugins/gtk/docklet/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5859 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "always"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5860 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5861 else if(gaim_prefs_exists("/gaim/gtk/away/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5862 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5863 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "away"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5864 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5865 else { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5866 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "never"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5867 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5868 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5869 /* Connect callbacks. */ |
10087 | 5870 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
|
5871 close_on_tabs_pref_cb, NULL); |
12188 | 5872 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
5873 show_timestamps_pref_cb, NULL); | |
10087 | 5874 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
|
5875 show_formatting_toolbar_pref_cb, NULL); |
10087 | 5876 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5877 spellcheck_pref_cb, NULL); |
10087 | 5878 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5879 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5880 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5881 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5882 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5883 |
10087 | 5884 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5885 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5886 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5887 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5888 /* IM callbacks */ |
10087 | 5889 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
|
5890 animate_buddy_icons_pref_cb, NULL); |
10087 | 5891 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
|
5892 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5893 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5894 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5895 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5896 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5897 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5898 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5899 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5900 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
5901 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5902 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5903 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5904 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5905 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5906 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 5907 |
5908 /********************************************************************** | |
5909 * Register commands | |
5910 **********************************************************************/ | |
9829 | 5911 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
5912 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
5913 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 5914 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
5915 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5916 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 5917 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
5918 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5919 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
|
5920 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5921 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5922 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 5923 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 5924 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
5925 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 5926 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5927 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5928 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5929 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5930 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5931 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5932 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5933 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5934 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5935 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5936 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5937 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5938 gaim_signal_connect(blist_handle, "buddy-added", handle, |
11855 | 5939 G_CALLBACK(buddy_update_cb), NULL); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5940 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
11855 | 5941 G_CALLBACK(buddy_update_cb), NULL); |
5942 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5943 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5944 handle, G_CALLBACK(received_im_msg_cb), NULL); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5945 |
11581 | 5946 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5947 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5948 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5949 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5950 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5951 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5952 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5953 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5954 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5955 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5956 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5957 { |
10443 | 5958 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 5959 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5960 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5961 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5962 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5963 } |
11581 | 5964 |
5965 | |
5966 | |
5967 | |
5968 | |
5969 | |
5970 | |
5971 | |
5972 | |
5973 | |
5974 | |
5975 | |
5976 | |
5977 | |
5978 | |
5979 | |
5980 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
5981 * and touch each others' private members all day long */ | |
5982 | |
5983 /** | |
5984 * @file gtkconvwin.c GTK+ Conversation Window API | |
5985 * @ingroup gtkui | |
5986 * | |
5987 * gaim | |
5988 * | |
5989 * Gaim is the legal property of its developers, whose names are too numerous | |
5990 * to list here. Please refer to the COPYRIGHT file distributed with this | |
5991 * source distribution. | |
5992 * | |
5993 * This program is free software; you can redistribute it and/or modify | |
5994 * it under the terms of the GNU General Public License as published by | |
5995 * the Free Software Foundation; either version 2 of the License, or | |
5996 * (at your option) any later version. | |
5997 * | |
5998 * This program is distributed in the hope that it will be useful, | |
5999 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
6000 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
6001 * GNU General Public License for more details. | |
6002 * | |
6003 * You should have received a copy of the GNU General Public License | |
6004 * along with this program; if not, write to the Free Software | |
6005 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
6006 * | |
6007 */ | |
6008 #include "internal.h" | |
6009 #include "gtkgaim.h" | |
6010 | |
6011 | |
6012 #include <gdk/gdkkeysyms.h> | |
6013 | |
6014 #include "account.h" | |
6015 #include "cmds.h" | |
6016 #include "debug.h" | |
6017 #include "imgstore.h" | |
6018 #include "log.h" | |
6019 #include "notify.h" | |
6020 #include "prpl.h" | |
6021 #include "request.h" | |
6022 #include "util.h" | |
6023 | |
6024 #include "gtkdnd-hints.h" | |
6025 #include "gtkblist.h" | |
6026 #include "gtkconv.h" | |
6027 #include "gtkdialogs.h" | |
6028 #include "gtkmenutray.h" | |
6029 #include "gtkpounce.h" | |
6030 #include "gtkprefs.h" | |
6031 #include "gtkprivacy.h" | |
6032 #include "gtkutils.h" | |
6033 #include "gtkstock.h" | |
6034 #include "gtkimhtml.h" | |
6035 #include "gtkimhtmltoolbar.h" | |
6036 | |
6037 static void | |
6038 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
6039 { | |
6040 gtk_widget_destroy(warn_close_dialog); | |
6041 warn_close_dialog = NULL; | |
6042 | |
6043 if (resp == GTK_RESPONSE_OK) | |
6044 gaim_gtk_conv_window_destroy(win); | |
6045 } | |
6046 | |
6047 static void | |
6048 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
6049 { | |
6050 GtkWidget *label; | |
6051 GtkWidget *vbox, *hbox; | |
6052 GtkWidget *img; | |
6053 | |
6054 g_return_if_fail(warn_close_dialog == NULL); | |
6055 | |
6056 | |
6057 warn_close_dialog = gtk_dialog_new_with_buttons( | |
6058 _("Confirm close"), | |
6059 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
6060 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
6061 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
6062 | |
6063 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
6064 GTK_RESPONSE_OK); | |
6065 | |
6066 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
6067 6); | |
6068 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
6069 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
6070 FALSE); | |
6071 | |
6072 /* Setup the outside spacing. */ | |
6073 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
6074 | |
6075 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
6076 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
6077 | |
6078 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
6079 GTK_ICON_SIZE_DIALOG); | |
6080 /* Setup the inner hbox and put the dialog's icon in it. */ | |
6081 hbox = gtk_hbox_new(FALSE, 12); | |
6082 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
6083 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
6084 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
6085 | |
6086 /* Setup the right vbox. */ | |
6087 vbox = gtk_vbox_new(FALSE, 12); | |
6088 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
6089 | |
6090 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
6091 gtk_widget_set_size_request(label, 350, -1); | |
6092 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
6093 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
6094 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
6095 | |
6096 /* Connect the signals. */ | |
6097 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
6098 G_CALLBACK(do_close), gtkwin); | |
6099 | |
6100 } | |
6101 | |
6102 /************************************************************************** | |
6103 * Callbacks | |
6104 **************************************************************************/ | |
6105 | |
6106 static gboolean | |
6107 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
6108 { | |
6109 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6110 GList *l; |
11581 | 6111 |
6112 /* If there are unread messages then show a warning dialog */ | |
6113 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
6114 l != NULL; l = l->next) | |
6115 { | |
6116 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6117 if (gaim_conversation_get_type(gtkconv->active_conv) == GAIM_CONV_TYPE_IM && |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6118 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6119 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6120 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6121 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6122 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6123 return TRUE; |
11581 | 6124 } |
6125 } | |
6126 | |
6127 gaim_gtk_conv_window_destroy(win); | |
6128 | |
6129 return TRUE; | |
6130 } | |
6131 | |
11604 | 6132 static void |
6133 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
6134 { | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6135 if (state == GAIM_UNSEEN_NONE) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6136 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6137 gtkconv->unseen_count = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6138 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6139 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6140 else |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6141 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6142 gtkconv->unseen_count++; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6143 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6144 if (state > gtkconv->unseen_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6145 gtkconv->unseen_state = state; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6146 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6147 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6148 /* emit update signal to notify of count and possible unseen state change */ |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6149 gaim_conversation_update(gtkconv->active_conv, GAIM_CONV_UPDATE_UNSEEN); |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6150 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6151 |
11581 | 6152 /* |
6153 * When a conversation window is focused, we know the user | |
6154 * has looked at it so we know there are no longer unseen | |
6155 * messages. | |
6156 */ | |
6157 static gint | |
6158 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6159 { | |
6160 GaimGtkWindow *win = d; | |
11604 | 6161 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6162 | |
6163 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6164 |
6165 return FALSE; | |
6166 } | |
6167 | |
11851 | 6168 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6169 /* Courtesy of Galeon! */ |
6170 static void | |
6171 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6172 { | |
6173 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6174 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6175 } | |
11851 | 6176 #endif |
11581 | 6177 |
6178 static void | |
6179 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6180 { | |
6181 static GdkCursor *cursor = NULL; | |
6182 | |
6183 gtkwin->in_drag = TRUE; | |
6184 | |
6185 if (gtkwin->drag_leave_signal) { | |
6186 g_signal_handler_disconnect(G_OBJECT(widget), | |
6187 gtkwin->drag_leave_signal); | |
6188 gtkwin->drag_leave_signal = 0; | |
6189 } | |
6190 | |
6191 if (cursor == NULL) | |
6192 cursor = gdk_cursor_new(GDK_FLEUR); | |
6193 | |
6194 /* Grab the pointer */ | |
6195 gtk_grab_add(gtkwin->notebook); | |
6196 #ifndef _WIN32 | |
6197 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6198 always be true after a button press. */ | |
6199 if (!gdk_pointer_is_grabbed()) | |
6200 #endif | |
6201 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6202 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6203 NULL, cursor, GDK_CURRENT_TIME); | |
6204 } | |
6205 | |
6206 static gboolean | |
6207 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6208 { | |
6209 | |
6210 /* | |
6211 * Make sure the user moved the mouse far enough for the | |
6212 * drag to be initiated. | |
6213 */ | |
6214 if (win->in_predrag) { | |
6215 if (e->x_root < win->drag_min_x || | |
6216 e->x_root >= win->drag_max_x || | |
6217 e->y_root < win->drag_min_y || | |
6218 e->y_root >= win->drag_max_y) { | |
6219 | |
6220 win->in_predrag = FALSE; | |
6221 notebook_init_grab(win, widget); | |
6222 } | |
6223 } | |
6224 else { /* Otherwise, draw the arrows. */ | |
6225 GaimGtkWindow *dest_win; | |
6226 GtkNotebook *dest_notebook; | |
6227 GtkWidget *tab; | |
6228 gint nb_x, nb_y, page_num; | |
6229 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6230 gboolean horiz_tabs = FALSE; | |
11614 | 6231 GaimGtkConversation *gtkconv; |
6232 gboolean to_right = FALSE; | |
11581 | 6233 |
6234 /* Get the window that the cursor is over. */ | |
6235 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6236 | |
6237 if (dest_win == NULL) { | |
6238 dnd_hints_hide_all(); | |
6239 | |
6240 return TRUE; | |
6241 } | |
6242 | |
6243 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6244 | |
6245 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6246 | |
6247 arrow1_x = arrow2_x = nb_x; | |
6248 arrow1_y = arrow2_y = nb_y; | |
6249 | |
6250 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6251 e->x_root, e->y_root, &to_right); |
6252 to_right = to_right && (win != dest_win); | |
11581 | 6253 |
6254 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6255 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6256 | |
6257 horiz_tabs = TRUE; | |
6258 } | |
6259 | |
11614 | 6260 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6261 tab = gtkconv->tabby; | |
11581 | 6262 |
6263 if (horiz_tabs) { | |
6264 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6265 | |
11614 | 6266 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6267 arrow1_x += tab->allocation.width; |
6268 arrow2_x += tab->allocation.width; | |
6269 } | |
6270 | |
6271 arrow1_y = nb_y + tab->allocation.y; | |
6272 arrow2_y = nb_y + tab->allocation.y + | |
6273 tab->allocation.height; | |
6274 } else { | |
6275 arrow1_x = nb_x + tab->allocation.x; | |
6276 arrow2_x = nb_x + tab->allocation.x + | |
6277 tab->allocation.width; | |
6278 arrow1_y = arrow2_y = nb_y + tab->allocation.y + tab->allocation.height/2; | |
6279 | |
6280 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
6281 arrow1_y += tab->allocation.height; | |
6282 arrow2_y += tab->allocation.height; | |
6283 } | |
6284 } | |
6285 | |
6286 if (horiz_tabs) { | |
6287 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6288 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6289 } else { | |
6290 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6291 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6292 } | |
6293 } | |
6294 | |
6295 return TRUE; | |
6296 } | |
6297 | |
6298 static gboolean | |
6299 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6300 { | |
6301 if (win->in_drag) | |
6302 return FALSE; | |
6303 | |
6304 if (e->x_root < win->drag_min_x || | |
6305 e->x_root >= win->drag_max_x || | |
6306 e->y_root < win->drag_min_y || | |
6307 e->y_root >= win->drag_max_y) { | |
6308 | |
6309 win->in_predrag = FALSE; | |
6310 notebook_init_grab(win, widget); | |
6311 } | |
6312 | |
6313 return TRUE; | |
6314 } | |
6315 | |
6316 /* | |
6317 * THANK YOU GALEON! | |
6318 */ | |
6319 static gboolean | |
6320 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6321 { | |
6322 gint nb_x, nb_y, x_rel, y_rel; | |
6323 int tab_clicked; | |
6324 GtkWidget *page; | |
6325 GtkWidget *tab; | |
6326 | |
6327 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6328 return FALSE; | |
6329 | |
6330 | |
6331 if (win->in_drag) { | |
6332 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6333 "Already in the middle of a window drag at tab_press_cb\n"); | |
6334 return TRUE; | |
6335 } | |
6336 | |
6337 /* | |
6338 * Make sure a tab was actually clicked. The arrow buttons | |
6339 * mess things up. | |
6340 */ | |
11614 | 6341 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6342 |
6343 if (tab_clicked == -1) | |
6344 return FALSE; | |
6345 | |
6346 /* | |
6347 * Get the relative position of the press event, with regards to | |
6348 * the position of the notebook. | |
6349 */ | |
6350 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6351 | |
6352 x_rel = e->x_root - nb_x; | |
6353 y_rel = e->y_root - nb_y; | |
6354 | |
6355 /* Reset the min/max x/y */ | |
6356 win->drag_min_x = 0; | |
6357 win->drag_min_y = 0; | |
6358 win->drag_max_x = 0; | |
6359 win->drag_max_y = 0; | |
6360 | |
6361 /* Find out which tab was dragged. */ | |
6362 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6363 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6364 | |
6365 win->drag_min_x = tab->allocation.x + nb_x; | |
6366 win->drag_min_y = tab->allocation.y + nb_y; | |
6367 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6368 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6369 | |
6370 /* Make sure the click occurred in the tab. */ | |
6371 if (e->x_root < win->drag_min_x || | |
6372 e->x_root >= win->drag_max_x || | |
6373 e->y_root < win->drag_min_y || | |
6374 e->y_root >= win->drag_max_y) { | |
6375 | |
6376 return FALSE; | |
6377 } | |
6378 | |
6379 win->in_predrag = TRUE; | |
6380 win->drag_tab = tab_clicked; | |
6381 | |
6382 /* Connect the new motion signals. */ | |
6383 win->drag_motion_signal = | |
6384 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6385 G_CALLBACK(notebook_motion_cb), win); | |
6386 | |
6387 win->drag_leave_signal = | |
6388 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6389 G_CALLBACK(notebook_leave_cb), win); | |
6390 | |
6391 return FALSE; | |
6392 } | |
6393 | |
6394 static gboolean | |
6395 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6396 { | |
6397 GaimGtkWindow *dest_win; | |
6398 GaimConversation *conv; | |
6399 GaimGtkConversation *gtkconv; | |
6400 gint dest_page_num = 0; | |
6401 gboolean new_window = FALSE; | |
11614 | 6402 gboolean to_right = FALSE; |
11581 | 6403 |
6404 /* | |
6405 * Don't check to make sure that the event's window matches the | |
6406 * widget's, because we may be getting an event passed on from the | |
6407 * close button. | |
6408 */ | |
6409 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6410 return FALSE; | |
6411 | |
6412 if (gdk_pointer_is_grabbed()) { | |
6413 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6414 gtk_grab_remove(widget); | |
6415 } | |
6416 | |
6417 if (!win->in_predrag && !win->in_drag) | |
6418 return FALSE; | |
6419 | |
6420 /* Disconnect the motion signal. */ | |
6421 if (win->drag_motion_signal) { | |
6422 g_signal_handler_disconnect(G_OBJECT(widget), | |
6423 win->drag_motion_signal); | |
6424 | |
6425 win->drag_motion_signal = 0; | |
6426 } | |
6427 | |
6428 /* | |
6429 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6430 * signal. | |
6431 */ | |
6432 if (win->in_predrag) { | |
6433 win->in_predrag = FALSE; | |
6434 | |
6435 if (win->drag_leave_signal) { | |
6436 g_signal_handler_disconnect(G_OBJECT(widget), | |
6437 win->drag_leave_signal); | |
6438 | |
6439 win->drag_leave_signal = 0; | |
6440 } | |
6441 } | |
6442 | |
6443 /* If we're not in drag... */ | |
6444 /* We're perfectly normal people! */ | |
6445 if (!win->in_drag) | |
6446 return FALSE; | |
6447 | |
6448 win->in_drag = FALSE; | |
6449 | |
6450 dnd_hints_hide_all(); | |
6451 | |
6452 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6453 | |
6454 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6455 | |
6456 if (dest_win == NULL) { | |
6457 /* If the current window doesn't have any other conversations, | |
6458 * there isn't much point transferring the conv to a new window. */ | |
6459 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6460 /* Make a new window to stick this to. */ | |
6461 dest_win = gaim_gtk_conv_window_new(); | |
6462 new_window = TRUE; | |
6463 } | |
6464 } | |
6465 | |
6466 if (dest_win == NULL) | |
6467 return FALSE; | |
6468 | |
6469 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6470 "conversation-dragging", win, dest_win); | |
6471 | |
6472 /* Get the destination page number. */ | |
6473 if (!new_window) | |
6474 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6475 e->x_root, e->y_root, &to_right); |
11581 | 6476 |
6477 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6478 | |
6479 if (win == dest_win) { | |
6480 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6481 } else { | |
6482 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6483 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 6484 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 6485 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
6486 if (new_window) { | |
6487 gint win_width, win_height; | |
6488 | |
6489 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6490 &win_width, &win_height); | |
6491 | |
6492 gtk_window_move(GTK_WINDOW(dest_win->window), | |
6493 e->x_root - (win_width / 2), | |
6494 e->y_root - (win_height / 2)); | |
6495 | |
6496 gaim_gtk_conv_window_show(dest_win); | |
6497 } | |
6498 } | |
6499 | |
6500 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
6501 | |
6502 return TRUE; | |
6503 } | |
6504 | |
6505 | |
6506 static void | |
6507 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6508 gpointer user_data) | |
6509 { | |
6510 GaimGtkWindow *win; | |
6511 GaimConversation *conv; | |
6512 GaimGtkConversation *gtkconv; | |
6513 | |
6514 win = user_data; | |
6515 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6516 | |
6517 g_return_if_fail(conv != NULL); | |
6518 | |
6519 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
6520 return; | |
6521 | |
6522 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6523 | |
6524 stop_anim(NULL, gtkconv); | |
6525 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6526 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6527 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6528 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6529 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6530 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6531 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6532 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6533 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6534 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6535 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6536 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6537 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6538 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6539 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6540 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6541 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6542 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6543 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6544 /* 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
|
6545 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6546 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6547 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6548 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6549 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6550 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6551 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6552 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6553 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6554 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6555 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6556 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6557 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6558 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6559 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6560 GaimGtkWindow *win; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6561 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6562 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6563 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6564 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6565 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6566 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6567 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6568 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6569 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6570 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6571 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6572 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6573 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6574 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6575 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6576 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6577 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6578 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6579 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6580 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6581 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6582 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6583 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6584 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6585 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6586 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6587 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6588 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6589 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6590 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6591 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6592 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6593 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6594 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6595 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6596 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6597 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6598 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6599 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6600 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
6601 gaim_gtkconv_get_tab_at_xy(win, event->x_root, event->y_root, NULL)); |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6602 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6603 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6604 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6605 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6606 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6607 } |
12188 | 6608 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6609 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6610 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6611 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6612 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6613 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6614 item = gtk_menu_item_new_with_label("Detach this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6615 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6616 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6617 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6618 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6619 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6620 item = gtk_menu_item_new_with_label("Close this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6621 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6622 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6623 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6624 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6625 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6626 gaim_separator(menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6627 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6628 item = gtk_menu_item_new_with_label("Close other tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6629 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6630 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6631 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6632 G_CALLBACK(close_others_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6633 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6634 item = gtk_menu_item_new_with_label("Close all tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6635 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6636 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6637 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6638 G_CALLBACK(close_window), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6639 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6640 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6641 } |
11581 | 6642 |
6643 static void | |
6644 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6645 gpointer user_data) | |
6646 { | |
6647 GaimGtkWindow *win; | |
6648 GaimConversation *conv; | |
6649 GaimGtkConversation *gtkconv; | |
6650 | |
6651 win = user_data; | |
6652 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
6653 conv = gtkconv->active_conv; | |
6654 | |
6655 g_return_if_fail(conv != NULL); | |
6656 | |
6657 /* | |
6658 * Only set "unseen" to "none" if the window has focus | |
6659 */ | |
6660 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 6661 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 6662 |
6663 /* Update the menubar */ | |
6664 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6665 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
|
6666 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6667 |
11594 | 6668 generate_send_to_items(win); |
6669 | |
11604 | 6670 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 6671 |
6672 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), | |
6673 gtkconv->make_sound); | |
6674 | |
6675 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
6676 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
6677 | |
6678 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
12188 | 6679 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
11581 | 6680 |
6681 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6682 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), | |
6683 gtkconv->u.im->show_icon); | |
11604 | 6684 |
11581 | 6685 /* |
6686 * We pause icons when they are not visible. If this icon should | |
6687 * be animated then start it back up again. | |
6688 */ | |
6689 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
6690 (gtkconv->u.im->animate)) | |
6691 start_anim(NULL, gtkconv); | |
6692 } | |
6693 | |
6694 /************************************************************************** | |
6695 * GTK+ window ops | |
6696 **************************************************************************/ | |
6697 | |
6698 GList * | |
6699 gaim_gtk_conv_windows_get_list() | |
6700 { | |
6701 return window_list; | |
6702 } | |
6703 | |
6704 GaimGtkWindow * | |
6705 gaim_gtk_conv_window_new() | |
6706 { | |
6707 GaimGtkWindow *win; | |
6708 GtkPositionType pos; | |
6709 GtkWidget *testidea; | |
6710 GtkWidget *menubar; | |
6711 | |
6712 win = g_malloc0(sizeof(GaimGtkWindow)); | |
6713 | |
6714 window_list = g_list_append(window_list, win); | |
6715 | |
6716 /* Create the window. */ | |
6717 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
6718 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
6719 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
6720 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
6721 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
6722 | |
6723 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
6724 G_CALLBACK(close_win_cb), win); | |
6725 | |
6726 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
6727 G_CALLBACK(focus_win_cb), win); | |
6728 | |
6729 /* Create the notebook. */ | |
6730 win->notebook = gtk_notebook_new(); | |
6731 | |
6732 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
6733 | |
6734 #if 0 | |
6735 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
6736 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
6737 #endif | |
6738 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
6739 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
6740 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
6741 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
6742 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
6743 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6744 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6745 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6746 |
11581 | 6747 gtk_widget_show(win->notebook); |
6748 | |
6749 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
6750 G_CALLBACK(before_switch_conv_cb), win); | |
6751 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
6752 G_CALLBACK(switch_conv_cb), win); | |
6753 | |
6754 /* Setup the tab drag and drop signals. */ | |
6755 gtk_widget_add_events(win->notebook, | |
6756 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
6757 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
6758 G_CALLBACK(notebook_press_cb), win); | |
6759 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
6760 G_CALLBACK(notebook_release_cb), win); | |
6761 | |
6762 testidea = gtk_vbox_new(FALSE, 0); | |
6763 | |
6764 /* Setup the menubar. */ | |
6765 menubar = setup_menubar(win); | |
6766 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
6767 | |
6768 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
6769 | |
6770 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
6771 | |
6772 gtk_widget_show(testidea); | |
6773 | |
6774 return win; | |
6775 } | |
6776 | |
6777 void | |
6778 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
6779 { | |
6780 window_list = g_list_remove(window_list, win); | |
6781 | |
11611 | 6782 if (win->gtkconvs) { |
6783 while (win->gtkconvs) { | |
6784 GList *nextgtk = win->gtkconvs->next; | |
6785 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
6786 GList *nextcore = gtkconv->convs->next; | |
6787 GaimConversation *conv = gtkconv->convs->data; | |
6788 gaim_conversation_destroy(conv); | |
6789 if (!nextgtk && !nextcore) | |
6790 /* we'll end up invoking ourselves when we destroy our last child */ | |
6791 /* so don't destroy ourselves right now */ | |
6792 return; | |
6793 } | |
6794 return; | |
6795 } | |
11581 | 6796 gtk_widget_destroy(win->window); |
6797 | |
6798 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
6799 | |
6800 g_free(win); | |
6801 } | |
6802 | |
6803 void | |
6804 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
6805 { | |
6806 gtk_widget_show(win->window); | |
6807 } | |
6808 | |
6809 void | |
6810 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
6811 { | |
6812 gtk_widget_hide(win->window); | |
6813 } | |
6814 | |
6815 void | |
6816 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
6817 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
6818 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 6819 } |
6820 | |
6821 void | |
6822 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6823 { | |
6824 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
6825 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
6826 gtkconv->tab_cont)); | |
6827 } | |
6828 | |
6829 void | |
6830 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6831 { | |
6832 GaimConversation *conv = gtkconv->active_conv; | |
6833 GaimGtkConversation *focus_gtkconv; | |
6834 GtkWidget *tabby, *menu_tabby; | |
6835 GtkWidget *tab_cont = gtkconv->tab_cont; | |
6836 GtkWidget *close_image; | |
6837 GaimConversationType conv_type; | |
6838 const char *name; | |
6839 const gchar *tmp_lab; | |
6840 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 6841 gboolean tabs_side = FALSE; |
6842 gint angle = 0; | |
11581 | 6843 |
6844 name = gaim_conversation_get_name(conv); | |
6845 conv_type = gaim_conversation_get_type(conv); | |
6846 | |
6847 | |
6848 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
6849 gtkconv->win = win; | |
6850 | |
11619 | 6851 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
6852 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
6853 tabs_side = TRUE; | |
6854 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
6855 angle = 90; | |
6856 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6857 angle = 270; | |
6858 | |
6859 if (angle) | |
6860 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
6861 else | |
6862 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 6863 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
6864 | |
6865 /* Close button. */ | |
6866 gtkconv->close = gtk_button_new(); | |
6867 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
6868 if (gtk_check_version(2, 4, 2) == NULL) { | |
6869 /* Need to account for extra padding around the gtkbutton */ | |
6870 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
6871 "focus-line-width", &focus_width, | |
6872 "focus-padding", &focus_pad, | |
6873 NULL); | |
6874 close_button_width += (focus_width + focus_pad) * 2; | |
6875 close_button_height += (focus_width + focus_pad) * 2; | |
6876 } | |
6877 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
6878 close_button_width, close_button_height); | |
6879 | |
6880 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
6881 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
6882 gtk_widget_show(close_image); | |
6883 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
6884 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
6885 _("Close conversation"), NULL); | |
6886 | |
6887 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
6888 G_CALLBACK(close_conv_cb), gtkconv); | |
6889 | |
11851 | 6890 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6891 /* |
6892 * I love Galeon. They have a fix for that stupid annoying visible | |
6893 * border bug. I love you guys! -- ChipX86 | |
6894 */ | |
11851 | 6895 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 6896 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
6897 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 6898 #endif |
11581 | 6899 |
6900 /* Status icon. */ | |
6901 gtkconv->icon = gtk_image_new(); | |
6902 gtkconv->menu_icon = gtk_image_new(); | |
6903 update_tab_icon(conv); | |
6904 | |
6905 /* Tab label. */ | |
6906 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 6907 |
11581 | 6908 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 6909 if (!angle) |
6910 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 6911 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 6912 if (tabs_side) { |
6913 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
6914 } | |
6915 if (angle) | |
6916 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 6917 #endif |
6918 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6919 #if 0 | |
6920 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
6921 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
6922 #endif | |
6923 | |
6924 /* Pack it all together. */ | |
11619 | 6925 if (angle == 90) |
6926 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
6927 else | |
6928 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 6929 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
6930 FALSE, FALSE, 0); | |
6931 | |
6932 gtk_widget_show_all(gtkconv->icon); | |
6933 gtk_widget_show_all(gtkconv->menu_icon); | |
6934 | |
6935 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
6936 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
6937 gtk_widget_show(gtkconv->tab_label); | |
6938 gtk_widget_show(gtkconv->menu_label); | |
6939 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
6940 | |
11619 | 6941 if (angle == 90) |
6942 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
6943 else | |
6944 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 6945 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
6946 gtk_widget_show(gtkconv->close); | |
6947 | |
6948 gtk_widget_show(tabby); | |
6949 gtk_widget_show(menu_tabby); | |
6950 | |
6951 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6952 gaim_gtkconv_update_buddy_icon(conv); | |
6953 | |
6954 /* Add this pane to the conversation's notebook. */ | |
6955 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 6956 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 6957 |
6958 | |
6959 gtk_widget_show(tab_cont); | |
6960 | |
6961 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
6962 /* Er, bug in notebooks? Switch to the page manually. */ | |
6963 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
6964 | |
6965 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6966 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6967 } else | |
6968 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
6969 | |
6970 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
6971 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
6972 gtk_widget_grab_focus(focus_gtkconv->entry); | |
6973 | |
6974 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 6975 update_send_to_selection(win); |
11581 | 6976 } |
6977 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6978 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6979 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
11581 | 6980 { |
6981 unsigned int index; | |
6982 GaimConversationType conv_type; | |
6983 | |
6984 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
6985 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
6986 | |
6987 g_object_ref(gtkconv->tab_cont); | |
6988 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
6989 | |
6990 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
6991 | |
6992 /* go back to tabless if need be */ | |
6993 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
6994 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6995 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6996 } | |
6997 | |
6998 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 6999 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7000 if (!win->gtkconvs && win != hidden_convwin) |
11582 | 7001 gaim_gtk_conv_window_destroy(win); |
11581 | 7002 } |
7003 | |
7004 GaimGtkConversation * | |
7005 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
7006 { | |
7007 GtkWidget *tab_cont; | |
7008 | |
7009 if (index == -1) | |
7010 index = 0; | |
7011 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 7012 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 7013 } |
7014 | |
7015 GaimGtkConversation * | |
7016 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
7017 { | |
7018 int index; | |
7019 GtkWidget *tab_cont; | |
7020 | |
7021 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
7022 if (index == -1) | |
7023 index = 0; | |
7024 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
7025 if (!tab_cont) | |
7026 return NULL; | |
7027 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
7028 } | |
7029 | |
7030 | |
7031 GaimConversation * | |
7032 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
7033 { | |
7034 GaimGtkConversation *gtkconv; | |
7035 | |
7036 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
7037 return gtkconv ? gtkconv->active_conv : NULL; | |
7038 } | |
7039 | |
7040 gboolean | |
7041 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
7042 { | |
7043 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
7044 } | |
7045 | |
7046 gboolean | |
7047 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
7048 { | |
7049 gboolean has_focus = FALSE; | |
7050 | |
7051 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
7052 | |
7053 return has_focus; | |
7054 } | |
7055 | |
7056 GaimGtkWindow * | |
7057 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
7058 { | |
7059 GaimGtkWindow *win; | |
7060 GdkWindow *gdkwin; | |
7061 GList *l; | |
7062 | |
7063 gdkwin = gdk_window_at_pointer(&x, &y); | |
7064 | |
7065 if (gdkwin) | |
7066 gdkwin = gdk_window_get_toplevel(gdkwin); | |
7067 | |
7068 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
7069 win = l->data; | |
7070 | |
7071 if (gdkwin == win->window->window) | |
7072 return win; | |
7073 } | |
7074 | |
7075 return NULL; | |
7076 } | |
7077 | |
7078 GList * | |
7079 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
7080 { | |
7081 return win->gtkconvs; | |
7082 } | |
7083 | |
7084 guint | |
7085 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
7086 { | |
7087 return g_list_length(win->gtkconvs); | |
7088 } | |
7089 | |
7090 GaimGtkWindow * | |
7091 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
7092 { | |
7093 GList *wins, *convs; | |
7094 GaimGtkWindow *win; | |
7095 GaimGtkConversation *conv; | |
7096 | |
7097 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7098 return NULL; | |
7099 | |
7100 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7101 win = wins->data; | |
7102 | |
7103 for (convs = win->gtkconvs; | |
7104 convs != NULL; | |
7105 convs = convs->next) { | |
7106 | |
7107 conv = convs->data; | |
7108 | |
7109 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7110 return win; | |
7111 } | |
7112 } | |
7113 | |
7114 return NULL; | |
7115 } | |
7116 | |
7117 GaimGtkWindow * | |
7118 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
7119 { | |
7120 GList *wins, *convs; | |
7121 GaimGtkWindow *win; | |
7122 GaimGtkConversation *conv; | |
7123 | |
7124 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7125 return NULL; | |
7126 | |
7127 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7128 wins != NULL; | |
7129 wins = wins->prev) { | |
7130 | |
7131 win = wins->data; | |
7132 | |
7133 for (convs = win->gtkconvs; | |
7134 convs != NULL; | |
7135 convs = convs->next) { | |
7136 | |
7137 conv = convs->data; | |
7138 | |
7139 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7140 return win; | |
7141 } | |
7142 } | |
7143 | |
7144 return NULL; | |
7145 } | |
7146 | |
7147 | |
7148 /************************************************************************** | |
7149 * Conversation placement functions | |
7150 **************************************************************************/ | |
7151 typedef struct | |
7152 { | |
7153 char *id; | |
7154 char *name; | |
7155 GaimConvPlacementFunc fnc; | |
7156 | |
7157 } ConvPlacementData; | |
7158 | |
7159 static GList *conv_placement_fncs = NULL; | |
7160 static GaimConvPlacementFunc place_conv = NULL; | |
7161 | |
7162 /* This one places conversations in the last made window. */ | |
7163 static void | |
7164 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7165 { | |
7166 GaimGtkWindow *win; | |
7167 | |
7168 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7169 win = l ? l->data : NULL;; | |
7170 | |
7171 if (win == NULL) { | |
7172 win = gaim_gtk_conv_window_new(); | |
7173 | |
7174 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7175 gaim_gtk_conv_window_show(win); | |
7176 } else { | |
7177 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7178 } | |
7179 } | |
7180 | |
7181 /* This one places conversations in the last made window of the same type. */ | |
7182 static void | |
7183 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7184 { | |
7185 GaimGtkWindow *win; | |
7186 | |
7187 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7188 | |
7189 if (win == NULL) { | |
7190 win = gaim_gtk_conv_window_new(); | |
7191 | |
7192 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7193 gaim_gtk_conv_window_show(win); | |
7194 } else | |
7195 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7196 } | |
7197 | |
7198 /* This one places each conversation in its own window. */ | |
7199 static void | |
7200 conv_placement_new_window(GaimGtkConversation *conv) | |
7201 { | |
7202 GaimGtkWindow *win; | |
7203 | |
7204 win = gaim_gtk_conv_window_new(); | |
7205 | |
7206 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7207 | |
7208 gaim_gtk_conv_window_show(win); | |
7209 } | |
7210 | |
7211 static GaimGroup * | |
7212 conv_get_group(GaimGtkConversation *conv) | |
7213 { | |
7214 GaimGroup *group = NULL; | |
7215 | |
7216 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7217 GaimBuddy *buddy; | |
7218 | |
7219 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7220 gaim_conversation_get_name(conv->active_conv)); | |
7221 | |
7222 if (buddy != NULL) | |
12088 | 7223 group = gaim_buddy_get_group(buddy); |
11581 | 7224 |
7225 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7226 GaimChat *chat; | |
7227 | |
7228 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7229 gaim_conversation_get_name(conv->active_conv)); | |
7230 | |
7231 if (chat != NULL) | |
7232 group = gaim_chat_get_group(chat); | |
7233 } | |
7234 | |
7235 return group; | |
7236 } | |
7237 | |
7238 /* | |
7239 * This groups things by, well, group. Buddies from groups will always be | |
7240 * grouped together, and a buddy from a group not belonging to any currently | |
7241 * open windows will get a new window. | |
7242 */ | |
7243 static void | |
7244 conv_placement_by_group(GaimGtkConversation *conv) | |
7245 { | |
7246 GaimConversationType type; | |
7247 GaimGroup *group = NULL; | |
7248 GList *wl, *cl; | |
7249 | |
7250 type = gaim_conversation_get_type(conv->active_conv); | |
7251 | |
7252 group = conv_get_group(conv); | |
7253 | |
7254 /* Go through the list of IMs and find one with this group. */ | |
7255 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7256 GaimGtkWindow *win2; | |
7257 GaimGtkConversation *conv2; | |
7258 GaimGroup *group2 = NULL; | |
7259 | |
7260 win2 = wl->data; | |
7261 | |
7262 for (cl = win2->gtkconvs; | |
7263 cl != NULL; | |
7264 cl = cl->next) { | |
7265 conv2 = cl->data; | |
7266 | |
7267 group2 = conv_get_group(conv2); | |
7268 | |
7269 if (group == group2) { | |
7270 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7271 | |
7272 return; | |
7273 } | |
7274 } | |
7275 } | |
7276 | |
7277 /* Make a new window. */ | |
7278 conv_placement_new_window(conv); | |
7279 } | |
7280 | |
7281 /* This groups things by account. Otherwise, the same semantics as above */ | |
7282 static void | |
7283 conv_placement_by_account(GaimGtkConversation *conv) | |
7284 { | |
7285 GaimConversationType type; | |
7286 GList *wins, *convs; | |
7287 GaimAccount *account; | |
7288 | |
7289 account = gaim_conversation_get_account(conv->active_conv); | |
7290 type = gaim_conversation_get_type(conv->active_conv); | |
7291 | |
7292 /* Go through the list of IMs and find one with this group. */ | |
7293 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7294 GaimGtkWindow *win2; | |
7295 GaimGtkConversation *conv2; | |
7296 | |
7297 win2 = wins->data; | |
7298 | |
7299 for (convs = win2->gtkconvs; | |
7300 convs != NULL; | |
7301 convs = convs->next) { | |
7302 conv2 = convs->data; | |
7303 | |
7304 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7305 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7306 return; | |
7307 } | |
7308 } | |
7309 } | |
7310 | |
7311 /* Make a new window. */ | |
7312 conv_placement_new_window(conv); | |
7313 } | |
7314 | |
7315 static ConvPlacementData * | |
7316 get_conv_placement_data(const char *id) | |
7317 { | |
7318 ConvPlacementData *data = NULL; | |
7319 GList *n; | |
7320 | |
7321 for (n = conv_placement_fncs; n; n = n->next) { | |
7322 data = n->data; | |
7323 if (!strcmp(data->id, id)) | |
7324 return data; | |
7325 } | |
7326 | |
7327 return NULL; | |
7328 } | |
7329 | |
7330 static void | |
7331 add_conv_placement_fnc(const char *id, const char *name, | |
7332 GaimConvPlacementFunc fnc) | |
7333 { | |
7334 ConvPlacementData *data; | |
7335 | |
7336 data = g_new(ConvPlacementData, 1); | |
7337 | |
7338 data->id = g_strdup(id); | |
7339 data->name = g_strdup(name); | |
7340 data->fnc = fnc; | |
7341 | |
7342 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7343 } | |
7344 | |
7345 static void | |
7346 ensure_default_funcs(void) | |
7347 { | |
7348 if (conv_placement_fncs == NULL) { | |
7349 add_conv_placement_fnc("last", _("Last created window"), | |
7350 conv_placement_last_created_win); | |
7351 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7352 conv_placement_last_created_win_type); | |
7353 add_conv_placement_fnc("new", _("New window"), | |
7354 conv_placement_new_window); | |
7355 add_conv_placement_fnc("group", _("By group"), | |
7356 conv_placement_by_group); | |
7357 add_conv_placement_fnc("account", _("By account"), | |
7358 conv_placement_by_account); | |
7359 } | |
7360 } | |
7361 | |
7362 GList * | |
7363 gaim_gtkconv_placement_get_options(void) | |
7364 { | |
7365 GList *n, *list = NULL; | |
7366 ConvPlacementData *data; | |
7367 | |
7368 ensure_default_funcs(); | |
7369 | |
7370 for (n = conv_placement_fncs; n; n = n->next) { | |
7371 data = n->data; | |
7372 list = g_list_append(list, data->name); | |
7373 list = g_list_append(list, data->id); | |
7374 } | |
7375 | |
7376 return list; | |
7377 } | |
7378 | |
7379 | |
7380 void | |
7381 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
7382 GaimConvPlacementFunc fnc) | |
7383 { | |
7384 g_return_if_fail(id != NULL); | |
7385 g_return_if_fail(name != NULL); | |
7386 g_return_if_fail(fnc != NULL); | |
7387 | |
7388 ensure_default_funcs(); | |
7389 | |
7390 add_conv_placement_fnc(id, name, fnc); | |
7391 } | |
7392 | |
7393 void | |
7394 gaim_gtkconv_placement_remove_fnc(const char *id) | |
7395 { | |
7396 ConvPlacementData *data = get_conv_placement_data(id); | |
7397 | |
7398 if (data == NULL) | |
7399 return; | |
7400 | |
7401 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
7402 | |
7403 g_free(data->id); | |
7404 g_free(data->name); | |
7405 g_free(data); | |
7406 } | |
7407 | |
7408 const char * | |
7409 gaim_gtkconv_placement_get_name(const char *id) | |
7410 { | |
7411 ConvPlacementData *data; | |
7412 | |
7413 ensure_default_funcs(); | |
7414 | |
7415 data = get_conv_placement_data(id); | |
7416 | |
7417 if (data == NULL) | |
7418 return NULL; | |
7419 | |
7420 return data->name; | |
7421 } | |
7422 | |
7423 GaimConvPlacementFunc | |
7424 gaim_gtkconv_placement_get_fnc(const char *id) | |
7425 { | |
7426 ConvPlacementData *data; | |
7427 | |
7428 ensure_default_funcs(); | |
7429 | |
7430 data = get_conv_placement_data(id); | |
7431 | |
7432 if (data == NULL) | |
7433 return NULL; | |
7434 | |
7435 return data->fnc; | |
7436 } | |
7437 | |
7438 void | |
7439 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
7440 { | |
7441 g_return_if_fail(func != NULL); | |
7442 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7443 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7444 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7445 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7446 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7447 place_conv = NULL; |
11581 | 7448 } |
7449 | |
7450 GaimConvPlacementFunc | |
7451 gaim_gtkconv_placement_get_current_func(void) | |
7452 { | |
7453 return place_conv; | |
7454 } | |
7455 | |
7456 void | |
7457 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
7458 { | |
7459 if (place_conv) | |
7460 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7461 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7462 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7463 } |
12239 | 7464 |
7465 gboolean | |
7466 gaim_gtkconv_is_hidden(GaimGtkConversation *gtkconv) | |
7467 { | |
7468 g_return_val_if_fail(gtkconv != NULL, FALSE); | |
7469 | |
7470 return (gtkconv->win == hidden_convwin); | |
7471 } |