Mercurial > pidgin.yaz
annotate src/gtkconv.c @ 12279:234c25bc5d49
[gaim-migrate @ 14583]
sf patch #1367212, from Casey Harkins
1) don't save window size when the blist is maximized
2) save whether the blist is maximized
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 01 Dec 2005 04:35:05 +0000 |
parents | 3ef381cdc47e |
children | 255e6912607b |
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); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
136 static void private_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
137 gboolean destroy_empty); |
4359 | 138 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
139 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
140 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
141 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
142 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
143 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
144 col = nick_colors[g_str_hash(name) % NUM_NICK_COLORS]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
145 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
146 (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
|
147 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
148 /* 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
|
149 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
150 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
151 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
152 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
153 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
154 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
155 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
156 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
157 |
4359 | 158 /************************************************************************** |
159 * Callbacks | |
160 **************************************************************************/ | |
10971 | 161 |
4359 | 162 static gint |
10810 | 163 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 164 { |
10810 | 165 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 166 |
10810 | 167 l = list; |
168 while (l) { | |
169 GaimConversation *conv = l->data; | |
170 gaim_conversation_destroy(conv); | |
171 l = l->next; | |
172 } | |
11508 | 173 |
10810 | 174 g_list_free(list); |
11508 | 175 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
176 return TRUE; |
4359 | 177 } |
178 | |
8914 | 179 static gboolean |
10810 | 180 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 181 { |
10810 | 182 GaimConversation *conv = gtkconv->active_conv; |
11508 | 183 |
8914 | 184 if (!GTK_WIDGET_VISIBLE(w)) |
185 return FALSE; | |
186 | |
187 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
188 return FALSE; | |
189 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
190 /* 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
|
191 * 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
|
192 * 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
|
193 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
194 /* 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
|
195 * negate it anyway. --luke */ |
11338 | 196 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 197 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
198 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
199 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
|
200 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
|
201 } |
8914 | 202 if (w == gtkconv->entry) |
203 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
204 } | |
11338 | 205 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 206 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
207 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
208 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
|
209 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
|
210 } |
8914 | 211 if (w == gtkconv->entry) |
212 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
213 } | |
214 | |
215 return FALSE; | |
216 } | |
217 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
218 static void |
10810 | 219 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
220 { |
10810 | 221 GaimConversation *conv = c->active_conv; |
11508 | 222 |
10665 | 223 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
224 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
225 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
226 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
227 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
228 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
|
229 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
230 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
231 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
|
232 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
233 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
234 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
|
235 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
236 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
237 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
238 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
239 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
240 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
241 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
242 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
243 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
244 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
|
245 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
246 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
247 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
248 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
249 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
250 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
251 fg_color.blue / 256); |
8061 | 252 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
253 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
254 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
255 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
256 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
259 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
261 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
262 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
264 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
266 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
267 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
268 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
269 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
270 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
271 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
272 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
273 g_free(color); |
8677 | 274 |
9025 | 275 |
10665 | 276 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 277 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
278 else | |
279 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 280 } |
281 } | |
9130 | 282 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
283 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
284 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *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 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
287 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
288 |
9130 | 289 static const char * |
290 gaim_gtk_get_cmd_prefix(void) | |
291 { | |
292 return "/"; | |
293 } | |
294 | |
9167 | 295 static GaimCmdRet |
9829 | 296 say_command_cb(GaimConversation *conv, |
297 const char *cmd, char **args, char **error, void *data) | |
298 { | |
11338 | 299 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 300 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 301 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 302 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
303 | |
304 return GAIM_CMD_RET_OK; | |
305 } | |
306 | |
307 static GaimCmdRet | |
9167 | 308 me_command_cb(GaimConversation *conv, |
9597 | 309 const char *cmd, char **args, char **error, void *data) |
9167 | 310 { |
311 char *tmp; | |
312 | |
313 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 314 |
11338 | 315 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 316 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 317 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 318 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
319 | |
320 g_free(tmp); | |
321 return GAIM_CMD_RET_OK; | |
322 } | |
323 | |
9212 | 324 static GaimCmdRet |
325 debug_command_cb(GaimConversation *conv, | |
9597 | 326 const char *cmd, char **args, char **error, void *data) |
9212 | 327 { |
328 char *tmp, *markup; | |
329 GaimCmdStatus status; | |
330 | |
331 if (!g_ascii_strcasecmp(args[0], "version")) { | |
332 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
|
333 markup = g_markup_escape_text(tmp, -1); |
9212 | 334 |
335 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
336 | |
337 g_free(tmp); | |
338 g_free(markup); | |
339 return status; | |
340 } else { | |
341 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
342 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
343 return GAIM_CMD_STATUS_OK; | |
344 } | |
345 } | |
346 | |
9213 | 347 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
348 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
349 const char *cmd, char **args, char **error, void *data) |
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 GaimGtkConversation *gtkconv = NULL; |
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 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
354 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
355 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
356 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
357 } |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
358 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
359 static GaimCmdRet |
9213 | 360 help_command_cb(GaimConversation *conv, |
9597 | 361 const char *cmd, char **args, char **error, void *data) |
9213 | 362 { |
9597 | 363 GList *l, *text; |
9213 | 364 GString *s; |
9597 | 365 |
366 if (args[0] != NULL) { | |
367 s = g_string_new(""); | |
368 text = gaim_cmd_help(conv, args[0]); | |
369 | |
370 if (text) { | |
371 for (l = text; l; l = l->next) | |
372 if (l->next) | |
9816 | 373 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 374 else |
9816 | 375 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 376 } else { |
377 g_string_append(s, _("No such command (in this context).")); | |
378 } | |
379 } else { | |
380 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
381 "The following commands are available in this context:\n")); | |
382 | |
383 text = gaim_cmd_list(conv); | |
384 for (l = text; l; l = l->next) | |
9213 | 385 if (l->next) |
9597 | 386 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 387 else |
9597 | 388 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 389 } |
390 | |
391 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
392 g_string_free(s, TRUE); | |
393 | |
394 return GAIM_CMD_STATUS_OK; | |
395 } | |
396 | |
4359 | 397 static void |
9374 | 398 send_history_add(GaimConversation *conv, const char *message) |
399 { | |
400 GList *first; | |
401 | |
402 first = g_list_first(conv->send_history); | |
403 | |
404 if (first->data) | |
405 g_free(first->data); | |
406 | |
407 first->data = g_strdup(message); | |
408 | |
409 conv->send_history = g_list_prepend(first, NULL); | |
410 } | |
411 | |
9832 | 412 static gboolean |
413 check_for_and_do_command(GaimConversation *conv) | |
414 { | |
415 GaimGtkConversation *gtkconv; | |
416 char *cmd; | |
417 const char *prefix; | |
418 GaimAccount *account; | |
419 GtkTextIter start; | |
420 | |
421 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
422 account = gaim_conversation_get_account(conv); | |
423 prefix = gaim_gtk_get_cmd_prefix(); | |
424 | |
425 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
426 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
427 | |
428 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
429 && !gtk_text_iter_get_child_anchor(&start)) { | |
430 GaimCmdStatus status; | |
431 char *error, *cmdline, *markup, *send_history; | |
432 GtkTextIter end; | |
433 | |
434 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
435 send_history_add(conv, send_history); | |
436 g_free(send_history); | |
437 | |
438 cmdline = cmd + strlen(prefix); | |
439 | |
440 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
441 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
442 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
443 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
444 g_free(cmd); | |
445 g_free(markup); | |
446 | |
447 switch (status) { | |
448 case GAIM_CMD_STATUS_OK: | |
449 return TRUE; | |
450 case GAIM_CMD_STATUS_NOT_FOUND: | |
451 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
452 gaim_conversation_write(conv, "", _("No such command."), | |
453 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
454 | |
455 return TRUE; | |
456 } | |
457 return FALSE; | |
458 case GAIM_CMD_STATUS_WRONG_ARGS: | |
459 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
460 "to that command."), | |
461 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
462 return TRUE; | |
463 case GAIM_CMD_STATUS_FAILED: | |
464 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
465 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
466 if(error) | |
467 g_free(error); | |
468 return TRUE; | |
469 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 470 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 471 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 472 GAIM_MESSAGE_NO_LOG, time(NULL)); |
473 else | |
10843 | 474 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 475 GAIM_MESSAGE_NO_LOG, time(NULL)); |
476 return TRUE; | |
477 case GAIM_CMD_STATUS_WRONG_PRPL: | |
478 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
479 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
480 return TRUE; | |
481 } | |
482 } | |
483 | |
484 g_free(cmd); | |
485 return FALSE; | |
486 } | |
487 | |
9374 | 488 static void |
10810 | 489 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 490 { |
10810 | 491 GaimConversation *conv = gtkconv->active_conv; |
8655 | 492 GaimAccount *account; |
8677 | 493 GaimConnection *gc; |
12216 | 494 GaimMessageFlags flags = 0; |
8448 | 495 char *buf, *clean; |
4359 | 496 |
8655 | 497 account = gaim_conversation_get_account(conv); |
9130 | 498 |
9471 | 499 if (!gaim_account_is_connected(account)) |
500 return; | |
501 | |
11338 | 502 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 503 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 504 return; |
505 | |
9832 | 506 if (check_for_and_do_command(conv)) { |
507 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
508 return; | |
9130 | 509 } |
510 | |
8442 | 511 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 512 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 513 |
4359 | 514 gtk_widget_grab_focus(gtkconv->entry); |
515 | |
8448 | 516 if (strlen(clean) == 0) { |
517 g_free(clean); | |
4359 | 518 return; |
519 } | |
520 | |
12272 | 521 gaim_idle_touch(); |
522 | |
12216 | 523 /* XXX: is there a better way to tell if the message has images? */ |
524 if (GTK_IMHTML(gtkconv->entry)->im_images != NULL) | |
525 flags |= GAIM_MESSAGE_IMAGES; | |
526 | |
8677 | 527 gc = gaim_account_get_connection(account); |
10665 | 528 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 529 char **bufs; |
530 int i; | |
531 | |
532 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
533 for (i = 0; bufs[i]; i++) { | |
9374 | 534 send_history_add(conv, bufs[i]); |
11338 | 535 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 536 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), bufs[i], flags); |
11338 | 537 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 538 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), bufs[i], flags); |
8677 | 539 } |
540 | |
541 g_strfreev(bufs); | |
542 | |
543 } else { | |
9374 | 544 send_history_add(conv, buf); |
11338 | 545 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 546 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), buf, flags); |
11338 | 547 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 548 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), buf, flags); |
8677 | 549 } |
4359 | 550 |
8677 | 551 g_free(clean); |
4359 | 552 g_free(buf); |
553 | |
8061 | 554 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 555 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 556 } |
557 | |
558 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
559 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 560 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
561 GaimAccount *account; |
4359 | 562 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
563 GaimConversation *conv = gtkconv->active_conv; |
4359 | 564 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
565 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
566 name = gaim_conversation_get_name(conv); |
7879 | 567 |
11338 | 568 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 569 GaimBuddy *b; |
570 | |
571 b = gaim_find_buddy(account, name); | |
572 if (b != NULL) | |
9730 | 573 gaim_gtkdialogs_remove_buddy(b); |
7859 | 574 else if (account != NULL && gaim_account_is_connected(account)) |
575 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 576 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 577 GaimChat *c; |
578 | |
579 c = gaim_blist_find_chat(account, name); | |
580 if (c != NULL) | |
9730 | 581 gaim_gtkdialogs_remove_chat(c); |
7859 | 582 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 583 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 584 } |
4359 | 585 |
586 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
587 } | |
588 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
589 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 590 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
591 GaimConversation *conv = gtkconv->active_conv; |
7975 | 592 GaimPluginProtocolInfo *prpl_info = NULL; |
593 GaimConnection *gc; | |
594 | |
595 if ((gc = gaim_conversation_get_gc(conv))) { | |
596 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
597 | |
598 /* | |
599 * If there are special needs for getting info on users in | |
600 * buddy chat "rooms"... | |
601 */ | |
602 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
603 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
604 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
605 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
606 } |
7975 | 607 else |
608 prpl_info->get_info(gc, who); | |
609 } | |
610 } | |
611 | |
612 | |
4359 | 613 static void |
10810 | 614 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 615 { |
10810 | 616 GaimConversation *conv = gtkconv->active_conv; |
4359 | 617 |
11338 | 618 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 619 serv_get_info(gaim_conversation_get_gc(conv), |
620 gaim_conversation_get_name(conv)); | |
621 | |
622 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 623 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 624 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
625 GaimGtkChatPane *gtkchat; |
4359 | 626 GtkTreeIter iter; |
627 GtkTreeModel *model; | |
628 GtkTreeSelection *sel; | |
9554 | 629 char *name; |
4359 | 630 |
631 gtkchat = gtkconv->u.chat; | |
632 | |
633 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
634 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
635 | |
636 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 637 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 638 else |
639 return; | |
640 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
641 chat_do_info(gtkconv, name); |
9554 | 642 g_free(name); |
4359 | 643 } |
644 } | |
645 | |
646 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
647 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 648 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
649 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
650 GaimAccount *account; |
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 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
653 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
654 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
655 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 656 |
657 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
658 } | |
659 | |
660 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
661 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 662 { |
663 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
664 GaimGtkConversation *gtkconv; |
4359 | 665 |
666 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
667 | |
668 if (resp == GTK_RESPONSE_OK) { | |
669 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
670 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
671 | |
10113 | 672 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 673 return; |
674 | |
675 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
676 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 677 message, buddy); |
678 } | |
679 | |
680 gtk_widget_destroy(invite_dialog); | |
681 invite_dialog = NULL; | |
682 | |
683 g_free(info); | |
684 } | |
685 | |
686 static void | |
9909 | 687 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
688 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
689 { | |
690 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
691 const char *convprotocol; | |
692 | |
693 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
694 | |
695 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
696 { | |
697 GaimBlistNode *node = NULL; | |
698 GaimBuddy *buddy; | |
699 | |
700 memcpy(&node, sd->data, sizeof(node)); | |
701 | |
702 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
703 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
704 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
705 buddy = (GaimBuddy *)node; | |
706 else | |
707 return; | |
708 | |
709 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
710 { | |
711 gaim_notify_error(NULL, NULL, | |
712 _("That buddy is not on the same protocol as this " | |
10843 | 713 "chat."), NULL); |
9909 | 714 } |
715 else | |
716 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
717 | |
718 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
719 } | |
720 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
721 { | |
722 char *protocol = NULL; | |
723 char *username = NULL; | |
724 GaimAccount *account; | |
725 | |
11137 | 726 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 727 &protocol, &username, NULL)) |
728 { | |
729 if (account == NULL) | |
730 { | |
731 gaim_notify_error(NULL, NULL, | |
732 _("You are not currently signed on with an account that " | |
733 "can invite that buddy."), NULL); | |
734 } | |
735 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
736 { | |
737 gaim_notify_error(NULL, NULL, | |
738 _("That buddy is not on the same protocol as this " | |
10843 | 739 "chat."), NULL); |
9909 | 740 } |
741 else | |
742 { | |
743 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
744 } | |
745 } | |
746 | |
747 if (username != NULL) g_free(username); | |
748 if (protocol != NULL) g_free(protocol); | |
749 | |
750 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
751 } | |
752 } | |
753 | |
754 static const GtkTargetEntry dnd_targets[] = | |
755 { | |
756 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
757 {"application/x-im-contact", 0, 1} | |
758 }; | |
759 | |
760 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
761 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 762 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
763 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
764 InviteBuddyInfo *info = NULL; |
4359 | 765 |
766 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
767 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
768 GaimGtkWindow *gtkwin; |
4359 | 769 GtkWidget *label; |
770 GtkWidget *vbox, *hbox; | |
771 GtkWidget *table; | |
772 GtkWidget *img; | |
773 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
774 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 775 GTK_ICON_SIZE_DIALOG); |
4359 | 776 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
777 info = g_new0(InviteBuddyInfo, 1); |
4359 | 778 info->conv = conv; |
779 | |
11581 | 780 gc = gaim_conversation_get_gc(conv); |
781 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 782 |
783 /* Create the new dialog. */ | |
784 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 785 _("Invite Buddy Into Chat Room"), |
7879 | 786 GTK_WINDOW(gtkwin->window), 0, |
787 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
788 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 789 |
790 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 791 GTK_RESPONSE_OK); |
11243 | 792 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 793 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
794 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
795 | |
9909 | 796 info->window = GTK_WIDGET(invite_dialog); |
797 | |
4359 | 798 /* Setup the outside spacing. */ |
799 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
800 | |
11243 | 801 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
802 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 803 |
804 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 805 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 806 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
807 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
808 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
809 | |
810 /* Setup the right vbox. */ | |
811 vbox = gtk_vbox_new(FALSE, 0); | |
812 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
813 | |
814 /* Put our happy label in it. */ | |
815 label = gtk_label_new(_("Please enter the name of the user you wish " | |
816 "to invite, along with an optional invite " | |
817 "message.")); | |
818 gtk_widget_set_size_request(label, 350, -1); | |
819 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
820 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
821 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
822 | |
823 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 824 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 825 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
826 | |
827 /* Setup the table we're going to use to lay stuff out. */ | |
828 table = gtk_table_new(2, 2, FALSE); | |
11243 | 829 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
830 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
831 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 832 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
833 | |
834 /* Now the Buddy label */ | |
835 label = gtk_label_new(NULL); | |
836 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
837 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
838 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
839 | |
840 /* Now the Buddy drop-down entry field. */ | |
841 info->entry = gtk_combo_new(); | |
842 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
843 gtk_entry_set_activates_default( | |
844 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
845 | |
846 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
847 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
848 | |
849 /* Fill in the names. */ | |
850 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
851 generate_invite_user_names(gc)); | |
852 | |
853 | |
854 /* Now the label for "Message" */ | |
855 label = gtk_label_new(NULL); | |
856 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
857 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
858 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
859 | |
860 | |
861 /* And finally, the Message entry field. */ | |
862 info->message = gtk_entry_new(); | |
863 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
864 | |
865 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
866 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
867 | |
868 /* Connect the signals. */ | |
869 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
870 G_CALLBACK(do_invite), info); | |
9909 | 871 /* Setup drag-and-drop */ |
872 gtk_drag_dest_set(info->window, | |
873 GTK_DEST_DEFAULT_MOTION | | |
874 GTK_DEST_DEFAULT_DROP, | |
875 dnd_targets, | |
876 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
877 GDK_ACTION_COPY); | |
878 gtk_drag_dest_set(info->entry, | |
879 GTK_DEST_DEFAULT_MOTION | | |
880 GTK_DEST_DEFAULT_DROP, | |
881 dnd_targets, | |
882 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
883 GDK_ACTION_COPY); | |
884 | |
885 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
886 G_CALLBACK(invite_dnd_recv), info); | |
887 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
888 G_CALLBACK(invite_dnd_recv), info); | |
889 | |
4359 | 890 } |
891 | |
892 gtk_widget_show_all(invite_dialog); | |
893 | |
894 if (info != NULL) | |
895 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
896 } | |
897 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
898 static void |
7748 | 899 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
900 { | |
9714 | 901 gaim_gtkdialogs_im(); |
7748 | 902 } |
903 | |
904 static void | |
9504 | 905 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 906 { |
9504 | 907 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 908 FILE *fp; |
909 const char *name; | |
10849 | 910 gchar *text; |
9489 | 911 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
912 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9504 | 913 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 914 return; |
915 } | |
916 | |
917 name = gaim_conversation_get_name(conv); | |
10849 | 918 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 919 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 920 |
921 text = gtk_imhtml_get_markup( | |
922 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
923 fprintf(fp, "%s", text); | |
924 g_free(text); | |
925 | |
926 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 927 fclose(fp); |
928 } | |
929 | |
10849 | 930 /* |
931 * It would be kinda cool if this gave the option of saving a | |
932 * plaintext v. HTML file. | |
933 */ | |
9489 | 934 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
935 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
936 { |
11581 | 937 GaimGtkWindow *win = data; |
938 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 939 gchar *buf; |
940 | |
941 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 942 |
10849 | 943 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
944 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 945 |
946 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
947 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
948 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
949 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
950 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
951 { |
11581 | 952 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
953 GaimConversation *conv; |
9917 | 954 GaimLogType type; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
955 GaimGtkBuddyList *gtkblist; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
956 GdkCursor *cursor; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
957 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
958 GaimAccount *account; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
959 GSList *buddies; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
960 GSList *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
961 |
11581 | 962 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
963 |
11338 | 964 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 965 type = GAIM_LOG_IM; |
11338 | 966 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 967 type = GAIM_LOG_CHAT; |
968 else | |
969 return; | |
970 | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
971 gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
972 cursor = gdk_cursor_new(GDK_WATCH); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
973 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
974 gdk_window_set_cursor(gtkblist->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
975 gdk_window_set_cursor(win->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
976 gdk_cursor_unref(cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
977 while (gtk_events_pending()) |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
978 gtk_main_iteration(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
979 |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
980 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
981 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
982 |
10845 | 983 buddies = gaim_find_buddies(account, name); |
984 for (cur = buddies; cur != NULL; cur = cur->next) | |
985 { | |
986 GaimBlistNode *node = cur->data; | |
10846 | 987 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 988 { |
989 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
990 g_slist_free(buddies); | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
991 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
992 gdk_window_set_cursor(win->window->window, NULL); |
10845 | 993 return; |
994 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
995 } |
10845 | 996 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
997 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
998 gaim_gtk_log_show(type, name, account); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
999 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1000 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1001 gdk_window_set_cursor(win->window->window, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1002 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1003 |
8974 | 1004 static void |
1005 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
1006 { | |
11581 | 1007 GaimGtkWindow *win = data; |
8974 | 1008 GaimConversation *conv; |
1009 GaimGtkConversation *gtkconv; | |
1010 | |
11581 | 1011 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 1012 gtkconv = GAIM_GTK_CONVERSATION(conv); |
1013 | |
1014 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1015 } | |
1016 | |
7295 | 1017 struct _search { |
1018 GaimGtkConversation *gtkconv; | |
1019 GtkWidget *entry; | |
1020 }; | |
1021 | |
7929 | 1022 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 1023 { |
7929 | 1024 switch (resp) { |
1025 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1026 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1027 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1028 break; |
1029 | |
1030 case GTK_RESPONSE_DELETE_EVENT: | |
1031 case GTK_RESPONSE_CLOSE: | |
1032 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1033 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1034 s->gtkconv->dialogs.search = NULL; | |
1035 g_free(s); | |
1036 break; | |
1037 } | |
7295 | 1038 } |
1039 | |
1040 static void | |
7751 | 1041 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1042 { |
11581 | 1043 GaimGtkWindow *gtkwin = data; |
1044 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1045 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1046 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1047 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1048 GTK_ICON_SIZE_DIALOG); |
7929 | 1049 GtkWidget *label; |
7295 | 1050 struct _search *s; |
1051 | |
7798 | 1052 if (gtkconv->dialogs.search) { |
1053 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1054 return; |
7798 | 1055 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1056 |
7295 | 1057 s = g_malloc(sizeof(struct _search)); |
1058 s->gtkconv = gtkconv; | |
7929 | 1059 |
1060 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1061 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1062 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1063 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1064 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1065 GTK_RESPONSE_OK); |
7929 | 1066 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1067 G_CALLBACK(do_search_cb), s); | |
1068 | |
11243 | 1069 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1070 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1071 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1072 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
|
1073 gtk_container_set_border_width( |
11243 | 1074 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1075 | |
1076 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1077 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1078 hbox); |
7929 | 1079 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1080 | |
1081 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1082 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1083 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1084 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1085 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1086 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1087 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1088 | |
1089 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1090 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1091 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1092 g_signal_connect(G_OBJECT(s->entry), "changed", |
1093 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1094 gtkconv->dialogs.search); | |
1095 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
|
1096 |
7295 | 1097 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1098 gtk_widget_grab_focus(s->entry); |
7295 | 1099 } |
1100 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1101 static void |
9468 | 1102 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1103 { | |
11581 | 1104 GaimGtkWindow *win = data; |
1105 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1106 |
11338 | 1107 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1108 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1109 } | |
1110 | |
1111 } | |
1112 | |
1113 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1114 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1115 { |
11581 | 1116 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1117 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1118 |
11581 | 1119 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
|
1120 |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1121 gaim_gtk_pounce_editor_show(gaim_conversation_get_account(conv), |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1122 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1123 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1124 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1125 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1126 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1127 { |
11581 | 1128 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1129 GaimGtkConversation *gtkconv; |
8756 | 1130 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1131 |
11581 | 1132 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1133 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1134 | |
1135 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1136 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1137 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1138 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1139 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1140 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1141 { |
11581 | 1142 GaimGtkWindow *win = data; |
8756 | 1143 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1144 GaimGtkConversation *gtkconv; |
8756 | 1145 GtkIMHtmlToolbar *toolbar; |
1146 | |
11581 | 1147 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1148 conv = gtkconv->active_conv; | |
8756 | 1149 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1150 | |
1151 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1152 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1153 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1154 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1155 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1156 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1157 { |
11581 | 1158 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1159 GaimConversation *conv; |
7879 | 1160 GaimAccount *account; |
1161 const char *name; | |
1162 | |
11581 | 1163 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1164 account = gaim_conversation_get_account(conv); |
1165 name = gaim_conversation_get_name(conv); | |
1166 | |
11338 | 1167 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1168 GaimBuddy *b; |
1169 | |
1170 b = gaim_find_buddy(account, name); | |
1171 if (b != NULL) | |
9730 | 1172 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1173 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1174 GaimChat *c; |
1175 | |
1176 c = gaim_blist_find_chat(account, name); | |
1177 if (c != NULL) | |
9730 | 1178 gaim_gtkdialogs_alias_chat(c); |
5908
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 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1181 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1182 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1183 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1184 { |
11581 | 1185 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1186 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1187 |
11581 | 1188 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1189 |
10810 | 1190 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1191 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1192 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1193 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1194 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1195 { |
11581 | 1196 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1197 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1198 |
11581 | 1199 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1200 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1201 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1202 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1203 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1204 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1205 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1206 { |
11581 | 1207 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1208 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1209 |
11581 | 1210 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1212 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1216 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 { |
11581 | 1218 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1219 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1220 |
11581 | 1221 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1222 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1223 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1224 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1225 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1226 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1227 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1228 { |
11581 | 1229 GaimGtkWindow *win = data; |
1230 | |
1231 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
|
1232 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1233 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1234 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1235 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1236 { |
11581 | 1237 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1238 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1239 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1240 |
11581 | 1241 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1242 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1243 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1244 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1245 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1246 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
|
1247 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1248 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1249 return; |
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 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1252 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1253 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1254 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1255 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1256 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1257 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1258 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1259 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1260 time(NULL)); |
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 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1263 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1264 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1265 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1266 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1267 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1268 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1269 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1270 /* 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
|
1271 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1272 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1273 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1274 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1275 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1276 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1277 { |
11581 | 1278 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1279 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1280 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1281 |
11581 | 1282 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1283 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1284 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1285 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1286 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1287 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1288 |
10377 | 1289 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1290 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
|
1291 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1292 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1293 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1294 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1295 { |
11581 | 1296 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1297 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1298 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1299 |
11581 | 1300 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1301 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1302 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1303 return; |
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 = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1306 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1307 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1309 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1310 |
7961 | 1311 static void |
9188 | 1312 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1313 { | |
11581 | 1314 GaimGtkWindow *win = data; |
9188 | 1315 GaimConversation *conv; |
1316 GaimGtkConversation *gtkconv; | |
1317 | |
11581 | 1318 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1319 |
1320 if (!conv) | |
1321 return; | |
1322 | |
1323 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1324 | |
12188 | 1325 gaim_prefs_set_bool("/gaim/gtk/conversations/show_timestamps", |
9188 | 1326 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
1327 } | |
1328 | |
1329 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1330 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1331 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1332 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1333 GaimAccount *account; |
1334 GaimConnection *gc; | |
7961 | 1335 GaimPluginProtocolInfo *prpl_info = NULL; |
1336 char *real_who; | |
1337 | |
1338 account = gaim_conversation_get_account(conv); | |
10431 | 1339 g_return_if_fail(account != NULL); |
1340 | |
1341 gc = gaim_account_get_connection(account); | |
1342 g_return_if_fail(gc != NULL); | |
1343 | |
1344 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1345 | |
1346 if (prpl_info && prpl_info->get_cb_real_name) | |
1347 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1348 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1349 else | |
1350 real_who = g_strdup(who); | |
1351 | |
1352 if(!real_who) | |
1353 return; | |
1354 | |
10431 | 1355 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1356 |
1357 g_free(real_who); | |
1358 } | |
1359 | |
1360 static void | |
10810 | 1361 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1362 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1363 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1364 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1365 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1366 GtkTreeSelection *sel; |
9554 | 1367 char *name; |
5908
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 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1370 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1371 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1372 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1373 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1374 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1375 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
|
1376 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1377 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1378 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1379 chat_do_im(gtkconv, name); |
9554 | 1380 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1381 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1382 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1383 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1384 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1385 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1386 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1387 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1388 GaimConvChat *chat; |
11869 | 1389 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1390 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1391 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1392 GtkTreeSelection *sel; |
10504 | 1393 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1394 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1395 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1396 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1397 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1398 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1399 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1401 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1402 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1403 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1404 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1405 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1406 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1407 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1408 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1409 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1410 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1411 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1412 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1413 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1414 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1415 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1416 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1417 |
11869 | 1418 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1419 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1420 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1421 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1422 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1423 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1424 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1425 { |
1426 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1427 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1428 chat_do_im(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1429 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1430 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1431 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1432 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1433 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1434 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1435 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1436 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1437 | |
1438 serv_send_file(gc, who, NULL); | |
1439 } | |
1440 | |
1441 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1442 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
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 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1445 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1446 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1447 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1448 chat_do_info(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1449 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1450 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1451 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1452 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1453 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1454 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1455 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1456 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1457 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1458 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1459 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1460 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1461 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1462 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1463 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1464 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1465 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1466 * 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
|
1467 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1468 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1469 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1470 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1471 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1472 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1473 } |
5908
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 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1476 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1477 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1478 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1479 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1480 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1481 GaimAccount *account; |
6695 | 1482 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1483 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1484 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1485 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1486 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1487 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1488 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1489 if (b != NULL) |
9730 | 1490 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1491 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1492 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
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 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1495 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1496 |
8143 | 1497 static GtkWidget * |
10504 | 1498 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1499 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1500 { | |
1501 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1502 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1503 gboolean is_me = FALSE; |
8143 | 1504 GtkWidget *button; |
1505 | |
1506 /* | |
1507 * If a menu already exists, destroy it before creating a new one, | |
1508 * thus freeing-up the memory it occupied. | |
1509 */ | |
1510 if (menu) | |
1511 gtk_widget_destroy(menu); | |
1512 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1513 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1514 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1515 |
8143 | 1516 menu = gtk_menu_new(); |
1517 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1518 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1519 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1520 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
|
1521 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
|
1522 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1523 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1524 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1525 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1526 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1527 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1528 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
|
1529 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1530 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1531 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
|
1532 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
|
1533 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1534 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1535 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1536 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1537 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1538 } |
9498 | 1539 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1540 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1541 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
|
1542 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1543 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1544 } |
1545 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1546 if (prpl_info->get_cb_away) { |
10221 | 1547 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
|
1548 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1549 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1550 } |
1551 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1552 if (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1553 if (gaim_find_buddy(gc->account, who)) |
10221 | 1554 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
|
1555 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1556 else |
10221 | 1557 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
|
1558 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1559 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1560 } |
1561 | |
1562 return menu; | |
1563 } | |
1564 | |
1565 | |
1566 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1567 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1568 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1569 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1570 GaimPluginProtocolInfo *prpl_info = NULL; |
1571 GaimGtkChatPane *gtkchat; | |
1572 GaimConnection *gc; | |
1573 GaimAccount *account; | |
1574 GtkTreeSelection *sel; | |
1575 GtkTreeIter iter; | |
1576 GtkTreeModel *model; | |
1577 GtkWidget *menu; | |
1578 gchar *who; | |
1579 | |
1580 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1581 gtkchat = gtkconv->u.chat; | |
1582 account = gaim_conversation_get_account(conv); | |
1583 gc = account->gc; | |
1584 | |
1585 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1586 | |
1587 if (gc != NULL) | |
1588 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1589 | |
1590 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1591 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1592 return FALSE; | |
1593 | |
9498 | 1594 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1595 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1596 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1597 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1598 0, GDK_CURRENT_TIME); |
10504 | 1599 g_free(who); |
8143 | 1600 |
1601 return TRUE; | |
1602 } | |
1603 | |
1604 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1605 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1606 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1607 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1608 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1609 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1610 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1611 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1612 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1613 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1614 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1615 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1616 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1617 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1618 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1619 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1620 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1621 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1622 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1623 gc = account->gc; |
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 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1626 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1627 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
|
1628 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1629 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1630 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1631 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1632 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1633 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1634 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1635 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1636 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1637 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1638 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1639 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1640 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
|
1641 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1642 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1643 chat_do_im(gtkconv, who); |
7398 | 1644 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1645 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1646 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1647 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1648 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1649 |
10504 | 1650 g_free(who); |
1651 gtk_tree_path_free(path); | |
1652 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1653 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1654 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1655 |
8133 | 1656 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1657 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1658 { |
10827 | 1659 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1660 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1661 int index, i, total, found = 0; |
8133 | 1662 |
11581 | 1663 win = gtkconv->win; |
1664 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1665 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1666 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1667 /* 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
|
1668 for (i = forward ? index + 1 : index - 1; |
11581 | 1669 !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
|
1670 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1671 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1672 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1673 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1674 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1675 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1676 found = 1; |
8133 | 1677 } |
11252 | 1678 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1679 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1680 /* 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
|
1681 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1682 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1683 (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
|
1684 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1685 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1686 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1687 found = 1; |
8133 | 1688 } |
10827 | 1689 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1690 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1691 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1692 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1693 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1694 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1695 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1696 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1697 } |
11581 | 1698 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1699 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1700 } |
8133 | 1701 } |
1702 | |
10827 | 1703 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1704 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1705 } |
1706 | |
4359 | 1707 static gboolean |
8105 | 1708 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1709 { |
11581 | 1710 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1711 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1712 GaimGtkConversation *gtkconv; |
8105 | 1713 int curconv; |
1714 | |
10810 | 1715 gtkconv = (GaimGtkConversation *)data; |
10849 | 1716 conv = gtkconv->active_conv; |
11581 | 1717 win = gtkconv->win; |
1718 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1719 |
8105 | 1720 /* If CTRL was held down... */ |
1721 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1722 switch (event->keyval) { |
1723 case GDK_Up: | |
1724 if (!conv->send_history) | |
1725 break; | |
1726 | |
1727 if (!conv->send_history->prev) { | |
1728 GtkTextIter start, end; | |
1729 | |
1730 if (conv->send_history->data) | |
1731 g_free(conv->send_history->data); | |
1732 | |
1733 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1734 &start); | |
1735 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1736 | |
1737 conv->send_history->data = | |
8506 | 1738 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1739 } |
8677 | 1740 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1741 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1742 GObject *object; |
8677 | 1743 GtkTextIter iter; |
1744 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1745 |
1746 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1747 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1748 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1749 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1750 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
|
1751 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1752 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1753 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1754 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1755 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
|
1756 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1757 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1758 |
8061 | 1759 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1760 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1761 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1762 0, NULL); |
8677 | 1763 /* this is mainly just a hack so the formatting at the |
1764 * cursor gets picked up. */ | |
1765 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1766 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1767 } |
1768 | |
8105 | 1769 return TRUE; |
4359 | 1770 break; |
1771 | |
1772 case GDK_Down: | |
1773 if (!conv->send_history) | |
1774 break; | |
1775 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1776 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1777 GObject *object; |
8677 | 1778 GtkTextIter iter; |
1779 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1780 |
4359 | 1781 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1782 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1783 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1784 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1785 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
|
1786 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1787 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1788 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1789 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1790 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
|
1791 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1792 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1793 |
8105 | 1794 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1795 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1796 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1797 0, NULL); |
8677 | 1798 /* this is mainly just a hack so the formatting at the |
1799 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1800 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1801 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1802 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1803 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1804 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1805 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1806 } |
4359 | 1807 } |
1808 | |
8105 | 1809 return TRUE; |
4359 | 1810 break; |
8105 | 1811 |
8108 | 1812 case GDK_Page_Down: |
8143 | 1813 case ']': |
11581 | 1814 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1815 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1816 else |
11581 | 1817 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1818 return TRUE; |
1819 break; | |
1820 | |
8108 | 1821 case GDK_Page_Up: |
8143 | 1822 case '[': |
11581 | 1823 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1824 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1825 else |
11581 | 1826 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1827 return TRUE; |
1828 break; | |
1829 | |
8108 | 1830 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1831 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1832 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1833 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1834 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1835 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1836 } |
8108 | 1837 |
1838 return TRUE; | |
1839 break; | |
1840 | |
11252 | 1841 case GDK_comma: |
11581 | 1842 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1843 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1844 curconv - 1); |
1845 break; | |
1846 | |
1847 case GDK_period: | |
11581 | 1848 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1849 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1850 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1851 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1852 #else |
1853 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1854 #endif | |
11252 | 1855 break; |
1856 | |
8105 | 1857 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1858 } |
8758 | 1859 |
8105 | 1860 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1861 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1862 { |
10864 | 1863 if (event->keyval > '0' && event->keyval <= '9') |
1864 { | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1865 guint switchto = event->keyval - '1'; |
11581 | 1866 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1867 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1868 |
1869 return TRUE; | |
1870 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1871 } |
8758 | 1872 |
8105 | 1873 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1874 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1875 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1876 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1877 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1878 case GDK_Tab: |
9605 | 1879 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1880 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1881 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1882 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1883 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1884 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1885 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1886 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1887 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1888 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1889 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1890 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1891 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1892 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1893 } |
4359 | 1894 return FALSE; |
1895 } | |
1896 | |
1897 /* | |
1898 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1899 * 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
|
1900 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1901 * 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
|
1902 * going all the way down to the notebook. I suspect a bug in |
4359 | 1903 * GtkTextView, but I'm not ready to point any fingers yet. |
1904 */ | |
1905 static gboolean | |
1906 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1907 { | |
1908 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1909 /* Right single click */ | |
1910 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1911 | |
1912 return TRUE; | |
1913 } | |
1914 | |
1915 return FALSE; | |
1916 } | |
1917 | |
8173 | 1918 /* |
1919 * If someone tries to type into the conversation backlog of a | |
1920 * conversation window then we yank focus from the conversation backlog | |
1921 * and give it to the text entry box so that people can type | |
1922 * all the live long day and it will get entered into the entry box. | |
1923 */ | |
6057 | 1924 static gboolean |
8105 | 1925 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1926 { |
1927 GaimGtkConversation *gtkconv = data; | |
1928 | |
8237 | 1929 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1930 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1931 (event->keyval == GDK_F10) || |
1932 (event->keyval == GDK_Shift_L) || | |
1933 (event->keyval == GDK_Shift_R) || | |
1934 (event->keyval == GDK_Escape) || | |
8177 | 1935 (event->keyval == GDK_Up) || |
1936 (event->keyval == GDK_Down) || | |
1937 (event->keyval == GDK_Left) || | |
8191 | 1938 (event->keyval == GDK_Right) || |
1939 (event->keyval == GDK_Home) || | |
9297 | 1940 (event->keyval == GDK_End) || |
1941 (event->keyval == GDK_Tab) || | |
1942 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1943 return FALSE; |
1944 | |
1945 if (event->type == GDK_KEY_RELEASE) | |
1946 gtk_widget_grab_focus(gtkconv->entry); | |
1947 | |
1948 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1949 | |
1950 return TRUE; | |
6057 | 1951 } |
1952 | |
4359 | 1953 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1954 gaim_gtkconv_set_active_conversation(GaimConversation *conv) |
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 GaimGtkConversation *gtkconv; |
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 g_return_if_fail(conv != NULL); |
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 gtkconv = GAIM_GTK_CONVERSATION(conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1961 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1962 if (gtkconv->active_conv == conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1963 return; |
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 gaim_conversation_close_logs(gtkconv->active_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 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1968 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1969 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1970 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
|
1971 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1972 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
1973 void |
11604 | 1974 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
1975 { | |
1976 GaimGtkConversation *gtkconv; | |
1977 | |
1978 g_return_if_fail(conv != NULL); | |
1979 | |
1980 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1981 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1982 gaim_gtkconv_set_active_conversation(conv); |
11604 | 1983 |
1984 gray_stuff_out(gtkconv); | |
1985 update_typing_icon(gtkconv); | |
1986 | |
1987 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
1988 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
1989 | |
11671
4ebd27e664c4
[gaim-migrate @ 13957]
Luke Schierer <lschiere@pidgin.im>
parents:
11669
diff
changeset
|
1990 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT); |
11604 | 1991 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
1992 gaim_account_get_protocol_name(conv->account)); | |
1993 } | |
1994 | |
1995 static void | |
4673 | 1996 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1997 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
1998 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 1999 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2000 GaimConversation *conv; |
4359 | 2001 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2002 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2003 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2004 |
11594 | 2005 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 2006 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 2007 } |
2008 | |
2009 static void | |
2010 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
2011 gchar *new_text, gint new_text_length, gpointer user_data) | |
2012 { | |
10810 | 2013 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2014 GaimConversation *conv; | |
2015 | |
2016 g_return_if_fail(gtkconv != NULL); | |
11508 | 2017 |
10810 | 2018 conv = gtkconv->active_conv; |
4359 | 2019 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2020 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2021 return; |
2022 | |
10810 | 2023 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2024 gtk_text_iter_is_end(position))); | |
4359 | 2025 } |
2026 | |
2027 static void | |
2028 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2029 GtkTextIter *end_pos, gpointer user_data) | |
2030 { | |
10810 | 2031 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2032 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2033 GaimConvIm *im; |
4359 | 2034 |
10810 | 2035 g_return_if_fail(gtkconv != NULL); |
11508 | 2036 |
10810 | 2037 conv = gtkconv->active_conv; |
4359 | 2038 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2039 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2040 return; |
2041 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2042 im = GAIM_CONV_IM(conv); |
4359 | 2043 |
2044 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2045 | |
2046 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2047 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2048 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2049 |
2050 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2051 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2052 GAIM_NOT_TYPING); |
4359 | 2053 } |
2054 else { | |
2055 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2056 got_typing_keypress(gtkconv, FALSE); |
4359 | 2057 } |
2058 } | |
2059 | |
8189 | 2060 /************************************************************************** |
2061 * A bunch of buddy icon functions | |
2062 **************************************************************************/ | |
11581 | 2063 GdkPixbuf * |
2064 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2065 { |
10116 | 2066 GaimAccount *account = NULL; |
2067 const char *name = NULL; | |
7143 | 2068 GdkPixbuf *status = NULL; |
2069 | |
10116 | 2070 g_return_val_if_fail(conv != NULL, NULL); |
2071 | |
2072 account = gaim_conversation_get_account(conv); | |
2073 name = gaim_conversation_get_name(conv); | |
2074 | |
2075 g_return_val_if_fail(account != NULL, NULL); | |
2076 g_return_val_if_fail(name != NULL, NULL); | |
2077 | |
11338 | 2078 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2079 GaimBuddy *b = gaim_find_buddy(account, name); |
2080 if (b != NULL) { | |
2081 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2082 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2083 } |
2084 } | |
2085 | |
2086 if (!status) { | |
2087 GdkPixbuf *pixbuf; | |
10884 | 2088 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2089 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2090 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2091 { |
7143 | 2092 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2093 GDK_INTERP_BILINEAR); | |
2094 g_object_unref(pixbuf); | |
2095 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2096 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2097 status = pixbuf; |
7143 | 2098 } |
2099 return status; | |
2100 } | |
2101 | |
8189 | 2102 static void |
2103 update_tab_icon(GaimConversation *conv) | |
2104 { | |
2105 GaimGtkConversation *gtkconv; | |
11581 | 2106 GaimGtkWindow *win; |
8189 | 2107 GaimAccount *account; |
2108 const char *name; | |
2109 GdkPixbuf *status = NULL; | |
2110 | |
10116 | 2111 g_return_if_fail(conv != NULL); |
2112 | |
8189 | 2113 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2114 win = gtkconv->win; |
8189 | 2115 name = gaim_conversation_get_name(conv); |
2116 account = gaim_conversation_get_account(conv); | |
2117 | |
11581 | 2118 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2119 |
10116 | 2120 g_return_if_fail(status != NULL); |
2121 | |
8189 | 2122 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2123 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2124 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2125 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2126 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2127 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2128 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2129 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2130 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2131 { |
11581 | 2132 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2133 | |
2134 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2135 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2136 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2137 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2138 } |
8189 | 2139 } |
2140 | |
2141 static gboolean | |
2142 redraw_icon(gpointer data) | |
2143 { | |
10810 | 2144 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2145 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2146 GaimAccount *account; |
2147 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2148 |
2149 GdkPixbuf *buf; | |
2150 GdkPixbuf *scale; | |
2151 GdkPixmap *pm; | |
2152 GdkBitmap *bm; | |
2153 gint delay; | |
9318 | 2154 int scale_width, scale_height; |
8189 | 2155 |
2156 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2157 account = gaim_conversation_get_account(conv); |
2158 if(account && account->gc) | |
2159 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2160 |
2161 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2162 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2163 | |
10483 | 2164 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2165 NULL, &scale_width, &scale_height); |
2166 | |
2167 /* this code is ugly, and scares me */ | |
8189 | 2168 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2169 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2170 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2171 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2172 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2173 GDK_INTERP_BILINEAR); |
8189 | 2174 |
2175 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2176 g_object_unref(G_OBJECT(scale)); | |
2177 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2178 g_object_unref(G_OBJECT(pm)); | |
2179 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2180 | |
2181 if (bm) | |
2182 g_object_unref(G_OBJECT(bm)); | |
2183 | |
9131 | 2184 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2185 |
2186 if (delay < 100) | |
9131 | 2187 delay = 100; |
2188 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2189 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2190 |
2191 return FALSE; | |
2192 } | |
2193 | |
2194 static void | |
10810 | 2195 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2196 { |
2197 int delay; | |
2198 | |
8228 | 2199 if (gtkconv->u.im->anim == NULL) |
2200 return; | |
2201 | |
8202 | 2202 if (gtkconv->u.im->icon_timer != 0) |
2203 return; | |
2204 | |
8189 | 2205 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2206 return; | |
2207 | |
10639 | 2208 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2209 | |
2210 if (delay < 100) | |
2211 delay = 100; | |
2212 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2213 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2214 } |
2215 | |
2216 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2217 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2218 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2219 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2220 GaimGtkWindow *gtkwin; |
2221 | |
2222 g_return_if_fail(conv != NULL); | |
2223 | |
9887 | 2224 if (gtkconv->u.im->icon_container != NULL) |
2225 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2226 |
2227 if (gtkconv->u.im->anim != NULL) | |
2228 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2229 | |
2230 if (gtkconv->u.im->icon_timer != 0) | |
2231 g_source_remove(gtkconv->u.im->icon_timer); | |
2232 | |
2233 if (gtkconv->u.im->iter != NULL) | |
2234 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2235 | |
2236 gtkconv->u.im->icon_timer = 0; | |
2237 gtkconv->u.im->icon = NULL; | |
2238 gtkconv->u.im->anim = NULL; | |
2239 gtkconv->u.im->iter = NULL; | |
10456 | 2240 gtkconv->u.im->icon_container = NULL; |
9687 | 2241 gtkconv->u.im->show_icon = FALSE; |
10456 | 2242 |
11581 | 2243 gtkwin = gtkconv->win; |
10456 | 2244 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2245 } |
2246 | |
9497 | 2247 static void |
9504 | 2248 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2249 { |
10810 | 2250 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2251 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2252 FILE *fp; |
2253 GaimBuddyIcon *icon; | |
2254 const void *data; | |
2255 size_t len; | |
2256 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2257 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2258 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2259 return; |
2260 } | |
2261 | |
2262 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2263 data = gaim_buddy_icon_get_data(icon, &len); | |
2264 | |
2265 if ((len <= 0) || (data == NULL)) { | |
9504 | 2266 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2267 return; |
2268 } | |
2269 | |
2270 fwrite(data, 1, len, fp); | |
2271 fclose(fp); | |
2272 } | |
2273 | |
2274 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2275 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2276 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2277 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2278 const gchar *ext; |
9497 | 2279 gchar *buf; |
2280 | |
2281 g_return_if_fail(conv != NULL); | |
9504 | 2282 |
10953 | 2283 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2284 if (ext == NULL) | |
2285 ext = "icon"; | |
2286 | |
2287 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2288 |
2289 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2290 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2291 |
2292 g_free(buf); | |
2293 } | |
2294 | |
11581 | 2295 static void |
2296 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2297 { | |
2298 if (gtkconv->u.im->icon_timer != 0) | |
2299 g_source_remove(gtkconv->u.im->icon_timer); | |
2300 | |
2301 gtkconv->u.im->icon_timer = 0; | |
2302 } | |
2303 | |
2304 | |
2305 static void | |
2306 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2307 { | |
2308 gtkconv->u.im->animate = | |
2309 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2310 | |
2311 if (gtkconv->u.im->animate) | |
2312 start_anim(NULL, gtkconv); | |
2313 else | |
2314 stop_anim(NULL, gtkconv); | |
2315 } | |
2316 | |
8189 | 2317 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2318 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2319 { |
2320 static GtkWidget *menu = NULL; | |
2321 GtkWidget *button; | |
2322 | |
2323 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2324 return FALSE; | |
2325 | |
2326 /* | |
2327 * If a menu already exists, destroy it before creating a new one, | |
2328 * thus freeing-up the memory it occupied. | |
2329 */ | |
2330 if (menu != NULL) | |
2331 gtk_widget_destroy(menu); | |
2332 | |
2333 menu = gtk_menu_new(); | |
2334 | |
2335 if (gtkconv->u.im->anim && | |
2336 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2337 { | |
2338 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2339 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2340 gtkconv->u.im->icon_timer); |
2341 } | |
2342 | |
2343 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2344 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2345 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2346 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2347 gtk_widget_show(button); | |
2348 | |
2349 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
|
2350 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2351 0, 0, NULL); |
2352 | |
2353 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2354 | |
2355 return TRUE; | |
2356 } | |
10456 | 2357 |
2358 static void | |
2359 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2360 { | |
11581 | 2361 GaimGtkWindow *win = data; |
10456 | 2362 GaimConversation *conv; |
2363 GaimGtkConversation *gtkconv; | |
2364 gboolean active; | |
2365 | |
11581 | 2366 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2367 |
2368 if (!conv) | |
2369 return; | |
2370 | |
11338 | 2371 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2372 |
2373 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2374 | |
2375 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2376 gtkconv->u.im->show_icon = active; | |
2377 if (active) | |
2378 gaim_gtkconv_update_buddy_icon(conv); | |
2379 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2380 remove_icon(gtkconv); |
10456 | 2381 } |
2382 | |
8189 | 2383 /************************************************************************** |
2384 * End of the bunch of buddy icon functions | |
2385 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2386 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2387 gaim_gtkconv_present_conversation(GaimConversation *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 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2390 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2391 if(gtkconv->win==hidden_convwin) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2392 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2393 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2394 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2395 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2396 gaim_gtkconv_set_active_conversation(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2397 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2398 gaim_gtk_conv_window_raise(gtkconv->win); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2399 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2400 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2401 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2402 GaimConversation * |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2403 gaim_gtk_conversations_get_first_unseen(GaimConversationType type, |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2404 GaimUnseenState min_state) |
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 GList *l; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2407 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2408 if(type==GAIM_CONV_TYPE_IM) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2409 l = gaim_get_ims(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2410 } else if(type==GAIM_CONV_TYPE_CHAT) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2411 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2412 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2413 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2414 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2415 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2416 for(; l!=NULL; l=l->next) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2417 GaimConversation *conv = (GaimConversation*)l->data; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2418 if (GAIM_GTK_CONVERSATION(conv)->unseen_state >= min_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2419 return conv; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2420 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2421 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2422 return NULL; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2423 } |
8189 | 2424 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2425 static void |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2426 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2427 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2428 g_return_if_fail(conv != NULL); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2429 gaim_gtkconv_present_conversation(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2430 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2431 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2432 guint |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2433 gaim_gtk_conversations_fill_unseen_menu(GtkWidget *menu, |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2434 GaimConversationType type, |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2435 GaimUnseenState min_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2436 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2437 GList *l; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2438 guint ret = 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 g_return_val_if_fail(menu != NULL, 0); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2441 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2442 if (type == GAIM_CONV_TYPE_IM) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2443 l = gaim_get_ims(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2444 } else if (type == GAIM_CONV_TYPE_CHAT) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2445 l = gaim_get_chats(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2446 } else { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2447 l = gaim_get_conversations(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2448 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2449 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2450 for (; l != NULL ; l = l->next) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2451 GaimConversation *conv = (GaimConversation*)l->data; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2452 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2453 |
12239 | 2454 if (gtkconv->unseen_state >= min_state && gtkconv->win == hidden_convwin) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2455 GtkWidget *icon = gtk_image_new(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2456 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2457 GtkWidget *item; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2458 gchar *text = g_strdup_printf("%s (%d)", |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2459 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2460 gtkconv->unseen_count); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2461 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2462 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2463 g_object_unref(pbuf); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2464 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2465 item = gtk_image_menu_item_new_with_label(text); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2466 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
|
2467 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
|
2468 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2469 g_free(text); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2470 ret++; |
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 } |
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 return ret; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2475 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2476 |
11581 | 2477 GaimGtkWindow * |
2478 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2479 { | |
2480 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2481 return gtkconv->win; | |
2482 } | |
2483 | |
2484 static GtkItemFactoryEntry menu_items[] = | |
2485 { | |
2486 /* Conversation menu */ | |
2487 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, | |
2488 | |
2489 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2490 0, "<StockItem>", GAIM_STOCK_IM }, | |
2491 | |
2492 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
2493 | |
2494 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2495 "<StockItem>", GTK_STOCK_FIND }, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2496 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", GAIM_STOCK_LOG }, |
11581 | 2497 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2498 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
12240 | 2499 { N_("/Conversation/Clea_r"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
11581 | 2500 |
2501 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, | |
2502 | |
2503 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2504 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2505 0, "<StockItem>", GAIM_STOCK_POUNCE }, |
11581 | 2506 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2507 "<StockItem>", GAIM_STOCK_INFO }, | |
2508 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2509 "<StockItem>", GAIM_STOCK_INVITE }, | |
2510 | |
2511 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
2512 | |
2513 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2514 "<StockItem>", GAIM_STOCK_EDIT }, | |
2515 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2516 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2517 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2518 "<StockItem>", GTK_STOCK_ADD }, | |
2519 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2520 "<StockItem>", GTK_STOCK_REMOVE }, | |
2521 | |
2522 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, | |
2523 | |
2524 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2525 "<StockItem>", GAIM_STOCK_LINK }, | |
2526 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2527 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2528 | |
2529 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, | |
2530 | |
2531 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2532 "<StockItem>", GTK_STOCK_CLOSE }, | |
2533 | |
2534 /* Options */ | |
2535 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, | |
2536 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2537 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
2538 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, | |
2539 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, | |
2540 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>" }, | |
2541 }; | |
2542 | |
2543 static const int menu_item_count = | |
2544 sizeof(menu_items) / sizeof(*menu_items); | |
2545 | |
2546 static char * | |
2547 item_factory_translate_func (const char *path, gpointer func_data) | |
2548 { | |
2549 return _((char *)path); | |
2550 } | |
2551 | |
2552 static GtkWidget * | |
2553 setup_menubar(GaimGtkWindow *win) | |
2554 { | |
2555 GtkAccelGroup *accel_group; | |
2556 | |
2557 accel_group = gtk_accel_group_new (); | |
2558 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2559 g_object_unref(accel_group); | |
2560 | |
2561 win->menu.item_factory = | |
2562 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2563 | |
2564 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2565 item_factory_translate_func, | |
2566 NULL, NULL); | |
2567 | |
2568 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2569 menu_items, win); | |
2570 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2571 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2572 | |
2573 | |
2574 win->menu.menubar = | |
2575 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2576 | |
2577 | |
2578 win->menu.view_log = | |
2579 gtk_item_factory_get_widget(win->menu.item_factory, | |
2580 N_("/Conversation/View Log")); | |
2581 | |
2582 /* --- */ | |
2583 | |
2584 win->menu.send_file = | |
2585 gtk_item_factory_get_widget(win->menu.item_factory, | |
2586 N_("/Conversation/Send File...")); | |
2587 | |
2588 win->menu.add_pounce = | |
2589 gtk_item_factory_get_widget(win->menu.item_factory, | |
2590 N_("/Conversation/Add Buddy Pounce...")); | |
2591 | |
2592 /* --- */ | |
2593 | |
2594 win->menu.get_info = | |
2595 gtk_item_factory_get_widget(win->menu.item_factory, | |
2596 N_("/Conversation/Get Info")); | |
2597 | |
2598 win->menu.invite = | |
2599 gtk_item_factory_get_widget(win->menu.item_factory, | |
2600 N_("/Conversation/Invite...")); | |
2601 | |
2602 /* --- */ | |
2603 | |
2604 win->menu.alias = | |
2605 gtk_item_factory_get_widget(win->menu.item_factory, | |
2606 N_("/Conversation/Alias...")); | |
2607 | |
2608 win->menu.block = | |
2609 gtk_item_factory_get_widget(win->menu.item_factory, | |
2610 N_("/Conversation/Block...")); | |
2611 | |
2612 win->menu.add = | |
2613 gtk_item_factory_get_widget(win->menu.item_factory, | |
2614 N_("/Conversation/Add...")); | |
2615 | |
2616 win->menu.remove = | |
2617 gtk_item_factory_get_widget(win->menu.item_factory, | |
2618 N_("/Conversation/Remove...")); | |
2619 | |
2620 /* --- */ | |
2621 | |
2622 win->menu.insert_link = | |
2623 gtk_item_factory_get_widget(win->menu.item_factory, | |
2624 N_("/Conversation/Insert Link...")); | |
2625 | |
2626 win->menu.insert_image = | |
2627 gtk_item_factory_get_widget(win->menu.item_factory, | |
2628 N_("/Conversation/Insert Image...")); | |
2629 | |
2630 /* --- */ | |
2631 | |
2632 win->menu.logging = | |
2633 gtk_item_factory_get_widget(win->menu.item_factory, | |
2634 N_("/Options/Enable Logging")); | |
2635 win->menu.sounds = | |
2636 gtk_item_factory_get_widget(win->menu.item_factory, | |
2637 N_("/Options/Enable Sounds")); | |
2638 win->menu.show_formatting_toolbar = | |
2639 gtk_item_factory_get_widget(win->menu.item_factory, | |
2640 N_("/Options/Show Formatting Toolbars")); | |
2641 win->menu.show_timestamps = | |
2642 gtk_item_factory_get_widget(win->menu.item_factory, | |
2643 N_("/Options/Show Timestamps")); | |
2644 win->menu.show_icon = | |
2645 gtk_item_factory_get_widget(win->menu.item_factory, | |
2646 N_("/Options/Show Buddy Icon")); | |
2647 | |
2648 | |
2649 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2650 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2651 win->menu.tray); | |
2652 gtk_widget_show(win->menu.tray); | |
2653 | |
2654 gtk_widget_show(win->menu.menubar); | |
2655 | |
2656 return win->menu.menubar; | |
2657 } | |
2658 | |
4359 | 2659 |
2660 /************************************************************************** | |
2661 * Utility functions | |
2662 **************************************************************************/ | |
2663 | |
2664 static void | |
10810 | 2665 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2666 { |
10810 | 2667 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2668 GaimConvIm *im; |
4685 | 2669 |
4359 | 2670 /* |
2671 * 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
|
2672 * send GAIM_TYPED any time soon. |
4359 | 2673 */ |
2674 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2675 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2676 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2677 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2678 gaim_conv_im_stop_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 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2681 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2682 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2683 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2684 |
2685 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2686 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2687 GAIM_TYPING); |
4359 | 2688 |
2689 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2690 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2691 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2692 gaim_conv_im_set_type_again(im, 0); |
4359 | 2693 } |
2694 } | |
2695 | |
4736 | 2696 static void |
10810 | 2697 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2698 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2699 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2700 GaimConvIm *im = NULL; |
10810 | 2701 GaimConversation *conv = gtkconv->active_conv; |
12008 | 2702 char *stock_id, *tooltip; |
11508 | 2703 |
11581 | 2704 gtkwin = gtkconv->win; |
4736 | 2705 |
12008 | 2706 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2707 im = GAIM_CONV_IM(conv); |
4736 | 2708 |
12008 | 2709 if (gtkwin->menu.typing_icon) { |
2710 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2711 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2712 |
12008 | 2713 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2714 return; | |
2715 | |
2716 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2717 stock_id = GAIM_STOCK_TYPING; | |
2718 tooltip = _("User is typing..."); | |
2719 } else { | |
2720 stock_id = GAIM_STOCK_TYPED; | |
2721 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2722 } |
12008 | 2723 |
2724 if (gtkwin->menu.typing_icon == NULL) | |
2725 { | |
2726 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
|
2727 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
|
2728 gtkwin->menu.typing_icon, |
12008 | 2729 tooltip); |
4736 | 2730 } |
12008 | 2731 else |
2732 { | |
2733 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2734 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2735 gtkwin->menu.typing_icon, | |
2736 tooltip); | |
2737 } | |
2738 | |
2739 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2740 } |
2741 | |
4685 | 2742 static gboolean |
11594 | 2743 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2744 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2745 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2746 GaimConversation *conv; |
4359 | 2747 GtkWidget *menu; |
2748 GList *child; | |
11594 | 2749 GaimBuddy *b; |
11581 | 2750 |
2751 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2752 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2753 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2754 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2755 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2756 account = gaim_conversation_get_account(conv); |
11581 | 2757 |
11594 | 2758 if (win->menu.send_to == NULL) |
4685 | 2759 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2760 |
11594 | 2761 if (!(b = gaim_find_buddy(account, conv->name))) |
2762 return FALSE; | |
2763 | |
2764 | |
2765 gtk_widget_show(win->menu.send_to); | |
4359 | 2766 |
2767 menu = gtk_menu_item_get_submenu( | |
11594 | 2768 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2769 |
2770 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2771 child != NULL; | |
2772 child = child->next) { | |
2773 | |
2774 GtkWidget *item = child->data; | |
11594 | 2775 GaimBuddy *item_buddy; |
2776 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2777 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2778 "gaim_buddy_name"); | |
2779 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2780 | |
2781 if (b == item_buddy) { | |
4359 | 2782 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2783 break; | |
2784 } | |
2785 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2786 |
4685 | 2787 return FALSE; |
4359 | 2788 } |
2789 | |
2790 static void | |
11594 | 2791 create_sendto_item(GtkWidget *menu, GtkSizeGroup *sg, GSList **group, GaimBuddy *bud) |
2792 { | |
2793 GaimAccount *account; | |
2794 GtkWidget *box; | |
2795 GtkWidget *label; | |
2796 GtkWidget *image; | |
2797 GtkWidget *menuitem; | |
11625 | 2798 GdkPixbuf *pixbuf; |
11616 | 2799 gchar *text; |
11594 | 2800 |
2801 account = bud->account; | |
2802 | |
2803 /* Create a pixmap for the protocol icon. */ | |
11625 | 2804 pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)bud, GAIM_STATUS_ICON_SMALL); |
11594 | 2805 /* Now convert it to GtkImage */ |
2806 if (pixbuf == NULL) | |
2807 image = gtk_image_new(); | |
2808 else | |
11625 | 2809 image = gtk_image_new_from_pixbuf(pixbuf); |
11594 | 2810 |
2811 gtk_size_group_add_widget(sg, image); | |
2812 | |
2813 g_object_unref(G_OBJECT(pixbuf)); | |
2814 | |
2815 /* Make our menu item */ | |
11616 | 2816 text = g_strdup_printf("%s (%s)", gaim_buddy_get_name(bud), gaim_account_get_username(bud->account)); |
2817 menuitem = gtk_radio_menu_item_new_with_label(*group, text); | |
2818 g_free(text); | |
11594 | 2819 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2820 | |
2821 /* Do some evil, see some evil, speak some evil. */ | |
2822 box = gtk_hbox_new(FALSE, 0); | |
2823 | |
2824 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
2825 g_object_ref(label); | |
2826 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
2827 | |
2828 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
2829 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
2830 | |
2831 g_object_unref(label); | |
2832 | |
2833 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
2834 | |
2835 gtk_widget_show(label); | |
2836 gtk_widget_show(image); | |
2837 gtk_widget_show(box); | |
2838 | |
2839 /* Set our data and callbacks. */ | |
2840 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
2841 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(gaim_buddy_get_name(bud)), g_free); | |
2842 | |
2843 g_signal_connect(G_OBJECT(menuitem), "activate", | |
2844 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2845 | |
2846 gtk_widget_show(menuitem); | |
2847 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2848 } | |
2849 | |
2850 static void | |
2851 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 2852 { |
4359 | 2853 GtkWidget *menu; |
2854 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2855 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 2856 GaimGtkConversation *gtkconv; |
2857 GSList *l, *buds; | |
2858 | |
2859 g_return_if_fail(win != NULL); | |
2860 | |
2861 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
2862 | |
11604 | 2863 g_return_if_fail(gtkconv != NULL); |
2864 | |
11594 | 2865 if (win->menu.send_to != NULL) |
2866 gtk_widget_destroy(win->menu.send_to); | |
2867 | |
4359 | 2868 |
2869 /* Build the Send As menu */ | |
11594 | 2870 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
2871 gtk_widget_show(win->menu.send_to); | |
4359 | 2872 |
2873 menu = gtk_menu_new(); | |
11581 | 2874 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 2875 win->menu.send_to, 2); |
2876 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 2877 |
2878 gtk_widget_show(menu); | |
2879 | |
11604 | 2880 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
2881 buds = gaim_find_buddies(gtkconv->active_conv->account, gtkconv->active_conv->name); | |
2882 for (l = buds; l != NULL; l = l->next) { | |
2883 GaimBuddy *b; | |
2884 GaimBlistNode *node; | |
2885 | |
2886 b = l->data; | |
2887 node = (GaimBlistNode *) gaim_buddy_get_contact(b); | |
2888 | |
2889 for (node = node->child; node != NULL; node = node->next) | |
2890 if (GAIM_BLIST_NODE_IS_BUDDY(node) && gaim_account_is_connected(((GaimBuddy *)node)->account)) | |
2891 create_sendto_item(menu, sg, &group, (GaimBuddy *) node); | |
2892 } | |
2893 | |
2894 g_slist_free(buds); | |
4359 | 2895 } |
2896 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2897 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2898 |
11594 | 2899 gtk_widget_show(win->menu.send_to); |
2900 if (!group) | |
2901 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
2902 update_send_to_selection(win); | |
4359 | 2903 } |
2904 | |
2905 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2906 generate_invite_user_names(GaimConnection *gc) |
4359 | 2907 { |
6695 | 2908 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 2909 static GList *tmp = NULL; |
2910 | |
2911 if (tmp) | |
2912 g_list_free(tmp); | |
2913 | |
2914 tmp = g_list_append(NULL, ""); | |
2915 | |
2916 if (gc != NULL) { | |
4785 | 2917 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2918 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2919 continue; | |
6695 | 2920 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2921 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 2922 continue; |
6695 | 2923 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
2924 GaimBuddy *buddy; | |
2925 | |
2926 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2927 continue; | |
2928 | |
2929 buddy = (GaimBuddy *)bnode; | |
2930 | |
2931 if (buddy->account == gc->account && | |
2932 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 2933 tmp = g_list_insert_sorted(tmp, buddy->name, |
2934 (GCompareFunc)g_utf8_collate); | |
6695 | 2935 } |
4359 | 2936 } |
2937 } | |
2938 } | |
2939 | |
2940 return tmp; | |
2941 } | |
2942 | |
9498 | 2943 static GdkPixbuf * |
9554 | 2944 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 2945 { |
9554 | 2946 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 2947 char *filename; |
10274 | 2948 const char *image = NULL; |
9554 | 2949 |
2950 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 2951 image = "founder.png"; |
9554 | 2952 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 2953 image = "op.png"; |
9554 | 2954 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 2955 image = "halfop.png"; |
9554 | 2956 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 2957 image = "voice.png"; |
9554 | 2958 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 2959 image = "ignored.png"; |
2960 } else { | |
2961 return NULL; | |
9554 | 2962 } |
10274 | 2963 |
2964 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2965 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
2966 g_free(filename); | |
2967 | |
2968 if (!pixbuf) | |
2969 return NULL; | |
2970 | |
2971 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
2972 g_object_unref(pixbuf); | |
2973 | |
2974 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
2975 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 2976 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
2977 g_free(filename); | |
10274 | 2978 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 2979 g_object_unref(pixbuf); |
10274 | 2980 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
2981 g_object_unref(scale2); | |
9498 | 2982 } |
2983 | |
10274 | 2984 return scale; |
9498 | 2985 } |
2986 | |
4359 | 2987 static void |
11869 | 2988 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 2989 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2990 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2991 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2992 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2993 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2994 GaimPluginProtocolInfo *prpl_info; |
4359 | 2995 GtkListStore *ls; |
9498 | 2996 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2997 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2998 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2999 gboolean is_buddy; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3000 GdkColor send_color; |
11508 | 3001 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3002 gdk_color_parse(SEND_COLOR, &send_color); |
4359 | 3003 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3004 chat = GAIM_CONV_CHAT(conv); |
4359 | 3005 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3006 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3007 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3008 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3009 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3010 return; |
4359 | 3011 |
3012 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3013 | |
9554 | 3014 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 3015 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3016 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
|
3017 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3018 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3019 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3020 |
4359 | 3021 gtk_list_store_append(ls, &iter); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3022 gtk_list_store_set(ls, &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3023 CHAT_USERS_ICON_COLUMN, pixbuf, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3024 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3025 CHAT_USERS_NAME_COLUMN, name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3026 CHAT_USERS_FLAGS_COLUMN, flags, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3027 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
|
3028 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3029 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3030 |
9554 | 3031 if (pixbuf) |
3032 g_object_unref(pixbuf); | |
4359 | 3033 } |
3034 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3035 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3036 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
|
3037 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3038 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3039 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3040 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3041 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3042 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3043 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3044 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3045 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3046 if (*most_matched == -1) { |
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 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3049 * on *most_matched is >= 0 |
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 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3052 *partial = 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 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3055 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3056 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3057 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3058 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3059 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3060 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3061 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3062 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3063 (*most_matched)++; |
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 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3066 } |
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 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3069 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3070 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3071 |
9605 | 3072 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3073 tab_complete(GaimConversation *conv) |
4359 | 3074 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3075 GaimGtkConversation *gtkconv; |
4359 | 3076 GtkTextIter cursor, word_start, start_buffer; |
3077 int start; | |
3078 int most_matched = -1; | |
3079 char *entered, *partial = NULL; | |
3080 char *text; | |
8021 | 3081 char *nick_partial; |
9605 | 3082 const char *prefix; |
4359 | 3083 GList *matches = NULL; |
9605 | 3084 gboolean command = FALSE; |
4359 | 3085 |
3086 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3087 | |
3088 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3089 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3090 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3091 | |
3092 word_start = cursor; | |
3093 | |
3094 /* if there's nothing there just return */ | |
3095 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3096 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
|
3097 |
4359 | 3098 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3099 &cursor, FALSE); | |
3100 | |
3101 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3102 start = strlen(text) - 1; | |
3103 | |
8021 | 3104 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3105 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3106 start-=2; |
3107 } | |
4359 | 3108 |
3109 /* find the start of the word that we're tabbing */ | |
3110 while (start >= 0 && text[start] != ' ') { | |
3111 gtk_text_iter_backward_char(&word_start); | |
3112 start--; | |
3113 } | |
3114 | |
9605 | 3115 prefix = gaim_gtk_get_cmd_prefix(); |
3116 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3117 command = TRUE; | |
3118 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3119 } | |
3120 | |
4359 | 3121 g_free(text); |
3122 | |
3123 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3124 &cursor, FALSE); | |
3125 | |
8021 | 3126 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3127 g_free(entered); |
11338 | 3128 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3129 } |
3130 | |
8021 | 3131 nick_partial = g_malloc(strlen(entered)+1); |
3132 | |
9605 | 3133 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3134 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3135 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3136 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3137 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3138 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3139 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3140 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3141 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3142 g_list_free(list); |
11338 | 3143 } 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
|
3144 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3145 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3146 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
|
3147 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3148 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3149 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3150 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3151 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3152 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3153 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3154 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3155 |
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 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3158 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
|
3159 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3160 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3161 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3162 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3163 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3164 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3165 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3166 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3167 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3168 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3169 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3170 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3171 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3172 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3173 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3174 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3175 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3176 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3177 } |
9605 | 3178 } else { |
3179 g_free(nick_partial); | |
3180 g_free(entered); | |
3181 return FALSE; | |
3182 } | |
3183 | |
8021 | 3184 g_free(nick_partial); |
3185 | |
4359 | 3186 /* we're only here if we're doing new style */ |
3187 | |
3188 /* if there weren't any matches, return */ | |
3189 if (!matches) { | |
3190 /* if matches isn't set partials won't be either */ | |
3191 g_free(entered); | |
11338 | 3192 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3193 } |
3194 | |
3195 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3196 | |
3197 if (!matches->next) { | |
3198 /* there was only one match. fill it in. */ | |
3199 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3200 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3201 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3202 | |
3203 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3204 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3205 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3206 g_free(tmp); | |
3207 } | |
3208 else | |
3209 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3210 matches->data, -1); | |
3211 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3212 g_free(matches->data); |
4359 | 3213 matches = g_list_remove(matches, matches->data); |
3214 } | |
3215 else { | |
3216 /* | |
3217 * there were lots of matches, fill in as much as possible | |
3218 * and display all of them | |
3219 */ | |
3220 char *addthis = g_malloc0(1); | |
3221 | |
3222 while (matches) { | |
3223 char *tmp = addthis; | |
3224 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3225 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3226 g_free(matches->data); |
4359 | 3227 matches = g_list_remove(matches, matches->data); |
3228 } | |
3229 | |
6982 | 3230 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3231 time(NULL)); |
3232 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3233 g_free(addthis); | |
3234 } | |
3235 | |
3236 g_free(entered); | |
3237 g_free(partial); | |
9605 | 3238 |
3239 return TRUE; | |
4359 | 3240 } |
3241 | |
10810 | 3242 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3243 { |
3244 GaimPluginProtocolInfo *prpl_info = NULL; | |
3245 GaimConnection *gc; | |
10810 | 3246 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3247 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3248 char *new_topic; |
8858 | 3249 const char *current_topic; |
7971 | 3250 |
3251 gc = gaim_conversation_get_gc(conv); | |
3252 | |
3253 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3254 return; | |
3255 | |
3256 if(prpl_info->set_chat_topic == NULL) | |
3257 return; | |
3258 | |
3259 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3260 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3261 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3262 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3263 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3264 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3265 g_free(new_topic); |
7971 | 3266 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3267 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3268 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3269 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3270 |
8858 | 3271 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3272 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3273 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3274 g_free(new_topic); |
7971 | 3275 } |
3276 | |
9554 | 3277 static gint |
3278 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3279 { | |
3280 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3281 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3282 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3283 gint ret = 0; |
3284 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3285 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3286 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3287 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3288 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3289 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3290 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3291 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3292 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3293 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3294 -1); |
9554 | 3295 |
3296 if (user1 == NULL || user2 == NULL) { | |
3297 if (!(user1 == NULL && user2 == NULL)) | |
3298 ret = (user1 == NULL) ? -1: 1; | |
3299 } else if (f1 != f2) { | |
3300 /* sort more important users first */ | |
3301 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3302 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3303 ret = buddy1 ? -1 : 1; |
9554 | 3304 } else { |
10904 | 3305 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3306 } |
3307 | |
3308 g_free(user1); | |
3309 g_free(user2); | |
3310 | |
3311 return ret; | |
3312 } | |
3313 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3314 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3315 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
|
3316 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3317 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3318 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3319 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3320 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3321 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3322 int f; |
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 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3325 g_return_if_fail(conv != NULL); |
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 /* 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
|
3328 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
|
3329 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3330 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
|
3331 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3332 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3333 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->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 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3336 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 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
|
3339 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3340 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3341 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3342 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3343 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3344 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3345 /* This user is not me, so look into updating the alias. */ |
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 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3348 alias = gaim_buddy_get_contact_alias(buddy2); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3349 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3350 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3351 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3352 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3353 -1); |
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 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3356 break; |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3359 f = gtk_tree_model_iter_next(model, &iter); |
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(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3362 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3363 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3364 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3365 } |
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 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3368 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
|
3369 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3370 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3371 GaimPluginProtocolInfo *prpl_info; |
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 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3374 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3375 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3376 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3377 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3378 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3379 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3382 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3383 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3384 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3385 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3386 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3387 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3388 for(bnode = node->child; bnode; bnode = bnode->next) { |
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 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3391 continue; |
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 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3394 } |
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 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3397 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3398 } |
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 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3401 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3402 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3403 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3404 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3405 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3406 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3407 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3408 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3409 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3410 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3411 /* 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
|
3412 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3413 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3414 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3415 /* 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
|
3416 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
|
3417 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3418 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
|
3419 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3420 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3421 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->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 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3424 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3425 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3426 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
|
3427 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3428 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3429 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
|
3430 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3431 break; |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3434 f = gtk_tree_model_iter_next(model, &iter); |
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(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3437 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3438 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3439 g_free(normalized_name); |
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 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3442 } |
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 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3445 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
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 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3448 } |
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 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3451 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3452 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3453 /* 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
|
3454 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3455 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3456 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3457 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3458 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3459 |
4359 | 3460 static GtkWidget * |
10810 | 3461 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3462 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3463 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3464 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3465 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3466 GaimConnection *gc; |
4359 | 3467 GtkWidget *vpaned, *hpaned; |
10175 | 3468 GtkWidget *vbox, *hbox, *frame; |
4359 | 3469 GtkWidget *lbox, *bbox; |
3470 GtkWidget *label; | |
3471 GtkWidget *list; | |
3472 GtkWidget *button; | |
7949 | 3473 GtkWidget *sw; |
4359 | 3474 GtkListStore *ls; |
3475 GtkCellRenderer *rend; | |
3476 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3477 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3478 GList *focus_chain = NULL; |
4359 | 3479 |
3480 gtkchat = gtkconv->u.chat; | |
3481 gc = gaim_conversation_get_gc(conv); | |
3482 | |
3483 /* Setup the outer pane. */ | |
3484 vpaned = gtk_vpaned_new(); | |
3485 gtk_widget_show(vpaned); | |
3486 | |
3487 /* Setup the top part of the pane. */ | |
11243 | 3488 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3489 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3490 gtk_widget_show(vbox); |
3491 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3492 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3493 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3494 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3495 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3496 { |
11243 | 3497 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3498 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3499 gtk_widget_show(hbox); |
3500 | |
3501 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3502 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3503 gtk_widget_show(label); |
3504 | |
3505 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3506 |
7971 | 3507 if(prpl_info->set_chat_topic == NULL) { |
3508 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3509 } else { | |
3510 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3511 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3512 } |
3513 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3514 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3515 gtk_widget_show(gtkchat->topic_text); |
3516 } | |
3517 | |
3518 /* Setup the horizontal pane. */ | |
3519 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3520 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3521 gtk_widget_show(hpaned); |
3522 | |
10175 | 3523 /* Setup gtkihmtml. */ |
3524 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3525 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3526 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3527 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3528 gtk_widget_show(frame); | |
3529 | |
3530 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3531 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3532 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3533 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3534 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3535 |
4359 | 3536 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3537 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3538 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3539 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3540 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3541 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3542 |
3543 /* Build the right pane. */ | |
11243 | 3544 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3545 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3546 gtk_widget_show(lbox); |
3547 | |
3548 /* Setup the label telling how many people are in the room. */ | |
3549 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3550 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3551 gtk_widget_show(gtkchat->count); | |
3552 | |
3553 /* Setup the list of users. */ | |
7949 | 3554 sw = gtk_scrolled_window_new(NULL, NULL); |
3555 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3556 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3557 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3558 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3559 gtk_widget_show(sw); | |
4359 | 3560 |
9554 | 3561 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
|
3562 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
|
3563 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3564 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3565 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3566 GTK_SORT_ASCENDING); |
3567 | |
3568 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3569 | |
9498 | 3570 rend = gtk_cell_renderer_pixbuf_new(); |
3571 | |
4359 | 3572 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3573 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3574 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3575 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3576 |
3577 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3578 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3579 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3580 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3581 |
9498 | 3582 rend = gtk_cell_renderer_text_new(); |
3583 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3584 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3585 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3586 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3587 NULL); |
4359 | 3588 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3589 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3590 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3591 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3592 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3593 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3594 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3595 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3596 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3597 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3598 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3599 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3600 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3601 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3602 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3603 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3604 #endif |
4359 | 3605 |
3606 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3607 | |
3608 gtk_widget_set_size_request(list, 150, -1); | |
3609 | |
3610 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3611 gtk_widget_show(list); | |
3612 | |
3613 gtkchat->list = list; | |
3614 | |
7949 | 3615 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3616 |
3617 /* Setup the user list toolbar. */ | |
11243 | 3618 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3619 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3620 gtk_widget_show(bbox); | |
3621 | |
3622 /* IM */ | |
10221 | 3623 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3624 GAIM_BUTTON_VERTICAL); |
10500 | 3625 gtkchat->userlist_im = button; |
4359 | 3626 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3627 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
|
3628 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3629 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3630 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3631 |
3632 gtk_widget_show(button); | |
3633 | |
3634 /* Ignore */ | |
3635 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3636 GAIM_BUTTON_VERTICAL); | |
10500 | 3637 gtkchat->userlist_ignore = button; |
4359 | 3638 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3639 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
|
3640 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3641 _("Ignore the user"), NULL); |
4359 | 3642 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3643 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3644 gtk_widget_show(button); |
3645 | |
3646 /* Info */ | |
3647 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3648 GAIM_BUTTON_VERTICAL); | |
10500 | 3649 gtkchat->userlist_info = button; |
4359 | 3650 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3651 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3652 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3653 _("Get the user's information"), NULL); |
4359 | 3654 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3655 G_CALLBACK(info_cb), gtkconv); |
4359 | 3656 |
3657 gtk_widget_show(button); | |
3658 | |
10175 | 3659 /* Setup the bottom half of the conversation window */ |
11243 | 3660 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3661 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3662 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3663 |
11243 | 3664 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3665 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3666 gtk_widget_show(gtkconv->lower_hbox); | |
3667 | |
11243 | 3668 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3669 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3670 gtk_widget_show(vbox); | |
3671 | |
10175 | 3672 /* Setup the toolbar, entry widget and all signals */ |
3673 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3674 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3675 gtk_widget_show(frame); |
3676 | |
9005 | 3677 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3678 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3679 gaim_account_get_protocol_name(conv->account)); |
10175 | 3680 gtk_widget_set_size_request(gtkconv->entry, -1, |
3681 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3682 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3683 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3684 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3685 |
3686 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3687 G_CALLBACK(entry_key_press_cb), gtkconv); |
10115 | 3688 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
10810 | 3689 G_CALLBACK(send_cb), gtkconv); |
4359 | 3690 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3691 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3692 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3693 G_CALLBACK(size_allocate_cb), gtkconv); |
3694 | |
3695 default_formatize(gtkconv); | |
4359 | 3696 |
9080 | 3697 /* |
3698 * Focus for chat windows should be as follows: | |
3699 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3700 * user list buttons -> entry -> buttons at bottom | |
3701 */ | |
9332 | 3702 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3703 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3704 | |
4359 | 3705 return vpaned; |
3706 } | |
3707 | |
3708 static GtkWidget * | |
10810 | 3709 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 3710 { |
10810 | 3711 GaimConversation *conv = gtkconv->active_conv; |
10175 | 3712 GtkWidget *frame; |
4359 | 3713 GtkWidget *paned; |
10175 | 3714 GtkWidget *vbox; |
3715 GtkWidget *vbox2; | |
9080 | 3716 GList *focus_chain = NULL; |
4359 | 3717 |
10175 | 3718 /* Setup the outer pane */ |
4359 | 3719 paned = gtk_vpaned_new(); |
3720 gtk_widget_show(paned); | |
3721 | |
10175 | 3722 /* Setup the top part of the pane */ |
11243 | 3723 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3724 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3725 gtk_widget_show(vbox); |
3726 | |
10175 | 3727 /* Setup the gtkimhtml widget */ |
3728 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3729 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3730 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 3731 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
3732 gtk_widget_show(frame); | |
3733 | |
3734 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3735 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3736 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 3737 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3738 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3739 |
3740 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 3741 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 3742 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 3743 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3744 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 3745 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 3746 |
10175 | 3747 /* Setup the bottom half of the conversation window */ |
11243 | 3748 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3749 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3750 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3751 |
11243 | 3752 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3753 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3754 gtk_widget_show(gtkconv->lower_hbox); | |
3755 | |
11243 | 3756 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3757 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
3758 gtk_widget_show(vbox2); | |
8821 | 3759 |
10175 | 3760 /* Setup the toolbar, entry widget and all signals */ |
3761 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3762 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 3763 gtk_widget_show(frame); |
3764 | |
9005 | 3765 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3766 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3767 gaim_account_get_protocol_name(conv->account)); |
10175 | 3768 gtk_widget_set_size_request(gtkconv->entry, -1, |
3769 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3770 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3771 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3772 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
|
3773 |
4359 | 3774 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 3775 G_CALLBACK(entry_key_press_cb), gtkconv); |
3776 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), gtkconv); | |
4359 | 3777 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3778 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3779 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3780 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3781 |
3782 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 3783 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 3784 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 3785 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 3786 |
8481 | 3787 /* had to move this after the imtoolbar is attached so that the |
3788 * signals get fired to toggle the buttons on the toolbar as well. | |
3789 */ | |
10810 | 3790 default_formatize(gtkconv); |
4359 | 3791 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3792 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3793 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3794 |
8758 | 3795 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 3796 gtkconv->u.im->show_icon = TRUE; |
4359 | 3797 |
9080 | 3798 /* |
3799 * Focus for IM windows should be as follows: | |
10356 | 3800 * Tab title -> conversation scrollback -> entry |
9080 | 3801 */ |
9332 | 3802 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3803 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 3804 |
4359 | 3805 return paned; |
3806 } | |
3807 | |
3808 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3809 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 3810 GtkSelectionData *sd, guint info, guint t, |
3811 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3812 { |
10810 | 3813 GaimConversation *conv = gtkconv->active_conv; |
11581 | 3814 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3815 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3816 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3817 { |
4781 | 3818 GaimBlistNode *n = NULL; |
6695 | 3819 GaimBuddy *b; |
11581 | 3820 GaimGtkConversation *gtkconv = NULL; |
9622 | 3821 |
11812 | 3822 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3823 |
6695 | 3824 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
3825 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
3826 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
3827 b = (GaimBuddy*)n; | |
3828 else | |
4781 | 3829 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3830 |
9622 | 3831 /* |
3832 * If we already have an open conversation with this buddy, then | |
3833 * just move the conv to this window. Otherwise, create a new | |
3834 * conv and add it to this window. | |
3835 */ | |
11338 | 3836 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 3837 if (c != NULL) { |
11581 | 3838 GaimGtkWindow *oldwin; |
3839 gtkconv = GAIM_GTK_CONVERSATION(c); | |
3840 oldwin = gtkconv->win; | |
9622 | 3841 if (oldwin != win) { |
11581 | 3842 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
3843 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 3844 } |
3845 } else { | |
11338 | 3846 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 3847 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3848 if (gtkconv->win != win) |
3849 { | |
3850 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3851 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3852 } | |
9622 | 3853 } |
3854 | |
3855 /* Make this conversation the active conversation */ | |
11581 | 3856 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3857 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3858 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 3859 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3860 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
|
3861 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3862 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3863 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3864 GaimAccount *account; |
11581 | 3865 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3866 |
11137 | 3867 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 3868 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3869 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3870 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3871 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3872 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3873 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3874 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3875 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3876 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3877 { |
11338 | 3878 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 3879 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3880 if (gtkconv->win != win) |
3881 { | |
3882 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3883 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3884 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3885 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3886 } |
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 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3889 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3890 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3891 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3892 } |
9525 | 3893 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 3894 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 3895 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 3896 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 3897 } |
10145 | 3898 else |
3899 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3900 } |
4359 | 3901 |
3902 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3903 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3904 { |
10145 | 3905 GTK_IMHTML_DND_TARGETS, |
3906 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
3907 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3908 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3909 |
10810 | 3910 static GaimGtkConversation * |
3911 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
3912 { | |
3913 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
3914 GaimContact *c; | |
3915 GaimBlistNode *cn; | |
10935 | 3916 |
10810 | 3917 if (!bud) |
3918 return NULL; | |
10935 | 3919 |
10810 | 3920 if (!(c = gaim_buddy_get_contact(bud))) |
3921 return NULL; | |
10935 | 3922 |
10810 | 3923 cn = (GaimBlistNode *)c; |
3924 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
3925 GaimConversation *conv; | |
11338 | 3926 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 3927 if (conv->ui_data) |
3928 return conv->ui_data; | |
3929 } | |
3930 } | |
10935 | 3931 |
10810 | 3932 return NULL; |
3933 } | |
3934 | |
11855 | 3935 static void |
3936 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
3937 { | |
3938 GList *list; | |
3939 | |
3940 g_return_if_fail(bnode); | |
3941 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
3942 | |
3943 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
3944 { | |
3945 GaimGtkWindow *win = list->data; | |
3946 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
3947 | |
3948 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
3949 continue; | |
3950 | |
3951 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); | |
3952 } | |
3953 } | |
3954 | |
11581 | 3955 /************************************************************************** |
3956 * Conversation UI operations | |
3957 **************************************************************************/ | |
3958 void | |
3959 gaim_gtkconv_new(GaimConversation *conv) | |
3960 { | |
3961 GaimGtkConversation *gtkconv; | |
3962 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 3963 GtkWidget *pane = NULL; |
3964 GtkWidget *tab_cont; | |
11581 | 3965 |
3966 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 3967 conv->ui_data = gtkconv; |
3968 if (!g_list_find(gtkconv->convs, conv)) | |
3969 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 3970 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 3971 return; |
4359 | 3972 } |
3973 | |
11581 | 3974 gtkconv = g_new0(GaimGtkConversation, 1); |
3975 conv->ui_data = gtkconv; | |
3976 gtkconv->active_conv = conv; | |
3977 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
3978 | |
3979 /* Setup some initial variables. */ | |
3980 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
3981 gtkconv->tooltips = gtk_tooltips_new(); | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
3982 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
3983 gtkconv->unseen_count = 0; |
11581 | 3984 |
3985 if (conv_type == GAIM_CONV_TYPE_IM) { | |
3986 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
3987 | |
3988 pane = setup_im_pane(gtkconv); | |
3989 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
3990 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
3991 pane = setup_chat_pane(gtkconv); | |
3992 } | |
3993 | |
12101 | 3994 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
3995 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
3996 | |
11581 | 3997 if (pane == NULL) { |
3998 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
3999 g_free(gtkconv->u.chat); | |
4000 else if (conv_type == GAIM_CONV_TYPE_IM) | |
4001 g_free(gtkconv->u.im); | |
4002 | |
4003 g_free(gtkconv); | |
4004 conv->ui_data = NULL; | |
4005 return; | |
10449 | 4006 } |
11581 | 4007 |
4008 /* Setup drag-and-drop */ | |
4009 gtk_drag_dest_set(pane, | |
4010 GTK_DEST_DEFAULT_MOTION | | |
4011 GTK_DEST_DEFAULT_DROP, | |
4012 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4013 GDK_ACTION_COPY); | |
4014 gtk_drag_dest_set(pane, | |
4015 GTK_DEST_DEFAULT_MOTION | | |
4016 GTK_DEST_DEFAULT_DROP, | |
4017 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4018 GDK_ACTION_COPY); | |
4019 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4020 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4021 GDK_ACTION_COPY); | |
4022 | |
4023 gtk_drag_dest_set(gtkconv->entry, 0, | |
4024 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4025 GDK_ACTION_COPY); | |
4026 | |
4027 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
4028 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4029 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
4030 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4031 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
4032 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4033 | |
4034 /* Setup the container for the tab. */ | |
4035 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
4036 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
4037 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
4038 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
4039 gtk_widget_show(pane); | |
4040 | |
4041 gtkconv->make_sound = TRUE; | |
4042 | |
4043 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
4044 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4045 else |
11581 | 4046 gtk_widget_hide(gtkconv->toolbar); |
4047 | |
12188 | 4048 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), |
4049 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4050 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4051 gaim_account_get_protocol_name(conv->account)); |
11581 | 4052 |
4053 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
4054 G_CALLBACK(gtk_widget_grab_focus), | |
4055 gtkconv->entry); | |
4056 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4057 if (conv_type == GAIM_CONV_TYPE_IM) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4058 /* put conv in hidden_convwin if hide_new pref is always */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4059 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
|
4060 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4061 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4062 } |
12188 | 4063 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4064 /* put conv in hidden_convwin if hide_new pref is away and account is away */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4065 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
|
4066 && gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4067 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4068 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4069 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4070 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4071 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4072 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4073 |
11581 | 4074 gaim_gtkconv_placement_place(gtkconv); |
4075 } | |
4076 | |
4359 | 4077 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4078 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4079 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4080 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4081 |
10810 | 4082 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4083 /* Don't destroy ourselves until all our convos are gone */ | |
4084 if (gtkconv->convs) | |
4085 return; | |
11508 | 4086 |
11581 | 4087 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4088 | |
9504 | 4089 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4090 gaim_request_close_with_handle(conv); | |
4359 | 4091 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4092 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4093 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4094 |
11338 | 4095 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4096 if (gtkconv->u.im->icon_timer != 0) |
4097 g_source_remove(gtkconv->u.im->icon_timer); | |
4098 | |
4359 | 4099 if (gtkconv->u.im->anim != NULL) |
4793 | 4100 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4101 |
4102 g_free(gtkconv->u.im); | |
11581 | 4103 } 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
|
4104 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4105 g_free(gtkconv->u.chat); |
4106 } | |
4107 | |
4633 | 4108 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4109 | |
4359 | 4110 g_free(gtkconv); |
4111 } | |
4112 | |
4113 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4114 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4115 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4116 time_t mtime) |
4359 | 4117 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4118 GaimGtkConversation *gtkconv; |
4359 | 4119 |
4120 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4121 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4122 |
6982 | 4123 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4124 } |
4125 | |
4126 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4127 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4128 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4129 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4130 GaimGtkConversation *gtkconv; |
4359 | 4131 |
4132 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4133 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4134 |
10398 | 4135 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4136 |
6982 | 4137 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4138 } |
4139 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4140 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4141 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4142 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4143 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4144 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4145 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4146 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4147 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4148 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4149 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4150 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4151 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4152 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4153 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4154 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4155 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4156 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4157 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4158 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4159 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4160 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4161 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4162 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4163 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4164 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4165 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4166 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4167 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4168 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4169 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4170 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4171 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4172 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4173 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4174 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4175 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4176 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4177 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4178 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4179 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4180 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4181 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4182 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4183 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4184 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4185 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4186 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4187 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4188 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4189 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4190 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4191 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4192 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4193 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4194 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4195 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4196 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4197 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4198 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4199 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4200 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4201 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4202 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4203 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4204 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4205 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4206 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4207 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4208 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4209 buddytag = gtk_text_buffer_create_tag( |
11096 | 4210 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
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 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4213 G_CALLBACK(buddytag_event), conv); |
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 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4216 return buddytag; |
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 |
4359 | 4219 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4220 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4221 const char *message, GaimMessageFlags flags, |
4359 | 4222 time_t mtime) |
4223 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4224 GaimGtkConversation *gtkconv; |
11581 | 4225 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4226 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4227 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4228 GaimPluginProtocolInfo *prpl_info; |
4359 | 4229 int gtk_font_options = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4230 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4231 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4232 int line_count; |
4359 | 4233 char buf2[BUF_LONG]; |
4234 char mdate[64]; | |
4235 char color[10]; | |
4236 char *str; | |
4237 char *with_font_tag; | |
4896 | 4238 char *sml_attrib = NULL; |
6982 | 4239 size_t length = strlen(message) + 1; |
4895 | 4240 |
4359 | 4241 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4242 |
4243 /* Set the active conversation to the one that just messaged us. */ | |
4244 /* 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
|
4245 gaim_gtkconv_set_active_conversation(conv); |
11581 | 4246 |
4359 | 4247 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4248 account = gaim_conversation_get_account(conv); |
11581 | 4249 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4250 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4251 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4252 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4253 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4254 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4255 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4256 /* 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
|
4257 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4258 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4259 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4260 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4261 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4262 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4263 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4264 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4265 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4266 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4267 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4268 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4269 |
8677 | 4270 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
4271 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
4272 | |
5133 | 4273 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4274 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4275 else | |
4276 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4277 |
4896 | 4278 if(gc) |
9699 | 4279 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4280 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4281 |
10503 | 4282 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4283 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4284 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4285 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4286 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4287 |
7956 | 4288 /* this is gonna crash one day, I can feel it. */ |
4289 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4290 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4291 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4292 } |
4359 | 4293 |
10737 | 4294 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4295 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4296 g_snprintf(buf2, sizeof(buf2), |
8690 | 4297 "<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
|
4298 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4299 |
8962 | 4300 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 4301 |
8722 | 4302 } else if (flags & GAIM_MESSAGE_ERROR) { |
4303 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4304 "<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
|
4305 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4306 |
8962 | 4307 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
4308 | |
7431 | 4309 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4310 g_snprintf(buf2, BUF_LONG, |
8690 | 4311 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4312 sml_attrib ? sml_attrib : "", message); |
7440 | 4313 |
10884 | 4314 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
10346 | 4315 } else if (flags & GAIM_MESSAGE_RAW) { |
10348 | 4316 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); |
10346 | 4317 } else { |
4895 | 4318 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4319 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
|
4320 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4321 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4322 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
|
4323 int tag_end_offset = 0; |
7440 | 4324 |
6621 | 4325 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4326 str = g_malloc(1024); |
7440 | 4327 |
4359 | 4328 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4329 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4330 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4331 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4332 tag_start_offset += 3; |
4359 | 4333 } |
4334 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4335 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4336 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4337 tag_end_offset = 2; |
4359 | 4338 strcpy(color, "#00FF00"); |
4339 } | |
7440 | 4340 } |
4359 | 4341 else { |
10504 | 4342 if (gaim_message_meify(new_message, -1)) { |
4359 | 4343 str = g_malloc(1024); |
7440 | 4344 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4345 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4346 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
|
4347 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4348 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4349 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4350 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4351 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4352 } |
7440 | 4353 |
6621 | 4354 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4355 strcpy(color, "#AF7F00"); |
4356 else | |
4357 strcpy(color, "#062585"); | |
4358 } | |
4359 else { | |
4360 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4361 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4362 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
|
4363 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4364 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4365 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4366 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4367 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4368 } |
6621 | 4369 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4370 strcpy(color, "#AF7F00"); |
6621 | 4371 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4372 if (flags & GAIM_MESSAGE_COLORIZE) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4373 GdkColor *col = get_nick_color(gtkconv, alias); |
10346 | 4374 |
10108 | 4375 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4376 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4377 } else |
7854 | 4378 strcpy(color, RECV_COLOR); |
4359 | 4379 } |
6621 | 4380 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4381 strcpy(color, SEND_COLOR); |
10892 | 4382 else { |
4383 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4384 strcpy(color, "#000000"); | |
4385 } | |
4359 | 4386 } |
4387 } | |
10892 | 4388 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4389 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4390 g_free(alias_escaped); |
11508 | 4391 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4392 /* 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
|
4393 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4394 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4395 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4396 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4397 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4398 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4399 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4400 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4401 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4402 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4403 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4404 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4405 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4406 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4407 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4408 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4409 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4410 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4411 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4412 /* 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
|
4413 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4414 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4415 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4416 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4417 } |
7440 | 4418 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4419 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4420 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4421 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4422 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4423 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4424 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4425 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4426 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4427 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4428 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4429 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4430 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4431 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4432 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4433 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4434 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4435 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4436 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4437 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4438 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4439 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4440 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4441 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4442 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4443 |
4359 | 4444 g_free(str); |
4445 | |
4895 | 4446 if(gc){ |
4896 | 4447 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4448 char *post = "</font>"; |
4449 int pre_len = strlen(pre); | |
4450 int post_len = strlen(post); | |
7440 | 4451 |
4895 | 4452 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4453 |
4895 | 4454 strcpy(with_font_tag, pre); |
4455 memcpy(with_font_tag + pre_len, new_message, length); | |
4456 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4457 |
4895 | 4458 length += pre_len + post_len; |
4459 g_free(pre); | |
4460 } | |
4608 | 4461 else |
4895 | 4462 with_font_tag = g_memdup(new_message, length); |
7440 | 4463 |
8962 | 4464 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
4465 with_font_tag, gtk_font_options); | |
7440 | 4466 |
4467 g_free(with_font_tag); | |
7447 | 4468 g_free(new_message); |
7440 | 4469 } |
4470 | |
5012 | 4471 if(sml_attrib) |
4472 g_free(sml_attrib); | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4473 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4474 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4475 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4476 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4477 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4478 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4479 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4480 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4481 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4482 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4483 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4484 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
|
4485 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4486 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4487 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4488 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4489 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4490 } |
4359 | 4491 } |
4492 | |
4493 static void | |
11869 | 4494 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
|
4495 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4496 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4497 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4498 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4499 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4500 GList *ll; |
11869 | 4501 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4502 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4503 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4504 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4505 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4506 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4507 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4508 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4509 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
|
4510 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4511 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4512 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4513 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4514 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4515 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4516 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4517 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4518 l = users; |
11869 | 4519 ll = flags; |
4520 lll = aliases; | |
4521 while (l != NULL && ll != NULL && lll != NULL) { | |
4522 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
|
4523 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4524 ll = ll->next; |
11869 | 4525 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4526 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4527 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4528 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4529 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4530 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
|
4531 const char *new_name, const char *new_alias) |
4359 | 4532 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4533 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4534 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4535 GaimGtkChatPane *gtkchat; |
11869 | 4536 GaimConvChatBuddyFlags flags; |
4359 | 4537 GtkTreeIter iter; |
4538 GtkTreeModel *model; | |
4539 int f = 1; | |
4540 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4541 chat = GAIM_CONV_CHAT(conv); |
4359 | 4542 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4543 gtkchat = gtkconv->u.chat; | |
4544 | |
9554 | 4545 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4546 | |
4547 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4548 return; | |
4549 | |
4550 while (f != 0) { | |
4551 char *val; | |
4552 | |
11869 | 4553 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4554 |
4555 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4556 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4557 g_free(val); | |
4359 | 4558 break; |
4559 } | |
9554 | 4560 |
4561 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4562 | |
4563 g_free(val); | |
4359 | 4564 } |
4565 | |
9554 | 4566 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4567 return; |
4568 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4569 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4570 |
11869 | 4571 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4572 } |
4573 | |
4574 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4575 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 4576 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4577 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4578 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4579 GaimGtkChatPane *gtkchat; |
4359 | 4580 GtkTreeIter iter; |
4581 GtkTreeModel *model; | |
4582 char tmp[BUF_LONG]; | |
4583 int num_users; | |
4584 int f = 1; | |
4585 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4586 chat = GAIM_CONV_CHAT(conv); |
4359 | 4587 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4588 gtkchat = gtkconv->u.chat; | |
4589 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4590 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
|
4591 |
9554 | 4592 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4593 | |
4594 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4595 return; | |
4596 | |
4597 while (f != 0) { | |
4598 char *val; | |
4599 | |
4600 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4601 | |
4602 if (!gaim_utf8_strcasecmp(user, val)) { | |
4603 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4604 g_free(val); | |
4359 | 4605 break; |
4606 } | |
9554 | 4607 |
4608 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4609 | |
4610 g_free(val); | |
4359 | 4611 } |
4612 | |
9554 | 4613 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 4614 return; |
4615 | |
4616 g_snprintf(tmp, sizeof(tmp), | |
9554 | 4617 ngettext("%d person in room", "%d people in room", |
4618 num_users), num_users); | |
4359 | 4619 |
4620 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4621 | |
4622 } | |
4623 | |
4624 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4625 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4626 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4627 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4628 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4629 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4630 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4631 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4632 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4633 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4634 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4635 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4636 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4637 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4638 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4639 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4640 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4641 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
|
4642 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4643 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4644 for (l = users; l != NULL; l = l->next) { |
9554 | 4645 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4646 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4647 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4648 continue; |
4649 | |
4650 do { | |
4651 char *val; | |
4652 | |
4653 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4654 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4655 | |
9696 | 4656 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4657 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4658 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4659 #else |
4660 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4661 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4662 #endif | |
4663 } | |
9554 | 4664 else |
4665 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4666 | |
4667 g_free(val); | |
4668 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4669 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4670 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4671 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4672 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4673 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4674 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4675 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4676 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4677 |
9554 | 4678 static void |
4679 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4680 { | |
4681 GaimConvChat *chat; | |
11869 | 4682 GaimConvChatBuddyFlags flags; |
9554 | 4683 GaimGtkConversation *gtkconv; |
4684 GaimGtkChatPane *gtkchat; | |
4685 GtkTreeIter iter; | |
4686 GtkTreeModel *model; | |
4687 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4688 char *alias = NULL; |
9554 | 4689 |
4690 chat = GAIM_CONV_CHAT(conv); | |
4691 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4692 gtkchat = gtkconv->u.chat; | |
4693 | |
4694 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4695 | |
4696 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4697 return; | |
4698 | |
4699 while (f != 0) { | |
4700 char *val; | |
4701 | |
4702 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4703 | |
4704 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4705 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4706 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4707 g_free(val); | |
4708 break; | |
4709 } | |
4710 | |
4711 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4712 | |
4713 g_free(val); | |
4714 } | |
4715 | |
4716 if (!gaim_conv_chat_find_user(chat, user)) | |
4717 return; | |
4718 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4719 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4720 |
11869 | 4721 flags = gaim_conv_chat_user_get_flags(chat, user); |
4722 | |
4723 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4724 g_free(alias); |
9554 | 4725 } |
4726 | |
11581 | 4727 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4728 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4729 { |
11581 | 4730 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4731 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4732 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4733 |
11581 | 4734 win = gtkconv->win; |
4735 | |
4736 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
|
4737 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4738 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4739 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4740 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4741 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4742 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4743 |
10526 | 4744 static gboolean |
4745 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
4746 { | |
4747 GaimGtkConversation *gtkconv; | |
4748 GtkIMHtmlSmiley *smiley; | |
4749 GdkPixbufLoader *loader; | |
11525 | 4750 struct smiley_list *list; |
4751 const char *sml = NULL, *conv_sml; | |
4752 | |
4753 if (!conv || !smile || !*smile) { | |
10526 | 4754 return FALSE; |
4755 } | |
4756 | |
11525 | 4757 /* If smileys are off, return false */ |
4758 if (gaim_gtkthemes_smileys_disabled()) | |
4759 return FALSE; | |
4760 | |
4761 /* If possible add this smiley to the current theme. | |
4762 * The addition is only temporary: custom smilies aren't saved to disk. */ | |
4763 conv_sml = gaim_account_get_protocol_name(conv->account); | |
10526 | 4764 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11525 | 4765 |
4766 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | |
4767 if (!strcmp(list->sml, conv_sml)) { | |
4768 sml = list->sml; | |
4769 break; | |
4770 } | |
4771 } | |
4772 | |
10526 | 4773 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
4774 | |
4775 if (smiley) { | |
11525 | 4776 |
4777 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
4778 return FALSE; | |
4779 } | |
4780 | |
4781 /* Close the old GdkPixbufAnimation, then create a new one for | |
4782 * the smiley we are about to receive */ | |
4783 g_object_unref(G_OBJECT(smiley->icon)); | |
4784 | |
4785 smiley->loader = gdk_pixbuf_loader_new(); | |
4786 smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); | |
4787 if (smiley->icon) | |
4788 g_object_ref(G_OBJECT(smiley->icon)); | |
4789 | |
4790 /* A custom smiley is already associated */ | |
4791 return TRUE; | |
10526 | 4792 } |
4793 | |
4794 loader = gdk_pixbuf_loader_new(); | |
4795 | |
4796 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
4797 /* 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
|
4798 GtkIMHtmlSmiley by opaque */ |
10526 | 4799 smiley = g_new0(GtkIMHtmlSmiley, 1); |
4800 smiley->file = NULL; | |
4801 smiley->smile = g_strdup(smile); | |
4802 smiley->loader = loader; | |
11525 | 4803 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 4804 |
4805 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
4806 if (smiley->icon) | |
4807 g_object_ref(G_OBJECT(smiley->icon)); | |
4808 | |
11525 | 4809 |
10526 | 4810 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); |
10537 | 4811 |
10526 | 4812 return TRUE; |
4813 } | |
4814 | |
10537 | 4815 static void |
10526 | 4816 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 4817 const guchar *data, gsize size) |
10526 | 4818 { |
4819 GaimGtkConversation *gtkconv; | |
4820 GtkIMHtmlSmiley *smiley; | |
10537 | 4821 GdkPixbufLoader *loader; |
10526 | 4822 const char *sml; |
4823 | |
4824 sml = gaim_account_get_protocol_name(conv->account); | |
4825 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4826 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4827 | |
10537 | 4828 if (!smiley) |
10526 | 4829 return; |
10537 | 4830 |
10526 | 4831 loader = smiley->loader; |
10537 | 4832 if (!loader) |
10526 | 4833 return; |
4834 | |
4835 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
4836 } | |
4837 | |
4838 static void | |
4839 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
4840 { | |
4841 GaimGtkConversation *gtkconv; | |
4842 GtkIMHtmlSmiley *smiley; | |
4843 GdkPixbufLoader *loader; | |
4844 const char *sml; | |
11525 | 4845 GtkWidget *icon = NULL; |
4846 GtkTextChildAnchor *anchor = NULL; | |
4847 GtkTextIter end; | |
4848 GtkIMHtml *imhtml; | |
4849 GSList *current = NULL; | |
10526 | 4850 |
4851 g_return_if_fail(conv != NULL); | |
4852 g_return_if_fail(smile != NULL); | |
4853 | |
4854 sml = gaim_account_get_protocol_name(conv->account); | |
4855 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4856 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4857 | |
10537 | 4858 if (!smiley) |
10526 | 4859 return; |
4860 | |
4861 loader = smiley->loader; | |
4862 | |
10537 | 4863 if (!loader) |
10526 | 4864 return; |
10537 | 4865 |
11525 | 4866 smiley->icon = gdk_pixbuf_loader_get_animation(loader); |
4867 if (smiley->icon) | |
4868 g_object_ref(G_OBJECT(smiley->icon)); | |
4869 | |
4870 for (current = smiley->anchors; current != NULL; current = g_slist_next(current)) { | |
4871 | |
4872 icon = gtk_image_new_from_animation(smiley->icon); | |
4873 | |
4874 if (icon) { | |
12047 | 4875 gtk_widget_show(icon); |
4876 | |
11525 | 4877 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
4878 | |
4879 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smile)), g_free); | |
4880 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smile), g_free); | |
4881 | |
4882 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(gtkconv->imhtml), icon, anchor); | |
4883 } | |
4884 | |
4885 } | |
4886 | |
4887 g_slist_free(smiley->anchors); | |
4888 smiley->anchors = NULL; | |
4889 | |
4890 /* Scroll to the end of the widget in case the smiley height was big... */ | |
4891 /* FIXME: need to test this actually works, previous dealings with scrolling | |
4892 * makes me question it */ | |
4893 imhtml = GTK_IMHTML(gtkconv->imhtml); | |
4894 gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(imhtml->text_buffer), &end); | |
4895 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &end, 0, TRUE, 0, 0); | |
4896 | |
10526 | 4897 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
4898 | |
4899 gdk_pixbuf_loader_close(loader, NULL); | |
4900 g_object_unref(G_OBJECT(loader)); | |
4901 smiley->loader = NULL; | |
4902 } | |
4903 | |
11581 | 4904 /* |
4905 * Makes sure all the menu items and all the buttons are hidden/shown and | |
4906 * sensitive/insensitive. This is called after changing tabs and when an | |
4907 * account signs on or off. | |
4908 */ | |
4909 static void | |
4910 gray_stuff_out(GaimGtkConversation *gtkconv) | |
4911 { | |
4912 GaimGtkWindow *win; | |
4913 GaimConversation *conv = gtkconv->active_conv; | |
4914 GaimConnection *gc; | |
4915 GaimPluginProtocolInfo *prpl_info = NULL; | |
4916 GdkPixbuf *window_icon = NULL; | |
4917 GtkIMHtmlButtons buttons; | |
4918 GaimAccount *account; | |
4919 | |
4920 win = gaim_gtkconv_get_window(gtkconv); | |
4921 gc = gaim_conversation_get_gc(conv); | |
4922 account = gaim_conversation_get_account(conv); | |
4923 | |
4924 if (gc != NULL) | |
4925 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
4926 | |
11594 | 4927 if (win->menu.send_to != NULL) |
11734 | 4928 update_send_to_selection(win); |
11581 | 4929 |
4930 /* | |
4931 * Handle hiding and showing stuff based on what type of conv this is. | |
4932 * Stuff that Gaim IMs support in general should be shown for IM | |
4933 * conversations. Stuff that Gaim chats support in general should be | |
4934 * shown for chat conversations. It doesn't matter whether the PRPL | |
4935 * supports it or not--that only affects if the button or menu item | |
4936 * is sensitive or not. | |
4937 */ | |
4938 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
4939 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
4940 | |
4941 /* Deal with menu items */ | |
4942 gtk_widget_show(win->menu.view_log); | |
4943 gtk_widget_show(win->menu.send_file); | |
4944 gtk_widget_show(win->menu.add_pounce); | |
4945 gtk_widget_show(win->menu.get_info); | |
4946 gtk_widget_hide(win->menu.invite); | |
4947 gtk_widget_show(win->menu.alias); | |
4948 gtk_widget_show(win->menu.block); | |
4949 | |
4950 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
4951 gtk_widget_show(win->menu.add); | |
4952 gtk_widget_hide(win->menu.remove); | |
4953 } else { | |
4954 gtk_widget_show(win->menu.remove); | |
4955 gtk_widget_hide(win->menu.add); | |
4956 } | |
4957 | |
4958 gtk_widget_show(win->menu.insert_link); | |
4959 gtk_widget_show(win->menu.insert_image); | |
4960 gtk_widget_show(win->menu.show_icon); | |
4961 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
4962 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
4963 | |
4964 /* Deal with menu items */ | |
4965 gtk_widget_show(win->menu.view_log); | |
4966 gtk_widget_hide(win->menu.send_file); | |
4967 gtk_widget_hide(win->menu.add_pounce); | |
4968 gtk_widget_hide(win->menu.get_info); | |
4969 gtk_widget_show(win->menu.invite); | |
4970 gtk_widget_show(win->menu.alias); | |
4971 gtk_widget_hide(win->menu.block); | |
4972 gtk_widget_hide(win->menu.show_icon); | |
4973 | |
4974 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
4975 /* If the chat is NOT in the buddy list */ | |
4976 gtk_widget_show(win->menu.add); | |
4977 gtk_widget_hide(win->menu.remove); | |
4978 } else { | |
4979 /* If the chat IS in the buddy list */ | |
4980 gtk_widget_hide(win->menu.add); | |
4981 gtk_widget_show(win->menu.remove); | |
4982 } | |
4983 | |
4984 gtk_widget_show(win->menu.insert_link); | |
4985 gtk_widget_hide(win->menu.insert_image); | |
4986 } | |
4987 | |
4988 /* | |
4989 * Handle graying stuff out based on whether an account is connected | |
4990 * and what features that account supports. | |
4991 */ | |
4992 if ((gc != NULL) && | |
12012 | 4993 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
4994 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
4995 { | |
11581 | 4996 /* Account is online */ |
4997 /* Deal with the toolbar */ | |
12012 | 4998 if (conv->features & GAIM_CONNECTION_HTML) |
4999 { | |
5000 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
5001 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
5002 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
5003 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
5004 { | |
5005 buttons &= ~GTK_IMHTML_GROW; | |
5006 buttons &= ~GTK_IMHTML_SHRINK; | |
5007 } | |
5008 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
5009 buttons &= ~GTK_IMHTML_LINKDESC; | |
5010 } else { | |
12216 | 5011 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
12012 | 5012 } |
12216 | 5013 |
5014 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
5015 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
5016 buttons &= ~GTK_IMHTML_IMAGE; | |
5017 | |
12012 | 5018 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); |
5019 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 5020 |
5021 /* Deal with menu items */ | |
12012 | 5022 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5023 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5024 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
5025 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
5026 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
5027 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 5028 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 5029 |
5030 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
5031 { | |
5032 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
5033 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
5034 gtk_widget_set_sensitive(win->menu.send_file, | |
5035 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
5036 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
5037 gtk_widget_set_sensitive(win->menu.alias, | |
5038 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
5039 } | |
5040 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5041 { | |
5042 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
5043 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
5044 gtk_widget_set_sensitive(win->menu.alias, | |
5045 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
5046 } | |
11581 | 5047 |
5048 /* Deal with chat userlist buttons */ | |
12012 | 5049 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5050 { | |
5051 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
5052 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
5053 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
5054 } | |
5055 } else { | |
11581 | 5056 /* Account is offline */ |
5057 /* Or it's a chat that we've left. */ | |
5058 | |
5059 /* Then deal with menu items */ | |
12012 | 5060 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5061 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
5062 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5063 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
5064 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
5065 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
5066 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
5067 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
5068 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
5069 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
5070 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 5071 |
5072 /* Deal with chat userlist buttons */ | |
12012 | 5073 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5074 { | |
5075 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5076 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5077 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5078 } | |
5079 } | |
11581 | 5080 |
5081 /* | |
5082 * Update the window's icon | |
5083 */ | |
12171 | 5084 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5085 { |
12171 | 5086 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
5087 (gtkconv->u.im->anim)) | |
5088 { | |
5089 window_icon = | |
5090 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5091 g_object_ref(window_icon); | |
5092 } else { | |
5093 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5094 } | |
5095 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5096 if (window_icon != NULL) | |
5097 g_object_unref(G_OBJECT(window_icon)); | |
5098 } | |
11581 | 5099 } |
5100 | |
10526 | 5101 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5102 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5103 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 5104 { |
11581 | 5105 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5106 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5107 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5108 GaimConvChat *chat; |
4359 | 5109 |
10116 | 5110 g_return_if_fail(conv != NULL); |
5111 | |
4359 | 5112 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5113 win = gtkconv->win; |
10810 | 5114 conv = gtkconv->active_conv; /* Gross hack */ |
11581 | 5115 /* Maybe we should just ignore it if conv != gtkconv->active_conv, |
5116 * instead of the gross hack? | |
5117 */ | |
4359 | 5118 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5119 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5120 { |
4359 | 5121 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5122 |
11338 | 5123 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5124 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5125 |
4359 | 5126 gaim_gtkconv_update_buttons_by_protocol(conv); |
5127 | |
11734 | 5128 update_send_to_selection(win); |
4359 | 5129 |
11525 | 5130 gaim_gtkthemes_smiley_themeize(gtkconv->imhtml); |
6394 | 5131 |
6395 | 5132 update_tab_icon(conv); |
4359 | 5133 } |
5134 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5135 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5136 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5137 { |
9472 | 5138 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5139 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5140 GaimAccount *account = gaim_conversation_get_account(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5141 /* 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
|
5142 char style[51]; |
4736 | 5143 |
11338 | 5144 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5145 im = GAIM_CONV_IM(conv); |
4359 | 5146 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5147 if (!gaim_account_is_connected(account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5148 || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5149 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5150 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5151 else | |
5152 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5153 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5154 *style = '\0'; |
4359 | 5155 |
5156 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5157 gtk_widget_realize(gtkconv->tab_label); | |
5158 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5159 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5160 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5161 { |
11759 | 5162 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5163 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5164 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5165 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5166 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5167 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5168 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5169 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5170 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5171 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5172 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5173 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5174 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5175 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5176 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5177 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5178 { |
11758 | 5179 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5180 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5181 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5182 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5183 { |
8536 | 5184 char *html_title,*label; |
5185 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5186 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5187 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5188 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5189 style, html_title); |
8536 | 5190 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5191 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5192 g_free(label); |
4359 | 5193 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5194 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5195 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5196 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5197 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5198 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5199 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5200 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5201 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5202 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5203 gtk_window_set_title(GTK_WINDOW(win->window), title); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5204 } |
9472 | 5205 |
5206 g_free(title); | |
4359 | 5207 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5208 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5209 { |
7154 | 5210 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5211 chat = GAIM_CONV_CHAT(conv); |
4359 | 5212 gtkchat = gtkconv->u.chat; |
5213 | |
7154 | 5214 topic = gaim_conv_chat_get_topic(chat); |
5215 | |
9554 | 5216 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5217 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5218 topic ? topic : "", NULL); |
4359 | 5219 } |
5220 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5221 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5222 { |
11581 | 5223 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); |
11594 | 5224 generate_send_to_items(win); |
8946 | 5225 update_tab_icon(conv); |
9472 | 5226 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5227 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5228 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5229 { |
8946 | 5230 update_tab_icon(conv); |
4359 | 5231 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5232 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
|
5233 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5234 { |
9472 | 5235 gaim_conversation_autoset_title(conv); |
10810 | 5236 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5237 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5238 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5239 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5240 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5241 } |
10665 | 5242 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5243 { | |
10810 | 5244 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5245 } |
4359 | 5246 } |
5247 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5248 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5249 { |
11581 | 5250 gaim_gtkconv_new, |
4359 | 5251 gaim_gtkconv_destroy, /* destroy_conversation */ |
5252 gaim_gtkconv_write_chat, /* write_chat */ | |
5253 gaim_gtkconv_write_im, /* write_im */ | |
5254 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5255 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5256 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5257 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5258 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5259 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5260 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5261 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5262 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5263 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5264 gaim_gtkconv_updated /* updated */ |
5265 }; | |
5266 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5267 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5268 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5269 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5270 return &conversation_ui_ops; |
4359 | 5271 } |
5272 | |
5273 /************************************************************************** | |
5274 * Public conversation utility functions | |
5275 **************************************************************************/ | |
5276 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5277 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5278 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5279 GaimGtkConversation *gtkconv; |
11581 | 5280 GaimGtkWindow *win; |
4359 | 5281 |
10381 | 5282 GdkPixbufLoader *loader; |
5283 GdkPixbufAnimation *anim; | |
4359 | 5284 GError *err = NULL; |
5285 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5286 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5287 size_t len; |
4359 | 5288 |
5289 GdkPixbuf *buf; | |
5290 | |
5291 GtkWidget *event; | |
5292 GtkWidget *frame; | |
5293 GdkPixbuf *scale; | |
5294 GdkPixmap *pm; | |
5295 GdkBitmap *bm; | |
9318 | 5296 int scale_width, scale_height; |
5297 | |
5298 GaimAccount *account; | |
5299 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5300 |
9324 | 5301 GaimBuddyIcon *icon; |
5302 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5303 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5304 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5305 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5306 |
5307 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5308 win = gtkconv->win; |
10175 | 5309 |
9687 | 5310 if (!gtkconv->u.im->show_icon) |
5311 return; | |
5312 | |
9318 | 5313 account = gaim_conversation_get_account(conv); |
5314 if(account && account->gc) | |
5315 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5316 |
9845 | 5317 /* Remove the current icon stuff */ |
9885 | 5318 if (gtkconv->u.im->icon_container != NULL) |
5319 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5320 gtkconv->u.im->icon_container = NULL; | |
9845 | 5321 |
5322 if (gtkconv->u.im->anim != NULL) | |
5323 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5324 | |
9887 | 5325 gtkconv->u.im->anim = NULL; |
5326 | |
9845 | 5327 if (gtkconv->u.im->icon_timer != 0) |
5328 g_source_remove(gtkconv->u.im->icon_timer); | |
5329 | |
5330 gtkconv->u.im->icon_timer = 0; | |
5331 | |
5332 if (gtkconv->u.im->iter != NULL) | |
5333 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5334 |
10116 | 5335 gtkconv->u.im->iter = NULL; |
5336 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5337 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5338 return; |
5339 | |
5340 if (gaim_conversation_get_gc(conv) == NULL) | |
5341 return; | |
5342 | |
9324 | 5343 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5344 | |
5345 if (icon == NULL) | |
5346 return; | |
5347 | |
5348 data = gaim_buddy_icon_get_data(icon, &len); | |
5349 | |
10381 | 5350 loader = gdk_pixbuf_loader_new(); |
5351 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5352 anim = gdk_pixbuf_loader_get_animation(loader); | |
5353 if (anim) | |
5354 g_object_ref(G_OBJECT(anim)); | |
5355 gdk_pixbuf_loader_close(loader, &err); | |
5356 g_object_unref(loader); | |
5357 | |
5358 if (!anim) | |
9324 | 5359 return; |
10381 | 5360 gtkconv->u.im->anim = anim; |
9324 | 5361 |
4359 | 5362 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5363 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5364 "Buddy icon error: %s\n", err->message); |
4359 | 5365 g_error_free(err); |
5366 } | |
5367 | |
5368 if (!gtkconv->u.im->anim) | |
5369 return; | |
5370 | |
5371 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5372 gtkconv->u.im->iter = NULL; | |
5373 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5374 } else { | |
5375 gtkconv->u.im->iter = | |
8496 | 5376 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5377 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5378 if (gtkconv->u.im->animate) |
10810 | 5379 start_anim(NULL, gtkconv); |
4359 | 5380 } |
5381 | |
10483 | 5382 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5383 NULL, &scale_width, &scale_height); |
4359 | 5384 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5385 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5386 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5387 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5388 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5389 GDK_INTERP_BILINEAR); |
4359 | 5390 |
5391 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5392 g_object_unref(G_OBJECT(scale)); |
4359 | 5393 |
8821 | 5394 |
9885 | 5395 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5396 |
4359 | 5397 frame = gtk_frame_new(NULL); |
5398 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5399 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5400 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5401 FALSE, FALSE, 0); | |
8821 | 5402 |
4359 | 5403 event = gtk_event_box_new(); |
5404 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5405 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5406 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5407 gtk_widget_show(event); |
5408 | |
4635 | 5409 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5410 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5411 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5412 gtk_widget_show(gtkconv->u.im->icon); | |
5413 | |
4793 | 5414 g_object_unref(G_OBJECT(pm)); |
4359 | 5415 |
5416 if (bm) | |
4793 | 5417 g_object_unref(G_OBJECT(bm)); |
7143 | 5418 |
10356 | 5419 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5420 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5421 |
9885 | 5422 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5423 gtk_widget_show(frame); |
5424 | |
7143 | 5425 /* The buddy icon code needs badly to be fixed. */ |
5426 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
|
5427 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5428 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
4359 | 5429 } |
5430 | |
5431 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5432 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5433 { |
11581 | 5434 GaimGtkWindow *win; |
4359 | 5435 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5436 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5437 return; |
5438 | |
11581 | 5439 win = GAIM_GTK_CONVERSATION(conv)->win; |
5440 | |
5441 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5442 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5443 } |
5444 | |
5445 int | |
11614 | 5446 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5447 { |
4359 | 5448 gint nb_x, nb_y, x_rel, y_rel; |
5449 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5450 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5451 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5452 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5453 gboolean horiz; |
4359 | 5454 |
11614 | 5455 if (to_right) |
5456 *to_right = FALSE; | |
5457 | |
11581 | 5458 notebook = GTK_NOTEBOOK(win->notebook); |
5459 | |
5460 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5461 x_rel = x - nb_x; |
5462 y_rel = y - nb_y; | |
5463 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5464 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5465 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5466 |
11780 | 5467 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5468 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5469 #else |
5470 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5471 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5472 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5473 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5474 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5475 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5476 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5477 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5478 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5479 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5480 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5481 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
|
5482 page_num = i; |
11614 | 5483 |
5484 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5485 *to_right = TRUE; | |
5486 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5487 break; |
4359 | 5488 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5489 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5490 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5491 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
|
5492 page_num = i; |
11614 | 5493 |
5494 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5495 *to_right = TRUE; | |
5496 | |
4359 | 5497 break; |
5498 } | |
5499 } | |
5500 } | |
5501 | |
5502 return page_num; | |
5503 } | |
5504 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5505 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5506 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
|
5507 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5508 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5509 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5510 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5511 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5512 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5513 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5514 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5515 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5516 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5517 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5518 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5519 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5520 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5521 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5522 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5523 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5524 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5525 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5526 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5527 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5528 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5529 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5530 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5531 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5532 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5533 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5534 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5535 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5536 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5537 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5538 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5539 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5540 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5541 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5542 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5543 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5544 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5545 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5546 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5547 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5548 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5549 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5550 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5551 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5552 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5553 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5554 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5555 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5556 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5557 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5558 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5559 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5560 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5561 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5562 GtkPositionType pos; |
11581 | 5563 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5564 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5565 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5566 |
11581 | 5567 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5568 win = l->data; | |
5569 | |
11619 | 5570 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
|
5571 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5572 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5573 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5574 static void |
12188 | 5575 show_timestamps_pref_cb(const char *name, GaimPrefType type, |
5576 gpointer value, gpointer data) | |
5577 { | |
5578 GList *l; | |
5579 GaimConversation *conv; | |
5580 GaimGtkConversation *gtkconv; | |
5581 GaimGtkWindow *win; | |
5582 | |
5583 for (l = gaim_get_conversations(); l != NULL; l = l->next) | |
5584 { | |
5585 conv = (GaimConversation *)l->data; | |
5586 | |
5587 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
5588 continue; | |
5589 | |
5590 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5591 win = gtkconv->win; | |
5592 | |
5593 gtk_check_menu_item_set_active( | |
5594 GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
5595 (gboolean)GPOINTER_TO_INT(value)); | |
5596 | |
5597 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
5598 (gboolean)GPOINTER_TO_INT(value)); | |
5599 } | |
5600 } | |
5601 | |
5602 static void | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5603 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5604 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5605 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5606 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5607 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5608 GaimGtkConversation *gtkconv; |
11581 | 5609 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5610 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5611 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5612 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5613 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5614 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5615 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5616 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5617 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5618 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5619 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5620 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5621 gtk_check_menu_item_set_active( |
11581 | 5622 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5623 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5624 |
5625 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5626 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5627 else |
8317 | 5628 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5629 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5630 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5631 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5632 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5633 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5634 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5635 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5636 GList *l; |
8189 | 5637 GaimConversation *conv; |
5638 GaimGtkConversation *gtkconv; | |
11581 | 5639 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5640 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5641 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
|
5642 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5643 |
8189 | 5644 /* Set the "animate" flag for each icon based on the new preference */ |
5645 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5646 conv = (GaimConversation *)l->data; | |
5647 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5648 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5649 } |
8189 | 5650 |
5651 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5652 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5653 win = l->data; | |
5654 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5655 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5656 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5657 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5658 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5659 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5660 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
|
5661 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5662 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5663 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5664 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5665 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5666 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5667 |
11338 | 5668 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 5669 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5670 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5671 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5672 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
5673 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5674 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5675 gpointer value, gpointer data) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5676 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5677 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5678 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5679 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5680 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5681 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5682 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5683 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5684 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5685 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5686 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5687 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5688 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
|
5689 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5690 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5691 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
|
5692 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5693 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5694 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
|
5695 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5696 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5697 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5698 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5699 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5700 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5701 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5702 if(gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5703 gaim_status_get_type(gaim_account_get_active_status( |
12239 | 5704 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5705 continue; |
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 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5708 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5709 } |
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 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5712 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5713 hide_new_pref_cb(const char *name, GaimPrefType type, gpointer value, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5714 gpointer data) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5715 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5716 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5717 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5718 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5719 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5720 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5721 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5722 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5723 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5724 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
|
5725 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5726 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5727 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
|
5728 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5729 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5730 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5731 gtkconv = l->data; |
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 conv = gtkconv->active_conv; |
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 if(when_away && gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5736 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5737 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5738 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5739 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5740 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5741 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5742 } |
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 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5745 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5746 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5747 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5748 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5749 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5750 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5751 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5752 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5753 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5754 |
11581 | 5755 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5756 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5757 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5758 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5759 |
11581 | 5760 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5761 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5762 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5763 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5764 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5765 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5766 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5767 GaimAccount *account; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5768 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5769 account = gaim_connection_get_account(gc); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5770 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5771 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5772 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5773 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5774 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5775 if (gaim_conversation_get_account(conv) == account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5776 gaim_conversation_update(conv, GPOINTER_TO_INT(event)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5777 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5778 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5779 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5780 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5781 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5782 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5783 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5784 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5785 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5786 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5787 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5788 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5789 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5790 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5791 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5792 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5793 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5794 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5795 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5796 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5797 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5798 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5799 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5800 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5801 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5802 |
12264 | 5803 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5804 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 5805 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 5806 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5807 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 5808 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 5809 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5810 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5811 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5812 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5813 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5814 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
|
5815 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5816 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5817 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5818 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5819 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5820 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5821 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5822 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5823 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5824 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 5825 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5826 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 5827 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5828 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5829 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5830 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 5831 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
|
5832 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5833 /* convert old queuing prefs to hide_new 3-way pref */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5834 if(gaim_prefs_exists("/plugins/gtk/docklet/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5835 gaim_prefs_get_bool("/plugins/gtk/docklet/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5836 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "always"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5837 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5838 else if(gaim_prefs_exists("/gaim/gtk/away/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5839 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5840 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "away"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5841 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5842 else { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5843 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "never"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5844 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5845 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5846 /* Connect callbacks. */ |
10087 | 5847 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
|
5848 close_on_tabs_pref_cb, NULL); |
12188 | 5849 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
5850 show_timestamps_pref_cb, NULL); | |
10087 | 5851 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
|
5852 show_formatting_toolbar_pref_cb, NULL); |
10087 | 5853 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5854 spellcheck_pref_cb, NULL); |
10087 | 5855 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5856 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5857 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5858 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5859 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5860 |
10087 | 5861 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5862 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5863 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5864 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5865 /* IM callbacks */ |
10087 | 5866 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
|
5867 animate_buddy_icons_pref_cb, NULL); |
10087 | 5868 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
|
5869 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5870 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5871 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5872 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5873 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5874 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5875 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5876 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5877 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
5878 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5879 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5880 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5881 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5882 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5883 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 5884 |
5885 /********************************************************************** | |
5886 * Register commands | |
5887 **********************************************************************/ | |
9829 | 5888 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
5889 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
5890 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 5891 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
5892 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5893 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 5894 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
5895 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5896 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
|
5897 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5898 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5899 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 5900 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 5901 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
5902 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 5903 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5904 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5905 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5906 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5907 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5908 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5909 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5910 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5911 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5912 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5913 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5914 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5915 gaim_signal_connect(blist_handle, "buddy-added", handle, |
11855 | 5916 G_CALLBACK(buddy_update_cb), NULL); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5917 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
11855 | 5918 G_CALLBACK(buddy_update_cb), NULL); |
5919 | |
11581 | 5920 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5921 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5922 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5923 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5924 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5925 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5926 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5927 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5928 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5929 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5930 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5931 { |
10443 | 5932 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 5933 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5934 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5935 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5936 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5937 } |
11581 | 5938 |
5939 | |
5940 | |
5941 | |
5942 | |
5943 | |
5944 | |
5945 | |
5946 | |
5947 | |
5948 | |
5949 | |
5950 | |
5951 | |
5952 | |
5953 | |
5954 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
5955 * and touch each others' private members all day long */ | |
5956 | |
5957 /** | |
5958 * @file gtkconvwin.c GTK+ Conversation Window API | |
5959 * @ingroup gtkui | |
5960 * | |
5961 * gaim | |
5962 * | |
5963 * Gaim is the legal property of its developers, whose names are too numerous | |
5964 * to list here. Please refer to the COPYRIGHT file distributed with this | |
5965 * source distribution. | |
5966 * | |
5967 * This program is free software; you can redistribute it and/or modify | |
5968 * it under the terms of the GNU General Public License as published by | |
5969 * the Free Software Foundation; either version 2 of the License, or | |
5970 * (at your option) any later version. | |
5971 * | |
5972 * This program is distributed in the hope that it will be useful, | |
5973 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
5974 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
5975 * GNU General Public License for more details. | |
5976 * | |
5977 * You should have received a copy of the GNU General Public License | |
5978 * along with this program; if not, write to the Free Software | |
5979 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
5980 * | |
5981 */ | |
5982 #include "internal.h" | |
5983 #include "gtkgaim.h" | |
5984 | |
5985 | |
5986 #include <gdk/gdkkeysyms.h> | |
5987 | |
5988 #include "account.h" | |
5989 #include "cmds.h" | |
5990 #include "debug.h" | |
5991 #include "imgstore.h" | |
5992 #include "log.h" | |
5993 #include "notify.h" | |
5994 #include "prpl.h" | |
5995 #include "request.h" | |
5996 #include "util.h" | |
5997 | |
5998 #include "gtkdnd-hints.h" | |
5999 #include "gtkblist.h" | |
6000 #include "gtkconv.h" | |
6001 #include "gtkdialogs.h" | |
6002 #include "gtkmenutray.h" | |
6003 #include "gtkpounce.h" | |
6004 #include "gtkprefs.h" | |
6005 #include "gtkprivacy.h" | |
6006 #include "gtkutils.h" | |
6007 #include "gtkstock.h" | |
6008 #include "gtkimhtml.h" | |
6009 #include "gtkimhtmltoolbar.h" | |
6010 | |
6011 static void | |
6012 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
6013 { | |
6014 gtk_widget_destroy(warn_close_dialog); | |
6015 warn_close_dialog = NULL; | |
6016 | |
6017 if (resp == GTK_RESPONSE_OK) | |
6018 gaim_gtk_conv_window_destroy(win); | |
6019 } | |
6020 | |
6021 static void | |
6022 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
6023 { | |
6024 GtkWidget *label; | |
6025 GtkWidget *vbox, *hbox; | |
6026 GtkWidget *img; | |
6027 | |
6028 g_return_if_fail(warn_close_dialog == NULL); | |
6029 | |
6030 | |
6031 warn_close_dialog = gtk_dialog_new_with_buttons( | |
6032 _("Confirm close"), | |
6033 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
6034 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
6035 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
6036 | |
6037 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
6038 GTK_RESPONSE_OK); | |
6039 | |
6040 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
6041 6); | |
6042 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
6043 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
6044 FALSE); | |
6045 | |
6046 /* Setup the outside spacing. */ | |
6047 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
6048 | |
6049 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
6050 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
6051 | |
6052 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
6053 GTK_ICON_SIZE_DIALOG); | |
6054 /* Setup the inner hbox and put the dialog's icon in it. */ | |
6055 hbox = gtk_hbox_new(FALSE, 12); | |
6056 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
6057 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
6058 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
6059 | |
6060 /* Setup the right vbox. */ | |
6061 vbox = gtk_vbox_new(FALSE, 12); | |
6062 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
6063 | |
6064 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
6065 gtk_widget_set_size_request(label, 350, -1); | |
6066 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
6067 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
6068 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
6069 | |
6070 /* Connect the signals. */ | |
6071 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
6072 G_CALLBACK(do_close), gtkwin); | |
6073 | |
6074 } | |
6075 | |
6076 /************************************************************************** | |
6077 * Callbacks | |
6078 **************************************************************************/ | |
6079 | |
6080 static gboolean | |
6081 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
6082 { | |
6083 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6084 GList *l; |
11581 | 6085 |
6086 /* If there are unread messages then show a warning dialog */ | |
6087 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
6088 l != NULL; l = l->next) | |
6089 { | |
6090 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6091 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
|
6092 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6093 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6094 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6095 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6096 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6097 return TRUE; |
11581 | 6098 } |
6099 } | |
6100 | |
6101 gaim_gtk_conv_window_destroy(win); | |
6102 | |
6103 return TRUE; | |
6104 } | |
6105 | |
11604 | 6106 static void |
6107 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
6108 { | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6109 if (state == GAIM_UNSEEN_NONE) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6110 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6111 gtkconv->unseen_count = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6112 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6113 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6114 else |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6115 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6116 gtkconv->unseen_count++; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6117 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6118 if (state > gtkconv->unseen_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6119 gtkconv->unseen_state = state; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6120 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6121 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6122 /* 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
|
6123 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
|
6124 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6125 |
11581 | 6126 /* |
6127 * When a conversation window is focused, we know the user | |
6128 * has looked at it so we know there are no longer unseen | |
6129 * messages. | |
6130 */ | |
6131 static gint | |
6132 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6133 { | |
6134 GaimGtkWindow *win = d; | |
11604 | 6135 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6136 | |
6137 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6138 |
6139 return FALSE; | |
6140 } | |
6141 | |
11851 | 6142 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6143 /* Courtesy of Galeon! */ |
6144 static void | |
6145 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6146 { | |
6147 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6148 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6149 } | |
11851 | 6150 #endif |
11581 | 6151 |
6152 static void | |
6153 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6154 { | |
6155 static GdkCursor *cursor = NULL; | |
6156 | |
6157 gtkwin->in_drag = TRUE; | |
6158 | |
6159 if (gtkwin->drag_leave_signal) { | |
6160 g_signal_handler_disconnect(G_OBJECT(widget), | |
6161 gtkwin->drag_leave_signal); | |
6162 gtkwin->drag_leave_signal = 0; | |
6163 } | |
6164 | |
6165 if (cursor == NULL) | |
6166 cursor = gdk_cursor_new(GDK_FLEUR); | |
6167 | |
6168 /* Grab the pointer */ | |
6169 gtk_grab_add(gtkwin->notebook); | |
6170 #ifndef _WIN32 | |
6171 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6172 always be true after a button press. */ | |
6173 if (!gdk_pointer_is_grabbed()) | |
6174 #endif | |
6175 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6176 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6177 NULL, cursor, GDK_CURRENT_TIME); | |
6178 } | |
6179 | |
6180 static gboolean | |
6181 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6182 { | |
6183 | |
6184 /* | |
6185 * Make sure the user moved the mouse far enough for the | |
6186 * drag to be initiated. | |
6187 */ | |
6188 if (win->in_predrag) { | |
6189 if (e->x_root < win->drag_min_x || | |
6190 e->x_root >= win->drag_max_x || | |
6191 e->y_root < win->drag_min_y || | |
6192 e->y_root >= win->drag_max_y) { | |
6193 | |
6194 win->in_predrag = FALSE; | |
6195 notebook_init_grab(win, widget); | |
6196 } | |
6197 } | |
6198 else { /* Otherwise, draw the arrows. */ | |
6199 GaimGtkWindow *dest_win; | |
6200 GtkNotebook *dest_notebook; | |
6201 GtkWidget *tab; | |
6202 gint nb_x, nb_y, page_num; | |
6203 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6204 gboolean horiz_tabs = FALSE; | |
11614 | 6205 GaimGtkConversation *gtkconv; |
6206 gboolean to_right = FALSE; | |
11581 | 6207 |
6208 /* Get the window that the cursor is over. */ | |
6209 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6210 | |
6211 if (dest_win == NULL) { | |
6212 dnd_hints_hide_all(); | |
6213 | |
6214 return TRUE; | |
6215 } | |
6216 | |
6217 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6218 | |
6219 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6220 | |
6221 arrow1_x = arrow2_x = nb_x; | |
6222 arrow1_y = arrow2_y = nb_y; | |
6223 | |
6224 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6225 e->x_root, e->y_root, &to_right); |
6226 to_right = to_right && (win != dest_win); | |
11581 | 6227 |
6228 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6229 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6230 | |
6231 horiz_tabs = TRUE; | |
6232 } | |
6233 | |
11614 | 6234 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6235 tab = gtkconv->tabby; | |
11581 | 6236 |
6237 if (horiz_tabs) { | |
6238 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6239 | |
11614 | 6240 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6241 arrow1_x += tab->allocation.width; |
6242 arrow2_x += tab->allocation.width; | |
6243 } | |
6244 | |
6245 arrow1_y = nb_y + tab->allocation.y; | |
6246 arrow2_y = nb_y + tab->allocation.y + | |
6247 tab->allocation.height; | |
6248 } else { | |
6249 arrow1_x = nb_x + tab->allocation.x; | |
6250 arrow2_x = nb_x + tab->allocation.x + | |
6251 tab->allocation.width; | |
6252 arrow1_y = arrow2_y = nb_y + tab->allocation.y + tab->allocation.height/2; | |
6253 | |
6254 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
6255 arrow1_y += tab->allocation.height; | |
6256 arrow2_y += tab->allocation.height; | |
6257 } | |
6258 } | |
6259 | |
6260 if (horiz_tabs) { | |
6261 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6262 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6263 } else { | |
6264 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6265 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6266 } | |
6267 } | |
6268 | |
6269 return TRUE; | |
6270 } | |
6271 | |
6272 static gboolean | |
6273 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6274 { | |
6275 if (win->in_drag) | |
6276 return FALSE; | |
6277 | |
6278 if (e->x_root < win->drag_min_x || | |
6279 e->x_root >= win->drag_max_x || | |
6280 e->y_root < win->drag_min_y || | |
6281 e->y_root >= win->drag_max_y) { | |
6282 | |
6283 win->in_predrag = FALSE; | |
6284 notebook_init_grab(win, widget); | |
6285 } | |
6286 | |
6287 return TRUE; | |
6288 } | |
6289 | |
6290 /* | |
6291 * THANK YOU GALEON! | |
6292 */ | |
6293 static gboolean | |
6294 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6295 { | |
6296 gint nb_x, nb_y, x_rel, y_rel; | |
6297 int tab_clicked; | |
6298 GtkWidget *page; | |
6299 GtkWidget *tab; | |
6300 | |
6301 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6302 return FALSE; | |
6303 | |
6304 | |
6305 if (win->in_drag) { | |
6306 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6307 "Already in the middle of a window drag at tab_press_cb\n"); | |
6308 return TRUE; | |
6309 } | |
6310 | |
6311 /* | |
6312 * Make sure a tab was actually clicked. The arrow buttons | |
6313 * mess things up. | |
6314 */ | |
11614 | 6315 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6316 |
6317 if (tab_clicked == -1) | |
6318 return FALSE; | |
6319 | |
6320 /* | |
6321 * Get the relative position of the press event, with regards to | |
6322 * the position of the notebook. | |
6323 */ | |
6324 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6325 | |
6326 x_rel = e->x_root - nb_x; | |
6327 y_rel = e->y_root - nb_y; | |
6328 | |
6329 /* Reset the min/max x/y */ | |
6330 win->drag_min_x = 0; | |
6331 win->drag_min_y = 0; | |
6332 win->drag_max_x = 0; | |
6333 win->drag_max_y = 0; | |
6334 | |
6335 /* Find out which tab was dragged. */ | |
6336 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6337 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6338 | |
6339 win->drag_min_x = tab->allocation.x + nb_x; | |
6340 win->drag_min_y = tab->allocation.y + nb_y; | |
6341 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6342 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6343 | |
6344 /* Make sure the click occurred in the tab. */ | |
6345 if (e->x_root < win->drag_min_x || | |
6346 e->x_root >= win->drag_max_x || | |
6347 e->y_root < win->drag_min_y || | |
6348 e->y_root >= win->drag_max_y) { | |
6349 | |
6350 return FALSE; | |
6351 } | |
6352 | |
6353 win->in_predrag = TRUE; | |
6354 win->drag_tab = tab_clicked; | |
6355 | |
6356 /* Connect the new motion signals. */ | |
6357 win->drag_motion_signal = | |
6358 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6359 G_CALLBACK(notebook_motion_cb), win); | |
6360 | |
6361 win->drag_leave_signal = | |
6362 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6363 G_CALLBACK(notebook_leave_cb), win); | |
6364 | |
6365 return FALSE; | |
6366 } | |
6367 | |
6368 static gboolean | |
6369 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6370 { | |
6371 GaimGtkWindow *dest_win; | |
6372 GaimConversation *conv; | |
6373 GaimGtkConversation *gtkconv; | |
6374 gint dest_page_num = 0; | |
6375 gboolean new_window = FALSE; | |
11614 | 6376 gboolean to_right = FALSE; |
11581 | 6377 |
6378 /* | |
6379 * Don't check to make sure that the event's window matches the | |
6380 * widget's, because we may be getting an event passed on from the | |
6381 * close button. | |
6382 */ | |
6383 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6384 return FALSE; | |
6385 | |
6386 if (gdk_pointer_is_grabbed()) { | |
6387 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6388 gtk_grab_remove(widget); | |
6389 } | |
6390 | |
6391 if (!win->in_predrag && !win->in_drag) | |
6392 return FALSE; | |
6393 | |
6394 /* Disconnect the motion signal. */ | |
6395 if (win->drag_motion_signal) { | |
6396 g_signal_handler_disconnect(G_OBJECT(widget), | |
6397 win->drag_motion_signal); | |
6398 | |
6399 win->drag_motion_signal = 0; | |
6400 } | |
6401 | |
6402 /* | |
6403 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6404 * signal. | |
6405 */ | |
6406 if (win->in_predrag) { | |
6407 win->in_predrag = FALSE; | |
6408 | |
6409 if (win->drag_leave_signal) { | |
6410 g_signal_handler_disconnect(G_OBJECT(widget), | |
6411 win->drag_leave_signal); | |
6412 | |
6413 win->drag_leave_signal = 0; | |
6414 } | |
6415 } | |
6416 | |
6417 /* If we're not in drag... */ | |
6418 /* We're perfectly normal people! */ | |
6419 if (!win->in_drag) | |
6420 return FALSE; | |
6421 | |
6422 win->in_drag = FALSE; | |
6423 | |
6424 dnd_hints_hide_all(); | |
6425 | |
6426 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6427 | |
6428 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6429 | |
6430 if (dest_win == NULL) { | |
6431 /* If the current window doesn't have any other conversations, | |
6432 * there isn't much point transferring the conv to a new window. */ | |
6433 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6434 /* Make a new window to stick this to. */ | |
6435 dest_win = gaim_gtk_conv_window_new(); | |
6436 new_window = TRUE; | |
6437 } | |
6438 } | |
6439 | |
6440 if (dest_win == NULL) | |
6441 return FALSE; | |
6442 | |
6443 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6444 "conversation-dragging", win, dest_win); | |
6445 | |
6446 /* Get the destination page number. */ | |
6447 if (!new_window) | |
6448 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6449 e->x_root, e->y_root, &to_right); |
11581 | 6450 |
6451 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6452 | |
6453 if (win == dest_win) { | |
6454 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6455 } else { | |
6456 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6457 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 6458 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 6459 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
6460 if (new_window) { | |
6461 gint win_width, win_height; | |
6462 | |
6463 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6464 &win_width, &win_height); | |
6465 | |
6466 gtk_window_move(GTK_WINDOW(dest_win->window), | |
6467 e->x_root - (win_width / 2), | |
6468 e->y_root - (win_height / 2)); | |
6469 | |
6470 gaim_gtk_conv_window_show(dest_win); | |
6471 } | |
6472 } | |
6473 | |
6474 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
6475 | |
6476 return TRUE; | |
6477 } | |
6478 | |
6479 | |
6480 static void | |
6481 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6482 gpointer user_data) | |
6483 { | |
6484 GaimGtkWindow *win; | |
6485 GaimConversation *conv; | |
6486 GaimGtkConversation *gtkconv; | |
6487 | |
6488 win = user_data; | |
6489 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6490 | |
6491 g_return_if_fail(conv != NULL); | |
6492 | |
6493 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
6494 return; | |
6495 | |
6496 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6497 | |
6498 stop_anim(NULL, gtkconv); | |
6499 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6500 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6501 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6502 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6503 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6504 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6505 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6506 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6507 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6508 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6509 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6510 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6511 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6512 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6513 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6514 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6515 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6516 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6517 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6518 /* 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
|
6519 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6520 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6521 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6522 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6523 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6524 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6525 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6526 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6527 } |
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 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6530 close_others_cb(GtkWidget *w, GObject *menu) |
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 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6533 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6534 GaimGtkWindow *win; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6535 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6536 gtkconv = g_object_get_data(menu, "clicked_tab"); |
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 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6539 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6540 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6541 win = gaim_gtkconv_get_window(gtkconv); |
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 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6544 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6545 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6546 iter = iter->next; |
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 if (gconv != 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 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6551 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6552 } |
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 close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6556 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6557 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6558 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6559 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6560 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6561 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6562 close_conv_cb(NULL, gtkconv); |
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 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6565 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6566 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6567 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6568 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6569 GaimGtkConversation *gtkconv; |
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 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6572 return FALSE; |
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 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
6575 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
|
6576 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6577 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
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 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6580 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6581 } |
12188 | 6582 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6583 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", 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 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6586 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6587 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6588 item = gtk_menu_item_new_with_label("Detach this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6589 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6590 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6591 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6592 G_CALLBACK(detach_tab_cb), menu); |
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 item = gtk_menu_item_new_with_label("Close this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6595 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6596 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6597 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6598 G_CALLBACK(close_tab_cb), menu); |
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 gaim_separator(menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6601 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6602 item = gtk_menu_item_new_with_label("Close other tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6603 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6604 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6605 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6606 G_CALLBACK(close_others_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6607 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6608 item = gtk_menu_item_new_with_label("Close all tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6609 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6610 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6611 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6612 G_CALLBACK(close_window), win); |
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 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6615 } |
11581 | 6616 |
6617 static void | |
6618 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6619 gpointer user_data) | |
6620 { | |
6621 GaimGtkWindow *win; | |
6622 GaimConversation *conv; | |
6623 GaimGtkConversation *gtkconv; | |
6624 | |
6625 win = user_data; | |
6626 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
6627 conv = gtkconv->active_conv; | |
6628 | |
6629 g_return_if_fail(conv != NULL); | |
6630 | |
6631 /* | |
6632 * Only set "unseen" to "none" if the window has focus | |
6633 */ | |
6634 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 6635 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 6636 |
6637 /* Update the menubar */ | |
6638 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6639 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
|
6640 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6641 |
11594 | 6642 generate_send_to_items(win); |
6643 | |
11604 | 6644 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 6645 |
6646 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), | |
6647 gtkconv->make_sound); | |
6648 | |
6649 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
6650 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
6651 | |
6652 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
12188 | 6653 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
11581 | 6654 |
6655 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6656 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), | |
6657 gtkconv->u.im->show_icon); | |
11604 | 6658 |
11581 | 6659 /* |
6660 * We pause icons when they are not visible. If this icon should | |
6661 * be animated then start it back up again. | |
6662 */ | |
6663 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
6664 (gtkconv->u.im->animate)) | |
6665 start_anim(NULL, gtkconv); | |
6666 } | |
6667 | |
6668 /************************************************************************** | |
6669 * GTK+ window ops | |
6670 **************************************************************************/ | |
6671 | |
6672 GList * | |
6673 gaim_gtk_conv_windows_get_list() | |
6674 { | |
6675 return window_list; | |
6676 } | |
6677 | |
6678 GaimGtkWindow * | |
6679 gaim_gtk_conv_window_new() | |
6680 { | |
6681 GaimGtkWindow *win; | |
6682 GtkPositionType pos; | |
6683 GtkWidget *testidea; | |
6684 GtkWidget *menubar; | |
6685 | |
6686 win = g_malloc0(sizeof(GaimGtkWindow)); | |
6687 | |
6688 window_list = g_list_append(window_list, win); | |
6689 | |
6690 /* Create the window. */ | |
6691 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
6692 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
6693 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
6694 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
6695 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
6696 | |
6697 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
6698 G_CALLBACK(close_win_cb), win); | |
6699 | |
6700 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
6701 G_CALLBACK(focus_win_cb), win); | |
6702 | |
6703 /* Create the notebook. */ | |
6704 win->notebook = gtk_notebook_new(); | |
6705 | |
6706 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
6707 | |
6708 #if 0 | |
6709 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
6710 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
6711 #endif | |
6712 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
6713 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
6714 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
6715 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
6716 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
6717 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6718 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6719 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6720 |
11581 | 6721 gtk_widget_show(win->notebook); |
6722 | |
6723 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
6724 G_CALLBACK(before_switch_conv_cb), win); | |
6725 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
6726 G_CALLBACK(switch_conv_cb), win); | |
6727 | |
6728 /* Setup the tab drag and drop signals. */ | |
6729 gtk_widget_add_events(win->notebook, | |
6730 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
6731 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
6732 G_CALLBACK(notebook_press_cb), win); | |
6733 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
6734 G_CALLBACK(notebook_release_cb), win); | |
6735 | |
6736 testidea = gtk_vbox_new(FALSE, 0); | |
6737 | |
6738 /* Setup the menubar. */ | |
6739 menubar = setup_menubar(win); | |
6740 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
6741 | |
6742 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
6743 | |
6744 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
6745 | |
6746 gtk_widget_show(testidea); | |
6747 | |
6748 return win; | |
6749 } | |
6750 | |
6751 void | |
6752 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
6753 { | |
6754 window_list = g_list_remove(window_list, win); | |
6755 | |
11611 | 6756 if (win->gtkconvs) { |
6757 while (win->gtkconvs) { | |
6758 GList *nextgtk = win->gtkconvs->next; | |
6759 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
6760 GList *nextcore = gtkconv->convs->next; | |
6761 GaimConversation *conv = gtkconv->convs->data; | |
6762 gaim_conversation_destroy(conv); | |
6763 if (!nextgtk && !nextcore) | |
6764 /* we'll end up invoking ourselves when we destroy our last child */ | |
6765 /* so don't destroy ourselves right now */ | |
6766 return; | |
6767 } | |
6768 return; | |
6769 } | |
11581 | 6770 gtk_widget_destroy(win->window); |
6771 | |
6772 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
6773 | |
6774 g_free(win); | |
6775 } | |
6776 | |
6777 void | |
6778 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
6779 { | |
6780 gtk_widget_show(win->window); | |
6781 } | |
6782 | |
6783 void | |
6784 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
6785 { | |
6786 gtk_widget_hide(win->window); | |
6787 } | |
6788 | |
6789 void | |
6790 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
6791 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
6792 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 6793 } |
6794 | |
6795 void | |
6796 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6797 { | |
6798 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
6799 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
6800 gtkconv->tab_cont)); | |
6801 } | |
6802 | |
6803 void | |
6804 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6805 { | |
6806 GaimConversation *conv = gtkconv->active_conv; | |
6807 GaimGtkConversation *focus_gtkconv; | |
6808 GtkWidget *tabby, *menu_tabby; | |
6809 GtkWidget *tab_cont = gtkconv->tab_cont; | |
6810 GtkWidget *close_image; | |
6811 GaimConversationType conv_type; | |
6812 const char *name; | |
6813 const gchar *tmp_lab; | |
6814 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 6815 gboolean tabs_side = FALSE; |
6816 gint angle = 0; | |
11581 | 6817 |
6818 name = gaim_conversation_get_name(conv); | |
6819 conv_type = gaim_conversation_get_type(conv); | |
6820 | |
6821 | |
6822 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
6823 gtkconv->win = win; | |
6824 | |
11619 | 6825 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
6826 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
6827 tabs_side = TRUE; | |
6828 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
6829 angle = 90; | |
6830 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6831 angle = 270; | |
6832 | |
6833 if (angle) | |
6834 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
6835 else | |
6836 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 6837 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
6838 | |
6839 /* Close button. */ | |
6840 gtkconv->close = gtk_button_new(); | |
6841 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
6842 if (gtk_check_version(2, 4, 2) == NULL) { | |
6843 /* Need to account for extra padding around the gtkbutton */ | |
6844 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
6845 "focus-line-width", &focus_width, | |
6846 "focus-padding", &focus_pad, | |
6847 NULL); | |
6848 close_button_width += (focus_width + focus_pad) * 2; | |
6849 close_button_height += (focus_width + focus_pad) * 2; | |
6850 } | |
6851 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
6852 close_button_width, close_button_height); | |
6853 | |
6854 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
6855 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
6856 gtk_widget_show(close_image); | |
6857 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
6858 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
6859 _("Close conversation"), NULL); | |
6860 | |
6861 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
6862 G_CALLBACK(close_conv_cb), gtkconv); | |
6863 | |
11851 | 6864 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6865 /* |
6866 * I love Galeon. They have a fix for that stupid annoying visible | |
6867 * border bug. I love you guys! -- ChipX86 | |
6868 */ | |
11851 | 6869 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 6870 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
6871 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 6872 #endif |
11581 | 6873 |
6874 /* Status icon. */ | |
6875 gtkconv->icon = gtk_image_new(); | |
6876 gtkconv->menu_icon = gtk_image_new(); | |
6877 update_tab_icon(conv); | |
6878 | |
6879 /* Tab label. */ | |
6880 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 6881 |
11581 | 6882 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 6883 if (!angle) |
6884 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 6885 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 6886 if (tabs_side) { |
6887 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
6888 } | |
6889 if (angle) | |
6890 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 6891 #endif |
6892 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6893 #if 0 | |
6894 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
6895 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
6896 #endif | |
6897 | |
6898 /* Pack it all together. */ | |
11619 | 6899 if (angle == 90) |
6900 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
6901 else | |
6902 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 6903 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
6904 FALSE, FALSE, 0); | |
6905 | |
6906 gtk_widget_show_all(gtkconv->icon); | |
6907 gtk_widget_show_all(gtkconv->menu_icon); | |
6908 | |
6909 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
6910 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
6911 gtk_widget_show(gtkconv->tab_label); | |
6912 gtk_widget_show(gtkconv->menu_label); | |
6913 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
6914 | |
11619 | 6915 if (angle == 90) |
6916 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
6917 else | |
6918 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 6919 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
6920 gtk_widget_show(gtkconv->close); | |
6921 | |
6922 gtk_widget_show(tabby); | |
6923 gtk_widget_show(menu_tabby); | |
6924 | |
6925 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6926 gaim_gtkconv_update_buddy_icon(conv); | |
6927 | |
6928 /* Add this pane to the conversation's notebook. */ | |
6929 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 6930 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 6931 |
6932 | |
6933 gtk_widget_show(tab_cont); | |
6934 | |
6935 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
6936 /* Er, bug in notebooks? Switch to the page manually. */ | |
6937 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
6938 | |
6939 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6940 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6941 } else | |
6942 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
6943 | |
6944 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
6945 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
6946 gtk_widget_grab_focus(focus_gtkconv->entry); | |
6947 | |
6948 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 6949 update_send_to_selection(win); |
11581 | 6950 } |
6951 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6952 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6953 private_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv, gboolean destroy_empty) |
11581 | 6954 { |
6955 unsigned int index; | |
6956 GaimConversationType conv_type; | |
6957 | |
6958 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
6959 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
6960 | |
6961 g_object_ref(gtkconv->tab_cont); | |
6962 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
6963 | |
6964 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
6965 | |
6966 /* go back to tabless if need be */ | |
6967 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
6968 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6969 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6970 } | |
6971 | |
6972 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 6973 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6974 if (destroy_empty && !win->gtkconvs) |
11582 | 6975 gaim_gtk_conv_window_destroy(win); |
11581 | 6976 } |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6977 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6978 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6979 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6980 private_remove_gtkconv(win, gtkconv, TRUE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6981 } |
11581 | 6982 |
6983 GaimGtkConversation * | |
6984 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
6985 { | |
6986 GtkWidget *tab_cont; | |
6987 | |
6988 if (index == -1) | |
6989 index = 0; | |
6990 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 6991 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 6992 } |
6993 | |
6994 GaimGtkConversation * | |
6995 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
6996 { | |
6997 int index; | |
6998 GtkWidget *tab_cont; | |
6999 | |
7000 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
7001 if (index == -1) | |
7002 index = 0; | |
7003 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
7004 if (!tab_cont) | |
7005 return NULL; | |
7006 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
7007 } | |
7008 | |
7009 | |
7010 GaimConversation * | |
7011 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
7012 { | |
7013 GaimGtkConversation *gtkconv; | |
7014 | |
7015 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
7016 return gtkconv ? gtkconv->active_conv : NULL; | |
7017 } | |
7018 | |
7019 gboolean | |
7020 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
7021 { | |
7022 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
7023 } | |
7024 | |
7025 gboolean | |
7026 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
7027 { | |
7028 gboolean has_focus = FALSE; | |
7029 | |
7030 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
7031 | |
7032 return has_focus; | |
7033 } | |
7034 | |
7035 GaimGtkWindow * | |
7036 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
7037 { | |
7038 GaimGtkWindow *win; | |
7039 GdkWindow *gdkwin; | |
7040 GList *l; | |
7041 | |
7042 gdkwin = gdk_window_at_pointer(&x, &y); | |
7043 | |
7044 if (gdkwin) | |
7045 gdkwin = gdk_window_get_toplevel(gdkwin); | |
7046 | |
7047 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
7048 win = l->data; | |
7049 | |
7050 if (gdkwin == win->window->window) | |
7051 return win; | |
7052 } | |
7053 | |
7054 return NULL; | |
7055 } | |
7056 | |
7057 GList * | |
7058 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
7059 { | |
7060 return win->gtkconvs; | |
7061 } | |
7062 | |
7063 guint | |
7064 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
7065 { | |
7066 return g_list_length(win->gtkconvs); | |
7067 } | |
7068 | |
7069 GaimGtkWindow * | |
7070 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
7071 { | |
7072 GList *wins, *convs; | |
7073 GaimGtkWindow *win; | |
7074 GaimGtkConversation *conv; | |
7075 | |
7076 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7077 return NULL; | |
7078 | |
7079 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7080 win = wins->data; | |
7081 | |
7082 for (convs = win->gtkconvs; | |
7083 convs != NULL; | |
7084 convs = convs->next) { | |
7085 | |
7086 conv = convs->data; | |
7087 | |
7088 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7089 return win; | |
7090 } | |
7091 } | |
7092 | |
7093 return NULL; | |
7094 } | |
7095 | |
7096 GaimGtkWindow * | |
7097 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
7098 { | |
7099 GList *wins, *convs; | |
7100 GaimGtkWindow *win; | |
7101 GaimGtkConversation *conv; | |
7102 | |
7103 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7104 return NULL; | |
7105 | |
7106 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7107 wins != NULL; | |
7108 wins = wins->prev) { | |
7109 | |
7110 win = wins->data; | |
7111 | |
7112 for (convs = win->gtkconvs; | |
7113 convs != NULL; | |
7114 convs = convs->next) { | |
7115 | |
7116 conv = convs->data; | |
7117 | |
7118 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7119 return win; | |
7120 } | |
7121 } | |
7122 | |
7123 return NULL; | |
7124 } | |
7125 | |
7126 | |
7127 /************************************************************************** | |
7128 * Conversation placement functions | |
7129 **************************************************************************/ | |
7130 typedef struct | |
7131 { | |
7132 char *id; | |
7133 char *name; | |
7134 GaimConvPlacementFunc fnc; | |
7135 | |
7136 } ConvPlacementData; | |
7137 | |
7138 static GList *conv_placement_fncs = NULL; | |
7139 static GaimConvPlacementFunc place_conv = NULL; | |
7140 | |
7141 /* This one places conversations in the last made window. */ | |
7142 static void | |
7143 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7144 { | |
7145 GaimGtkWindow *win; | |
7146 | |
7147 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7148 win = l ? l->data : NULL;; | |
7149 | |
7150 if (win == NULL) { | |
7151 win = gaim_gtk_conv_window_new(); | |
7152 | |
7153 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7154 gaim_gtk_conv_window_show(win); | |
7155 } else { | |
7156 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7157 } | |
7158 } | |
7159 | |
7160 /* This one places conversations in the last made window of the same type. */ | |
7161 static void | |
7162 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7163 { | |
7164 GaimGtkWindow *win; | |
7165 | |
7166 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7167 | |
7168 if (win == NULL) { | |
7169 win = gaim_gtk_conv_window_new(); | |
7170 | |
7171 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7172 gaim_gtk_conv_window_show(win); | |
7173 } else | |
7174 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7175 } | |
7176 | |
7177 /* This one places each conversation in its own window. */ | |
7178 static void | |
7179 conv_placement_new_window(GaimGtkConversation *conv) | |
7180 { | |
7181 GaimGtkWindow *win; | |
7182 | |
7183 win = gaim_gtk_conv_window_new(); | |
7184 | |
7185 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7186 | |
7187 gaim_gtk_conv_window_show(win); | |
7188 } | |
7189 | |
7190 static GaimGroup * | |
7191 conv_get_group(GaimGtkConversation *conv) | |
7192 { | |
7193 GaimGroup *group = NULL; | |
7194 | |
7195 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7196 GaimBuddy *buddy; | |
7197 | |
7198 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7199 gaim_conversation_get_name(conv->active_conv)); | |
7200 | |
7201 if (buddy != NULL) | |
12088 | 7202 group = gaim_buddy_get_group(buddy); |
11581 | 7203 |
7204 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7205 GaimChat *chat; | |
7206 | |
7207 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7208 gaim_conversation_get_name(conv->active_conv)); | |
7209 | |
7210 if (chat != NULL) | |
7211 group = gaim_chat_get_group(chat); | |
7212 } | |
7213 | |
7214 return group; | |
7215 } | |
7216 | |
7217 /* | |
7218 * This groups things by, well, group. Buddies from groups will always be | |
7219 * grouped together, and a buddy from a group not belonging to any currently | |
7220 * open windows will get a new window. | |
7221 */ | |
7222 static void | |
7223 conv_placement_by_group(GaimGtkConversation *conv) | |
7224 { | |
7225 GaimConversationType type; | |
7226 GaimGroup *group = NULL; | |
7227 GList *wl, *cl; | |
7228 | |
7229 type = gaim_conversation_get_type(conv->active_conv); | |
7230 | |
7231 group = conv_get_group(conv); | |
7232 | |
7233 /* Go through the list of IMs and find one with this group. */ | |
7234 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7235 GaimGtkWindow *win2; | |
7236 GaimGtkConversation *conv2; | |
7237 GaimGroup *group2 = NULL; | |
7238 | |
7239 win2 = wl->data; | |
7240 | |
7241 for (cl = win2->gtkconvs; | |
7242 cl != NULL; | |
7243 cl = cl->next) { | |
7244 conv2 = cl->data; | |
7245 | |
7246 group2 = conv_get_group(conv2); | |
7247 | |
7248 if (group == group2) { | |
7249 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7250 | |
7251 return; | |
7252 } | |
7253 } | |
7254 } | |
7255 | |
7256 /* Make a new window. */ | |
7257 conv_placement_new_window(conv); | |
7258 } | |
7259 | |
7260 /* This groups things by account. Otherwise, the same semantics as above */ | |
7261 static void | |
7262 conv_placement_by_account(GaimGtkConversation *conv) | |
7263 { | |
7264 GaimConversationType type; | |
7265 GList *wins, *convs; | |
7266 GaimAccount *account; | |
7267 | |
7268 account = gaim_conversation_get_account(conv->active_conv); | |
7269 type = gaim_conversation_get_type(conv->active_conv); | |
7270 | |
7271 /* Go through the list of IMs and find one with this group. */ | |
7272 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7273 GaimGtkWindow *win2; | |
7274 GaimGtkConversation *conv2; | |
7275 | |
7276 win2 = wins->data; | |
7277 | |
7278 for (convs = win2->gtkconvs; | |
7279 convs != NULL; | |
7280 convs = convs->next) { | |
7281 conv2 = convs->data; | |
7282 | |
7283 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7284 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7285 return; | |
7286 } | |
7287 } | |
7288 } | |
7289 | |
7290 /* Make a new window. */ | |
7291 conv_placement_new_window(conv); | |
7292 } | |
7293 | |
7294 static ConvPlacementData * | |
7295 get_conv_placement_data(const char *id) | |
7296 { | |
7297 ConvPlacementData *data = NULL; | |
7298 GList *n; | |
7299 | |
7300 for (n = conv_placement_fncs; n; n = n->next) { | |
7301 data = n->data; | |
7302 if (!strcmp(data->id, id)) | |
7303 return data; | |
7304 } | |
7305 | |
7306 return NULL; | |
7307 } | |
7308 | |
7309 static void | |
7310 add_conv_placement_fnc(const char *id, const char *name, | |
7311 GaimConvPlacementFunc fnc) | |
7312 { | |
7313 ConvPlacementData *data; | |
7314 | |
7315 data = g_new(ConvPlacementData, 1); | |
7316 | |
7317 data->id = g_strdup(id); | |
7318 data->name = g_strdup(name); | |
7319 data->fnc = fnc; | |
7320 | |
7321 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7322 } | |
7323 | |
7324 static void | |
7325 ensure_default_funcs(void) | |
7326 { | |
7327 if (conv_placement_fncs == NULL) { | |
7328 add_conv_placement_fnc("last", _("Last created window"), | |
7329 conv_placement_last_created_win); | |
7330 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7331 conv_placement_last_created_win_type); | |
7332 add_conv_placement_fnc("new", _("New window"), | |
7333 conv_placement_new_window); | |
7334 add_conv_placement_fnc("group", _("By group"), | |
7335 conv_placement_by_group); | |
7336 add_conv_placement_fnc("account", _("By account"), | |
7337 conv_placement_by_account); | |
7338 } | |
7339 } | |
7340 | |
7341 GList * | |
7342 gaim_gtkconv_placement_get_options(void) | |
7343 { | |
7344 GList *n, *list = NULL; | |
7345 ConvPlacementData *data; | |
7346 | |
7347 ensure_default_funcs(); | |
7348 | |
7349 for (n = conv_placement_fncs; n; n = n->next) { | |
7350 data = n->data; | |
7351 list = g_list_append(list, data->name); | |
7352 list = g_list_append(list, data->id); | |
7353 } | |
7354 | |
7355 return list; | |
7356 } | |
7357 | |
7358 | |
7359 void | |
7360 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
7361 GaimConvPlacementFunc fnc) | |
7362 { | |
7363 g_return_if_fail(id != NULL); | |
7364 g_return_if_fail(name != NULL); | |
7365 g_return_if_fail(fnc != NULL); | |
7366 | |
7367 ensure_default_funcs(); | |
7368 | |
7369 add_conv_placement_fnc(id, name, fnc); | |
7370 } | |
7371 | |
7372 void | |
7373 gaim_gtkconv_placement_remove_fnc(const char *id) | |
7374 { | |
7375 ConvPlacementData *data = get_conv_placement_data(id); | |
7376 | |
7377 if (data == NULL) | |
7378 return; | |
7379 | |
7380 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
7381 | |
7382 g_free(data->id); | |
7383 g_free(data->name); | |
7384 g_free(data); | |
7385 } | |
7386 | |
7387 const char * | |
7388 gaim_gtkconv_placement_get_name(const char *id) | |
7389 { | |
7390 ConvPlacementData *data; | |
7391 | |
7392 ensure_default_funcs(); | |
7393 | |
7394 data = get_conv_placement_data(id); | |
7395 | |
7396 if (data == NULL) | |
7397 return NULL; | |
7398 | |
7399 return data->name; | |
7400 } | |
7401 | |
7402 GaimConvPlacementFunc | |
7403 gaim_gtkconv_placement_get_fnc(const char *id) | |
7404 { | |
7405 ConvPlacementData *data; | |
7406 | |
7407 ensure_default_funcs(); | |
7408 | |
7409 data = get_conv_placement_data(id); | |
7410 | |
7411 if (data == NULL) | |
7412 return NULL; | |
7413 | |
7414 return data->fnc; | |
7415 } | |
7416 | |
7417 void | |
7418 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
7419 { | |
7420 g_return_if_fail(func != NULL); | |
7421 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7422 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7423 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7424 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7425 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7426 place_conv = NULL; |
11581 | 7427 } |
7428 | |
7429 GaimConvPlacementFunc | |
7430 gaim_gtkconv_placement_get_current_func(void) | |
7431 { | |
7432 return place_conv; | |
7433 } | |
7434 | |
7435 void | |
7436 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
7437 { | |
7438 if (place_conv) | |
7439 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7440 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7441 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7442 } |
12239 | 7443 |
7444 gboolean | |
7445 gaim_gtkconv_is_hidden(GaimGtkConversation *gtkconv) | |
7446 { | |
7447 g_return_val_if_fail(gtkconv != NULL, FALSE); | |
7448 | |
7449 return (gtkconv->win == hidden_convwin); | |
7450 } |