Mercurial > pidgin.yaz
annotate src/gtkconv.c @ 12345:f6fa5d742c76
[gaim-migrate @ 14649]
so we were talking in #gaim the other day, and chat nick colors came up.
I mentioned that back when sean changed the color code list, that we'd
talked about maybe someday having code to generate the list of colors
automatically. And datallah found the w3.org algorithm to check a given
color code for visibility, so Tak wrote up some code to use that to
generate a list of colors. I like it, and nwalp says to go ahead and
commit it then.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 05 Dec 2005 05:08:38 +0000 |
parents | 3726ff9022f3 |
children | f81d458aba18 |
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 |
12335 | 74 /* Undef this to turn off "custom-smiley" debug messages */ |
75 #define DEBUG_CUSTOM_SMILEY | |
76 | |
10108 | 77 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
78 | |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
79 #if 0 |
10108 | 80 /* These colors come from the default GNOME palette */ |
81 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
82 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
83 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
84 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
85 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
86 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
87 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
88 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
89 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
90 {0, 34816, 17920, 12544}, /* Red Dark */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
91 {0, 49408, 14336, 8704}, /* Red Shadow */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
92 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
93 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
94 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
95 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
96 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
97 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
98 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
99 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
100 {0, 57088, 16896, 7680}, /* Accent Red */ |
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
101 {0, 39168, 0, 0}, /* Accent Red Dark */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
102 {0, 17920, 40960, 17920}, /* Accent Green */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
103 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 104 }; |
6291 | 105 |
4359 | 106 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
107 #endif |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
108 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
109 /* From http://www.w3.org/TR/AERT#color-contrast */ |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
110 #define MIN_BRIGHTNESS_CONTRAST 125 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
111 #define MIN_COLOR_CONTRAST 500 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
112 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
113 #define NUM_NICK_COLORS 220 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
114 static GdkColor *nick_colors = NULL; |
4359 | 115 |
11581 | 116 typedef struct { |
4359 | 117 GtkWidget *window; |
118 | |
119 GtkWidget *entry; | |
120 GtkWidget *message; | |
121 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
122 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
123 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
124 } InviteBuddyInfo; |
4359 | 125 |
126 static GtkWidget *invite_dialog = NULL; | |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
127 static GtkWidget *warn_close_dialog = NULL; |
4359 | 128 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
129 static GaimGtkWindow *hidden_convwin = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
130 static GList *window_list = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
131 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
132 |
11594 | 133 static gboolean update_send_to_selection(GaimGtkWindow *win); |
134 static void generate_send_to_items(GaimGtkWindow *win); | |
11581 | 135 |
4359 | 136 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
10810 | 137 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
11604 | 138 static void gray_stuff_out(GaimGtkConversation *gtkconv); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
139 static GList *generate_invite_user_names(GaimConnection *gc); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
140 static void add_chat_buddy_common(GaimConversation *conv, const char *name, |
11869 | 141 GaimConvChatBuddyFlags flags, const char *alias, const char *old_name); |
9605 | 142 static gboolean tab_complete(GaimConversation *conv); |
11604 | 143 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); |
11613 | 144 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); |
10810 | 145 static void update_typing_icon(GaimGtkConversation *gtkconv); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
146 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
|
147 gboolean gaim_gtkconv_has_focus(GaimConversation *conv); |
12335 | 148 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data); |
149 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data); | |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
150 GdkColor* generate_nick_colors(guint numcolors, GdkColor background); |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
151 gboolean color_is_visible(GdkColor foreground, GdkColor background); |
4359 | 152 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
153 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
154 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
155 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
156 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
157 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
158 col = nick_colors[g_str_hash(name) % NUM_NICK_COLORS]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
159 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
160 (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
|
161 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
162 /* 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
|
163 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
164 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
165 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
166 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
167 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
168 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
169 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
170 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
171 |
4359 | 172 /************************************************************************** |
173 * Callbacks | |
174 **************************************************************************/ | |
10971 | 175 |
4359 | 176 static gint |
10810 | 177 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 178 { |
10810 | 179 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 180 |
10810 | 181 l = list; |
182 while (l) { | |
183 GaimConversation *conv = l->data; | |
184 gaim_conversation_destroy(conv); | |
185 l = l->next; | |
186 } | |
11508 | 187 |
10810 | 188 g_list_free(list); |
11508 | 189 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
190 return TRUE; |
4359 | 191 } |
192 | |
8914 | 193 static gboolean |
10810 | 194 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 195 { |
10810 | 196 GaimConversation *conv = gtkconv->active_conv; |
11508 | 197 |
8914 | 198 if (!GTK_WIDGET_VISIBLE(w)) |
199 return FALSE; | |
200 | |
201 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
202 return FALSE; | |
203 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
204 /* 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
|
205 * 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
|
206 * 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
|
207 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
208 /* 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
|
209 * negate it anyway. --luke */ |
11338 | 210 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 211 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
212 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
213 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
|
214 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
|
215 } |
8914 | 216 if (w == gtkconv->entry) |
217 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
218 } | |
11338 | 219 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 220 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
221 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
222 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
|
223 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
|
224 } |
8914 | 225 if (w == gtkconv->entry) |
226 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
227 } | |
228 | |
229 return FALSE; | |
230 } | |
231 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
232 static void |
10810 | 233 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
234 { |
10810 | 235 GaimConversation *conv = c->active_conv; |
11508 | 236 |
10665 | 237 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
238 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
239 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
240 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
241 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
242 if (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
|
243 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
244 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
245 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
|
246 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
247 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
248 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
|
249 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
250 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
251 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
252 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
253 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
254 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
255 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
256 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
259 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
261 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
262 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
264 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 fg_color.blue / 256); |
8061 | 266 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
267 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
268 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
269 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
270 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
271 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
272 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
273 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
274 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
275 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
276 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
277 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
278 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
279 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
280 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
281 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
282 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
283 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
284 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
285 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
286 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
287 g_free(color); |
8677 | 288 |
9025 | 289 |
10665 | 290 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 291 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
292 else | |
293 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 294 } |
295 } | |
9130 | 296 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
297 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
298 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
299 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
300 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
301 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
302 |
9130 | 303 static const char * |
304 gaim_gtk_get_cmd_prefix(void) | |
305 { | |
306 return "/"; | |
307 } | |
308 | |
9167 | 309 static GaimCmdRet |
9829 | 310 say_command_cb(GaimConversation *conv, |
311 const char *cmd, char **args, char **error, void *data) | |
312 { | |
11338 | 313 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 314 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 315 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 316 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
317 | |
318 return GAIM_CMD_RET_OK; | |
319 } | |
320 | |
321 static GaimCmdRet | |
9167 | 322 me_command_cb(GaimConversation *conv, |
9597 | 323 const char *cmd, char **args, char **error, void *data) |
9167 | 324 { |
325 char *tmp; | |
326 | |
327 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 328 |
11338 | 329 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 330 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 331 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 332 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
333 | |
334 g_free(tmp); | |
335 return GAIM_CMD_RET_OK; | |
336 } | |
337 | |
9212 | 338 static GaimCmdRet |
339 debug_command_cb(GaimConversation *conv, | |
9597 | 340 const char *cmd, char **args, char **error, void *data) |
9212 | 341 { |
342 char *tmp, *markup; | |
343 GaimCmdStatus status; | |
344 | |
345 if (!g_ascii_strcasecmp(args[0], "version")) { | |
346 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
|
347 markup = g_markup_escape_text(tmp, -1); |
9212 | 348 |
349 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
350 | |
351 g_free(tmp); | |
352 g_free(markup); | |
353 return status; | |
354 } else { | |
355 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
356 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
357 return GAIM_CMD_STATUS_OK; | |
358 } | |
359 } | |
360 | |
9213 | 361 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
362 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
363 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
364 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
365 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
366 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
367 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
368 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
369 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
370 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
371 } |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
372 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
373 static GaimCmdRet |
9213 | 374 help_command_cb(GaimConversation *conv, |
9597 | 375 const char *cmd, char **args, char **error, void *data) |
9213 | 376 { |
9597 | 377 GList *l, *text; |
9213 | 378 GString *s; |
9597 | 379 |
380 if (args[0] != NULL) { | |
381 s = g_string_new(""); | |
382 text = gaim_cmd_help(conv, args[0]); | |
383 | |
384 if (text) { | |
385 for (l = text; l; l = l->next) | |
386 if (l->next) | |
9816 | 387 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 388 else |
9816 | 389 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 390 } else { |
391 g_string_append(s, _("No such command (in this context).")); | |
392 } | |
393 } else { | |
394 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
395 "The following commands are available in this context:\n")); | |
396 | |
397 text = gaim_cmd_list(conv); | |
398 for (l = text; l; l = l->next) | |
9213 | 399 if (l->next) |
9597 | 400 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 401 else |
9597 | 402 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 403 } |
404 | |
405 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
406 g_string_free(s, TRUE); | |
407 | |
408 return GAIM_CMD_STATUS_OK; | |
409 } | |
410 | |
4359 | 411 static void |
9374 | 412 send_history_add(GaimConversation *conv, const char *message) |
413 { | |
414 GList *first; | |
415 | |
416 first = g_list_first(conv->send_history); | |
417 | |
418 if (first->data) | |
419 g_free(first->data); | |
420 | |
421 first->data = g_strdup(message); | |
422 | |
423 conv->send_history = g_list_prepend(first, NULL); | |
424 } | |
425 | |
9832 | 426 static gboolean |
427 check_for_and_do_command(GaimConversation *conv) | |
428 { | |
429 GaimGtkConversation *gtkconv; | |
430 char *cmd; | |
431 const char *prefix; | |
432 GaimAccount *account; | |
433 GtkTextIter start; | |
434 | |
435 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
436 account = gaim_conversation_get_account(conv); | |
437 prefix = gaim_gtk_get_cmd_prefix(); | |
438 | |
439 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
440 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
441 | |
442 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
443 && !gtk_text_iter_get_child_anchor(&start)) { | |
444 GaimCmdStatus status; | |
445 char *error, *cmdline, *markup, *send_history; | |
446 GtkTextIter end; | |
447 | |
448 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
449 send_history_add(conv, send_history); | |
450 g_free(send_history); | |
451 | |
452 cmdline = cmd + strlen(prefix); | |
453 | |
454 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
455 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
456 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
457 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
458 g_free(cmd); | |
459 g_free(markup); | |
460 | |
461 switch (status) { | |
462 case GAIM_CMD_STATUS_OK: | |
463 return TRUE; | |
464 case GAIM_CMD_STATUS_NOT_FOUND: | |
465 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
466 gaim_conversation_write(conv, "", _("No such command."), | |
467 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
468 | |
469 return TRUE; | |
470 } | |
471 return FALSE; | |
472 case GAIM_CMD_STATUS_WRONG_ARGS: | |
473 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
474 "to that command."), | |
475 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
476 return TRUE; | |
477 case GAIM_CMD_STATUS_FAILED: | |
478 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
479 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
480 if(error) | |
481 g_free(error); | |
482 return TRUE; | |
483 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 484 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 485 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 486 GAIM_MESSAGE_NO_LOG, time(NULL)); |
487 else | |
10843 | 488 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 489 GAIM_MESSAGE_NO_LOG, time(NULL)); |
490 return TRUE; | |
491 case GAIM_CMD_STATUS_WRONG_PRPL: | |
492 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
493 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
494 return TRUE; | |
495 } | |
496 } | |
497 | |
498 g_free(cmd); | |
499 return FALSE; | |
500 } | |
501 | |
9374 | 502 static void |
10810 | 503 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 504 { |
10810 | 505 GaimConversation *conv = gtkconv->active_conv; |
8655 | 506 GaimAccount *account; |
8677 | 507 GaimConnection *gc; |
12216 | 508 GaimMessageFlags flags = 0; |
8448 | 509 char *buf, *clean; |
4359 | 510 |
8655 | 511 account = gaim_conversation_get_account(conv); |
9130 | 512 |
9471 | 513 if (!gaim_account_is_connected(account)) |
514 return; | |
515 | |
11338 | 516 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 517 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 518 return; |
519 | |
9832 | 520 if (check_for_and_do_command(conv)) { |
521 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
522 return; | |
9130 | 523 } |
524 | |
8442 | 525 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 526 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 527 |
4359 | 528 gtk_widget_grab_focus(gtkconv->entry); |
529 | |
8448 | 530 if (strlen(clean) == 0) { |
531 g_free(clean); | |
4359 | 532 return; |
533 } | |
534 | |
12272 | 535 gaim_idle_touch(); |
536 | |
12216 | 537 /* XXX: is there a better way to tell if the message has images? */ |
538 if (GTK_IMHTML(gtkconv->entry)->im_images != NULL) | |
539 flags |= GAIM_MESSAGE_IMAGES; | |
540 | |
8677 | 541 gc = gaim_account_get_connection(account); |
10665 | 542 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 543 char **bufs; |
544 int i; | |
545 | |
546 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
547 for (i = 0; bufs[i]; i++) { | |
9374 | 548 send_history_add(conv, bufs[i]); |
11338 | 549 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 550 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), bufs[i], flags); |
11338 | 551 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 552 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), bufs[i], flags); |
8677 | 553 } |
554 | |
555 g_strfreev(bufs); | |
556 | |
557 } else { | |
9374 | 558 send_history_add(conv, buf); |
11338 | 559 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 560 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), buf, flags); |
11338 | 561 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 562 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), buf, flags); |
8677 | 563 } |
4359 | 564 |
8677 | 565 g_free(clean); |
4359 | 566 g_free(buf); |
567 | |
8061 | 568 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 569 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 570 } |
571 | |
572 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
573 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 574 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
575 GaimAccount *account; |
4359 | 576 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
577 GaimConversation *conv = gtkconv->active_conv; |
4359 | 578 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
579 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
580 name = gaim_conversation_get_name(conv); |
7879 | 581 |
11338 | 582 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 583 GaimBuddy *b; |
584 | |
585 b = gaim_find_buddy(account, name); | |
586 if (b != NULL) | |
9730 | 587 gaim_gtkdialogs_remove_buddy(b); |
7859 | 588 else if (account != NULL && gaim_account_is_connected(account)) |
589 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 590 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 591 GaimChat *c; |
592 | |
593 c = gaim_blist_find_chat(account, name); | |
594 if (c != NULL) | |
9730 | 595 gaim_gtkdialogs_remove_chat(c); |
7859 | 596 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 597 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 598 } |
4359 | 599 |
600 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
601 } | |
602 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
603 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 604 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
605 GaimConversation *conv = gtkconv->active_conv; |
7975 | 606 GaimPluginProtocolInfo *prpl_info = NULL; |
607 GaimConnection *gc; | |
608 | |
609 if ((gc = gaim_conversation_get_gc(conv))) { | |
610 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
611 | |
612 /* | |
613 * If there are special needs for getting info on users in | |
614 * buddy chat "rooms"... | |
615 */ | |
616 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
617 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
618 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
619 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
620 } |
7975 | 621 else |
622 prpl_info->get_info(gc, who); | |
623 } | |
624 } | |
625 | |
626 | |
4359 | 627 static void |
10810 | 628 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 629 { |
10810 | 630 GaimConversation *conv = gtkconv->active_conv; |
4359 | 631 |
11338 | 632 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 633 serv_get_info(gaim_conversation_get_gc(conv), |
634 gaim_conversation_get_name(conv)); | |
635 | |
636 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 637 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 638 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
639 GaimGtkChatPane *gtkchat; |
4359 | 640 GtkTreeIter iter; |
641 GtkTreeModel *model; | |
642 GtkTreeSelection *sel; | |
9554 | 643 char *name; |
4359 | 644 |
645 gtkchat = gtkconv->u.chat; | |
646 | |
647 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
648 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
649 | |
650 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 651 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 652 else |
653 return; | |
654 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
655 chat_do_info(gtkconv, name); |
9554 | 656 g_free(name); |
4359 | 657 } |
658 } | |
659 | |
660 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
661 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 662 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
663 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
664 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
665 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
666 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
667 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
668 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
669 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 670 |
671 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
672 } | |
673 | |
674 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
675 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 676 { |
677 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
678 GaimGtkConversation *gtkconv; |
4359 | 679 |
680 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
681 | |
682 if (resp == GTK_RESPONSE_OK) { | |
683 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
684 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
685 | |
10113 | 686 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 687 return; |
688 | |
689 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
690 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 691 message, buddy); |
692 } | |
693 | |
694 gtk_widget_destroy(invite_dialog); | |
695 invite_dialog = NULL; | |
696 | |
697 g_free(info); | |
698 } | |
699 | |
700 static void | |
9909 | 701 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
702 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
703 { | |
704 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
705 const char *convprotocol; | |
706 | |
707 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
708 | |
709 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
710 { | |
711 GaimBlistNode *node = NULL; | |
712 GaimBuddy *buddy; | |
713 | |
714 memcpy(&node, sd->data, sizeof(node)); | |
715 | |
716 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
717 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
718 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
719 buddy = (GaimBuddy *)node; | |
720 else | |
721 return; | |
722 | |
723 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
724 { | |
725 gaim_notify_error(NULL, NULL, | |
726 _("That buddy is not on the same protocol as this " | |
10843 | 727 "chat."), NULL); |
9909 | 728 } |
729 else | |
730 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
731 | |
732 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
733 } | |
734 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
735 { | |
736 char *protocol = NULL; | |
737 char *username = NULL; | |
738 GaimAccount *account; | |
739 | |
11137 | 740 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 741 &protocol, &username, NULL)) |
742 { | |
743 if (account == NULL) | |
744 { | |
745 gaim_notify_error(NULL, NULL, | |
746 _("You are not currently signed on with an account that " | |
747 "can invite that buddy."), NULL); | |
748 } | |
749 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
750 { | |
751 gaim_notify_error(NULL, NULL, | |
752 _("That buddy is not on the same protocol as this " | |
10843 | 753 "chat."), NULL); |
9909 | 754 } |
755 else | |
756 { | |
757 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
758 } | |
759 } | |
760 | |
761 if (username != NULL) g_free(username); | |
762 if (protocol != NULL) g_free(protocol); | |
763 | |
764 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
765 } | |
766 } | |
767 | |
768 static const GtkTargetEntry dnd_targets[] = | |
769 { | |
770 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
771 {"application/x-im-contact", 0, 1} | |
772 }; | |
773 | |
774 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
775 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 776 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
777 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
778 InviteBuddyInfo *info = NULL; |
4359 | 779 |
780 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
781 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
782 GaimGtkWindow *gtkwin; |
4359 | 783 GtkWidget *label; |
784 GtkWidget *vbox, *hbox; | |
785 GtkWidget *table; | |
786 GtkWidget *img; | |
787 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
788 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 789 GTK_ICON_SIZE_DIALOG); |
4359 | 790 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
791 info = g_new0(InviteBuddyInfo, 1); |
4359 | 792 info->conv = conv; |
793 | |
11581 | 794 gc = gaim_conversation_get_gc(conv); |
795 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 796 |
797 /* Create the new dialog. */ | |
798 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 799 _("Invite Buddy Into Chat Room"), |
7879 | 800 GTK_WINDOW(gtkwin->window), 0, |
801 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
802 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 803 |
804 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 805 GTK_RESPONSE_OK); |
11243 | 806 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 807 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
808 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
809 | |
9909 | 810 info->window = GTK_WIDGET(invite_dialog); |
811 | |
4359 | 812 /* Setup the outside spacing. */ |
813 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
814 | |
11243 | 815 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
816 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 817 |
818 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 819 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 820 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
821 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
822 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
823 | |
824 /* Setup the right vbox. */ | |
825 vbox = gtk_vbox_new(FALSE, 0); | |
826 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
827 | |
828 /* Put our happy label in it. */ | |
829 label = gtk_label_new(_("Please enter the name of the user you wish " | |
830 "to invite, along with an optional invite " | |
831 "message.")); | |
832 gtk_widget_set_size_request(label, 350, -1); | |
833 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
834 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
835 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
836 | |
837 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 838 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 839 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
840 | |
841 /* Setup the table we're going to use to lay stuff out. */ | |
842 table = gtk_table_new(2, 2, FALSE); | |
11243 | 843 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
844 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
845 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 846 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
847 | |
848 /* Now the Buddy label */ | |
849 label = gtk_label_new(NULL); | |
850 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
851 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
852 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
853 | |
854 /* Now the Buddy drop-down entry field. */ | |
855 info->entry = gtk_combo_new(); | |
856 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
857 gtk_entry_set_activates_default( | |
858 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
859 | |
860 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
861 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
862 | |
863 /* Fill in the names. */ | |
864 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
865 generate_invite_user_names(gc)); | |
866 | |
867 | |
868 /* Now the label for "Message" */ | |
869 label = gtk_label_new(NULL); | |
870 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
871 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
872 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
873 | |
874 | |
875 /* And finally, the Message entry field. */ | |
876 info->message = gtk_entry_new(); | |
877 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
878 | |
879 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
880 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
881 | |
882 /* Connect the signals. */ | |
883 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
884 G_CALLBACK(do_invite), info); | |
9909 | 885 /* Setup drag-and-drop */ |
886 gtk_drag_dest_set(info->window, | |
887 GTK_DEST_DEFAULT_MOTION | | |
888 GTK_DEST_DEFAULT_DROP, | |
889 dnd_targets, | |
890 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
891 GDK_ACTION_COPY); | |
892 gtk_drag_dest_set(info->entry, | |
893 GTK_DEST_DEFAULT_MOTION | | |
894 GTK_DEST_DEFAULT_DROP, | |
895 dnd_targets, | |
896 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
897 GDK_ACTION_COPY); | |
898 | |
899 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
900 G_CALLBACK(invite_dnd_recv), info); | |
901 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
902 G_CALLBACK(invite_dnd_recv), info); | |
903 | |
4359 | 904 } |
905 | |
906 gtk_widget_show_all(invite_dialog); | |
907 | |
908 if (info != NULL) | |
909 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
910 } | |
911 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
912 static void |
7748 | 913 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
914 { | |
9714 | 915 gaim_gtkdialogs_im(); |
7748 | 916 } |
917 | |
918 static void | |
9504 | 919 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 920 { |
9504 | 921 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 922 FILE *fp; |
923 const char *name; | |
10849 | 924 gchar *text; |
9489 | 925 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
926 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9504 | 927 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 928 return; |
929 } | |
930 | |
931 name = gaim_conversation_get_name(conv); | |
10849 | 932 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 933 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 934 |
935 text = gtk_imhtml_get_markup( | |
936 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
937 fprintf(fp, "%s", text); | |
938 g_free(text); | |
939 | |
940 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 941 fclose(fp); |
942 } | |
943 | |
10849 | 944 /* |
945 * It would be kinda cool if this gave the option of saving a | |
946 * plaintext v. HTML file. | |
947 */ | |
9489 | 948 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
949 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
950 { |
11581 | 951 GaimGtkWindow *win = data; |
952 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 953 gchar *buf; |
954 | |
955 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 956 |
10849 | 957 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
958 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 959 |
960 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
961 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
962 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
963 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
964 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
965 { |
11581 | 966 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
967 GaimConversation *conv; |
9917 | 968 GaimLogType type; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
969 GaimGtkBuddyList *gtkblist; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
970 GdkCursor *cursor; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
971 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
972 GaimAccount *account; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
973 GSList *buddies; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
974 GSList *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
975 |
11581 | 976 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
977 |
11338 | 978 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 979 type = GAIM_LOG_IM; |
11338 | 980 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 981 type = GAIM_LOG_CHAT; |
982 else | |
983 return; | |
984 | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
985 gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
986 cursor = gdk_cursor_new(GDK_WATCH); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
987 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
988 gdk_window_set_cursor(gtkblist->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
989 gdk_window_set_cursor(win->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
990 gdk_cursor_unref(cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
991 while (gtk_events_pending()) |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
992 gtk_main_iteration(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
993 |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
994 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
995 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
996 |
10845 | 997 buddies = gaim_find_buddies(account, name); |
998 for (cur = buddies; cur != NULL; cur = cur->next) | |
999 { | |
1000 GaimBlistNode *node = cur->data; | |
10846 | 1001 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 1002 { |
1003 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
1004 g_slist_free(buddies); | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1005 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1006 gdk_window_set_cursor(win->window->window, NULL); |
10845 | 1007 return; |
1008 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1009 } |
10845 | 1010 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1011 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1012 gaim_gtk_log_show(type, name, account); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1013 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1014 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1015 gdk_window_set_cursor(win->window->window, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1016 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1017 |
8974 | 1018 static void |
1019 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
1020 { | |
11581 | 1021 GaimGtkWindow *win = data; |
8974 | 1022 GaimConversation *conv; |
1023 GaimGtkConversation *gtkconv; | |
1024 | |
11581 | 1025 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 1026 gtkconv = GAIM_GTK_CONVERSATION(conv); |
1027 | |
1028 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1029 } | |
1030 | |
7295 | 1031 struct _search { |
1032 GaimGtkConversation *gtkconv; | |
1033 GtkWidget *entry; | |
1034 }; | |
1035 | |
7929 | 1036 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 1037 { |
7929 | 1038 switch (resp) { |
1039 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1040 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1041 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1042 break; |
1043 | |
1044 case GTK_RESPONSE_DELETE_EVENT: | |
1045 case GTK_RESPONSE_CLOSE: | |
1046 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1047 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1048 s->gtkconv->dialogs.search = NULL; | |
1049 g_free(s); | |
1050 break; | |
1051 } | |
7295 | 1052 } |
1053 | |
1054 static void | |
7751 | 1055 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1056 { |
11581 | 1057 GaimGtkWindow *gtkwin = data; |
1058 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1059 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1060 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1061 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1062 GTK_ICON_SIZE_DIALOG); |
7929 | 1063 GtkWidget *label; |
7295 | 1064 struct _search *s; |
1065 | |
7798 | 1066 if (gtkconv->dialogs.search) { |
1067 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1068 return; |
7798 | 1069 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1070 |
7295 | 1071 s = g_malloc(sizeof(struct _search)); |
1072 s->gtkconv = gtkconv; | |
7929 | 1073 |
1074 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1075 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1076 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1077 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1078 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1079 GTK_RESPONSE_OK); |
7929 | 1080 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1081 G_CALLBACK(do_search_cb), s); | |
1082 | |
11243 | 1083 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1084 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1085 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1086 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
|
1087 gtk_container_set_border_width( |
11243 | 1088 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1089 | |
1090 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1091 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1092 hbox); |
7929 | 1093 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1094 | |
1095 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1096 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1097 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1098 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1099 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1100 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1101 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1102 | |
1103 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1104 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1105 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1106 g_signal_connect(G_OBJECT(s->entry), "changed", |
1107 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1108 gtkconv->dialogs.search); | |
1109 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
|
1110 |
7295 | 1111 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1112 gtk_widget_grab_focus(s->entry); |
7295 | 1113 } |
1114 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1115 static void |
9468 | 1116 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1117 { | |
11581 | 1118 GaimGtkWindow *win = data; |
1119 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1120 |
11338 | 1121 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1122 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1123 } | |
1124 | |
1125 } | |
1126 | |
1127 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1128 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1129 { |
11581 | 1130 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1131 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1132 |
11581 | 1133 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
|
1134 |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1135 gaim_gtk_pounce_editor_show(gaim_conversation_get_account(conv), |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1136 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1137 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1138 |
5908
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_link_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; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1143 GaimGtkConversation *gtkconv; |
8756 | 1144 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1145 |
11581 | 1146 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1147 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1148 | |
1149 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1150 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1151 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1152 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1153 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1154 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1155 { |
11581 | 1156 GaimGtkWindow *win = data; |
8756 | 1157 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 GaimGtkConversation *gtkconv; |
8756 | 1159 GtkIMHtmlToolbar *toolbar; |
1160 | |
11581 | 1161 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1162 conv = gtkconv->active_conv; | |
8756 | 1163 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1164 | |
1165 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1166 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1167 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1168 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1169 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1170 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1171 { |
11581 | 1172 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1173 GaimConversation *conv; |
7879 | 1174 GaimAccount *account; |
1175 const char *name; | |
1176 | |
11581 | 1177 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1178 account = gaim_conversation_get_account(conv); |
1179 name = gaim_conversation_get_name(conv); | |
1180 | |
11338 | 1181 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1182 GaimBuddy *b; |
1183 | |
1184 b = gaim_find_buddy(account, name); | |
1185 if (b != NULL) | |
9730 | 1186 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1187 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1188 GaimChat *c; |
1189 | |
1190 c = gaim_blist_find_chat(account, name); | |
1191 if (c != NULL) | |
9730 | 1192 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1193 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1194 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1195 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1196 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1197 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1198 { |
11581 | 1199 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1200 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1201 |
11581 | 1202 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1203 |
10810 | 1204 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1205 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1206 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1207 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1208 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1209 { |
11581 | 1210 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1212 |
11581 | 1213 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1215 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1216 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1218 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1219 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1220 { |
11581 | 1221 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1222 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1223 |
11581 | 1224 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1225 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1226 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1227 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1228 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1229 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1230 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1231 { |
11581 | 1232 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1233 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1234 |
11581 | 1235 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1236 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1237 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1238 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1239 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1240 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1241 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1242 { |
11581 | 1243 GaimGtkWindow *win = data; |
1244 | |
1245 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
|
1246 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1247 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1248 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1249 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1250 { |
11581 | 1251 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1252 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1253 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1254 |
11581 | 1255 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1256 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1257 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1258 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1259 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1260 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
|
1261 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1262 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1263 return; |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1264 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1265 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1266 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1267 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1268 gaim_conversation_set_logging(conv, TRUE); |
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 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1271 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1272 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1273 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1274 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1275 } |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1276 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1277 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1278 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1279 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1280 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1281 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1282 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1283 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1284 /* 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
|
1285 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1286 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1287 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1288 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1289 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1290 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1291 { |
11581 | 1292 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1293 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1294 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1295 |
11581 | 1296 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1297 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1298 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1299 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1300 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1301 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1302 |
10377 | 1303 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1304 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
|
1305 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1306 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1307 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1309 { |
11581 | 1310 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1311 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1312 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1313 |
11581 | 1314 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1315 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1316 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1317 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1318 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1319 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1320 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1321 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1322 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1323 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1324 |
7961 | 1325 static void |
9188 | 1326 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1327 { | |
11581 | 1328 GaimGtkWindow *win = data; |
9188 | 1329 GaimConversation *conv; |
1330 GaimGtkConversation *gtkconv; | |
1331 | |
11581 | 1332 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1333 |
1334 if (!conv) | |
1335 return; | |
1336 | |
1337 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1338 | |
12188 | 1339 gaim_prefs_set_bool("/gaim/gtk/conversations/show_timestamps", |
9188 | 1340 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
1341 } | |
1342 | |
1343 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1344 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1345 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1346 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1347 GaimAccount *account; |
1348 GaimConnection *gc; | |
7961 | 1349 GaimPluginProtocolInfo *prpl_info = NULL; |
1350 char *real_who; | |
1351 | |
1352 account = gaim_conversation_get_account(conv); | |
10431 | 1353 g_return_if_fail(account != NULL); |
1354 | |
1355 gc = gaim_account_get_connection(account); | |
1356 g_return_if_fail(gc != NULL); | |
1357 | |
1358 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1359 | |
1360 if (prpl_info && prpl_info->get_cb_real_name) | |
1361 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1362 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1363 else | |
1364 real_who = g_strdup(who); | |
1365 | |
1366 if(!real_who) | |
1367 return; | |
1368 | |
10431 | 1369 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1370 |
1371 g_free(real_who); | |
1372 } | |
1373 | |
1374 static void | |
10810 | 1375 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1376 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1377 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1378 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1379 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1380 GtkTreeSelection *sel; |
9554 | 1381 char *name; |
5908
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 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1384 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1385 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1386 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1387 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1388 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1389 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
|
1390 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1391 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1392 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1393 chat_do_im(gtkconv, name); |
9554 | 1394 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1395 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1396 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1397 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1398 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1399 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1400 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1401 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1402 GaimConvChat *chat; |
11869 | 1403 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1404 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1405 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1406 GtkTreeSelection *sel; |
10504 | 1407 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1408 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1409 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1410 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1411 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1412 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1413 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1414 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1415 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1416 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1417 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1418 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1419 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1420 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1421 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1422 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1423 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1424 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1425 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1426 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1427 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1428 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1429 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1430 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1431 |
11869 | 1432 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1433 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1434 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1435 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1436 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1437 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1438 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1439 { |
1440 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1441 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1442 chat_do_im(gtkconv, who); |
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 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1445 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1446 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1447 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1448 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1449 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1450 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1451 | |
1452 serv_send_file(gc, who, NULL); | |
1453 } | |
1454 | |
1455 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1456 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1457 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1458 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1459 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1460 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1461 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1462 chat_do_info(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1463 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1464 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1465 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1466 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1467 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1468 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1469 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1470 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1471 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1472 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1473 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1474 who = g_object_get_data(G_OBJECT(w), "user_data"); |
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 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1477 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1478 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1479 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1480 * 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
|
1481 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1482 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1483 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1484 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1485 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1486 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1487 } |
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 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1490 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1491 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1492 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1493 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1494 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1495 GaimAccount *account; |
6695 | 1496 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1497 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1498 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1499 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1500 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1501 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1502 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1503 if (b != NULL) |
9730 | 1504 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1505 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1506 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1507 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1508 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1509 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1510 |
8143 | 1511 static GtkWidget * |
10504 | 1512 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1513 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1514 { | |
1515 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1516 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1517 gboolean is_me = FALSE; |
8143 | 1518 GtkWidget *button; |
1519 | |
1520 /* | |
1521 * If a menu already exists, destroy it before creating a new one, | |
1522 * thus freeing-up the memory it occupied. | |
1523 */ | |
1524 if (menu) | |
1525 gtk_widget_destroy(menu); | |
1526 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1527 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1528 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1529 |
8143 | 1530 menu = gtk_menu_new(); |
1531 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1532 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1533 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1534 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
|
1535 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
|
1536 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1537 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1538 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1539 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1540 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1541 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1542 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
|
1543 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1544 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1545 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
|
1546 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
|
1547 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1548 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1549 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1550 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1551 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1552 } |
9498 | 1553 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1554 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1555 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
|
1556 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1557 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1558 } |
1559 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1560 if (prpl_info->get_cb_away) { |
10221 | 1561 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
|
1562 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1563 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1564 } |
1565 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1566 if (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1567 if (gaim_find_buddy(gc->account, who)) |
10221 | 1568 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
|
1569 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1570 else |
10221 | 1571 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
|
1572 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1573 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1574 } |
1575 | |
1576 return menu; | |
1577 } | |
1578 | |
1579 | |
1580 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1581 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1582 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1583 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1584 GaimPluginProtocolInfo *prpl_info = NULL; |
1585 GaimGtkChatPane *gtkchat; | |
1586 GaimConnection *gc; | |
1587 GaimAccount *account; | |
1588 GtkTreeSelection *sel; | |
1589 GtkTreeIter iter; | |
1590 GtkTreeModel *model; | |
1591 GtkWidget *menu; | |
1592 gchar *who; | |
1593 | |
1594 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1595 gtkchat = gtkconv->u.chat; | |
1596 account = gaim_conversation_get_account(conv); | |
1597 gc = account->gc; | |
1598 | |
1599 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1600 | |
1601 if (gc != NULL) | |
1602 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1603 | |
1604 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1605 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1606 return FALSE; | |
1607 | |
9498 | 1608 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1609 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1610 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1611 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1612 0, GDK_CURRENT_TIME); |
10504 | 1613 g_free(who); |
8143 | 1614 |
1615 return TRUE; | |
1616 } | |
1617 | |
1618 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1619 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1620 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1621 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1622 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1623 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1624 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1625 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1626 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1627 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1628 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1629 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1630 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1631 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1632 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1633 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1634 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1635 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1636 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1637 gc = account->gc; |
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 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1640 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1641 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
|
1642 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1643 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1644 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1645 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1646 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1647 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1648 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1649 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1650 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1651 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1652 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1653 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1654 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
|
1655 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1656 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1657 chat_do_im(gtkconv, who); |
7398 | 1658 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1659 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1660 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1661 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1662 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1663 |
10504 | 1664 g_free(who); |
1665 gtk_tree_path_free(path); | |
1666 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1667 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1668 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1669 |
8133 | 1670 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1671 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1672 { |
10827 | 1673 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1674 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1675 int index, i, total, found = 0; |
8133 | 1676 |
11581 | 1677 win = gtkconv->win; |
1678 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1679 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1680 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1681 /* 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
|
1682 for (i = forward ? index + 1 : index - 1; |
11581 | 1683 !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
|
1684 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1685 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1686 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1687 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1688 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1689 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1690 found = 1; |
8133 | 1691 } |
11252 | 1692 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1693 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1694 /* 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
|
1695 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1696 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1697 (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
|
1698 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1699 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1700 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1701 found = 1; |
8133 | 1702 } |
10827 | 1703 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1704 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1705 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1706 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1707 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1708 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1709 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1710 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1711 } |
11581 | 1712 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1713 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1714 } |
8133 | 1715 } |
1716 | |
10827 | 1717 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1718 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1719 } |
1720 | |
4359 | 1721 static gboolean |
8105 | 1722 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1723 { |
11581 | 1724 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1725 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1726 GaimGtkConversation *gtkconv; |
8105 | 1727 int curconv; |
1728 | |
10810 | 1729 gtkconv = (GaimGtkConversation *)data; |
10849 | 1730 conv = gtkconv->active_conv; |
11581 | 1731 win = gtkconv->win; |
1732 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1733 |
8105 | 1734 /* If CTRL was held down... */ |
1735 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1736 switch (event->keyval) { |
1737 case GDK_Up: | |
1738 if (!conv->send_history) | |
1739 break; | |
1740 | |
1741 if (!conv->send_history->prev) { | |
1742 GtkTextIter start, end; | |
1743 | |
1744 if (conv->send_history->data) | |
1745 g_free(conv->send_history->data); | |
1746 | |
1747 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1748 &start); | |
1749 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1750 | |
1751 conv->send_history->data = | |
8506 | 1752 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1753 } |
8677 | 1754 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1755 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1756 GObject *object; |
8677 | 1757 GtkTextIter iter; |
1758 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1759 |
1760 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1761 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1762 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1763 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1764 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
|
1765 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1766 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1767 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1768 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1769 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
|
1770 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1771 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1772 |
8061 | 1773 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1774 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1775 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1776 0, NULL); |
8677 | 1777 /* this is mainly just a hack so the formatting at the |
1778 * cursor gets picked up. */ | |
1779 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1780 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1781 } |
1782 | |
8105 | 1783 return TRUE; |
4359 | 1784 break; |
1785 | |
1786 case GDK_Down: | |
1787 if (!conv->send_history) | |
1788 break; | |
1789 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1790 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1791 GObject *object; |
8677 | 1792 GtkTextIter iter; |
1793 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1794 |
4359 | 1795 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1796 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1797 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1798 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1799 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
|
1800 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1801 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1802 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1803 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1804 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
|
1805 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1806 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1807 |
8105 | 1808 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1809 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1810 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1811 0, NULL); |
8677 | 1812 /* this is mainly just a hack so the formatting at the |
1813 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1814 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1815 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1816 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1817 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1818 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1819 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1820 } |
4359 | 1821 } |
1822 | |
8105 | 1823 return TRUE; |
4359 | 1824 break; |
8105 | 1825 |
8108 | 1826 case GDK_Page_Down: |
8143 | 1827 case ']': |
11581 | 1828 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1829 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1830 else |
11581 | 1831 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1832 return TRUE; |
1833 break; | |
1834 | |
8108 | 1835 case GDK_Page_Up: |
8143 | 1836 case '[': |
11581 | 1837 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1838 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1839 else |
11581 | 1840 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1841 return TRUE; |
1842 break; | |
1843 | |
8108 | 1844 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1845 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1846 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1847 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1848 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1849 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1850 } |
8108 | 1851 |
1852 return TRUE; | |
1853 break; | |
1854 | |
11252 | 1855 case GDK_comma: |
11581 | 1856 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1857 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1858 curconv - 1); |
1859 break; | |
1860 | |
1861 case GDK_period: | |
11581 | 1862 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1863 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1864 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1865 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1866 #else |
1867 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1868 #endif | |
11252 | 1869 break; |
1870 | |
8105 | 1871 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1872 } |
8758 | 1873 |
8105 | 1874 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1875 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1876 { |
10864 | 1877 if (event->keyval > '0' && event->keyval <= '9') |
1878 { | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1879 guint switchto = event->keyval - '1'; |
11581 | 1880 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1881 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1882 |
1883 return TRUE; | |
1884 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1885 } |
8758 | 1886 |
8105 | 1887 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1888 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1889 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1890 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1891 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1892 case GDK_Tab: |
9605 | 1893 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1894 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1895 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1896 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1897 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1898 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1899 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1900 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1901 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1902 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1903 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1904 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1905 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1906 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1907 } |
4359 | 1908 return FALSE; |
1909 } | |
1910 | |
1911 /* | |
1912 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1913 * 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
|
1914 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1915 * 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
|
1916 * going all the way down to the notebook. I suspect a bug in |
4359 | 1917 * GtkTextView, but I'm not ready to point any fingers yet. |
1918 */ | |
1919 static gboolean | |
1920 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1921 { | |
1922 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1923 /* Right single click */ | |
1924 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1925 | |
1926 return TRUE; | |
1927 } | |
1928 | |
1929 return FALSE; | |
1930 } | |
1931 | |
8173 | 1932 /* |
1933 * If someone tries to type into the conversation backlog of a | |
1934 * conversation window then we yank focus from the conversation backlog | |
1935 * and give it to the text entry box so that people can type | |
1936 * all the live long day and it will get entered into the entry box. | |
1937 */ | |
6057 | 1938 static gboolean |
8105 | 1939 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1940 { |
1941 GaimGtkConversation *gtkconv = data; | |
1942 | |
8237 | 1943 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1944 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1945 (event->keyval == GDK_F10) || |
1946 (event->keyval == GDK_Shift_L) || | |
1947 (event->keyval == GDK_Shift_R) || | |
1948 (event->keyval == GDK_Escape) || | |
8177 | 1949 (event->keyval == GDK_Up) || |
1950 (event->keyval == GDK_Down) || | |
1951 (event->keyval == GDK_Left) || | |
8191 | 1952 (event->keyval == GDK_Right) || |
1953 (event->keyval == GDK_Home) || | |
9297 | 1954 (event->keyval == GDK_End) || |
1955 (event->keyval == GDK_Tab) || | |
1956 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1957 return FALSE; |
1958 | |
1959 if (event->type == GDK_KEY_RELEASE) | |
1960 gtk_widget_grab_focus(gtkconv->entry); | |
1961 | |
1962 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1963 | |
1964 return TRUE; | |
6057 | 1965 } |
1966 | |
4359 | 1967 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1968 gaim_gtkconv_set_active_conversation(GaimConversation *conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1969 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1970 GaimGtkConversation *gtkconv; |
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 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1973 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1974 gtkconv = GAIM_GTK_CONVERSATION(conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1975 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1976 if (gtkconv->active_conv == conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1977 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1978 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1979 gaim_conversation_close_logs(gtkconv->active_conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1980 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1981 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1982 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1983 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1984 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
|
1985 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1986 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
1987 void |
11604 | 1988 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
1989 { | |
1990 GaimGtkConversation *gtkconv; | |
1991 | |
1992 g_return_if_fail(conv != NULL); | |
1993 | |
1994 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1995 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1996 gaim_gtkconv_set_active_conversation(conv); |
11604 | 1997 |
1998 gray_stuff_out(gtkconv); | |
1999 update_typing_icon(gtkconv); | |
2000 | |
2001 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
2002 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
2003 | |
11671
4ebd27e664c4
[gaim-migrate @ 13957]
Luke Schierer <lschiere@pidgin.im>
parents:
11669
diff
changeset
|
2004 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT); |
11604 | 2005 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
2006 gaim_account_get_protocol_name(conv->account)); | |
2007 } | |
2008 | |
2009 static void | |
4673 | 2010 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 2011 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2012 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 2013 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2014 GaimConversation *conv; |
4359 | 2015 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2016 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2017 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2018 |
11594 | 2019 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 2020 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 2021 } |
2022 | |
2023 static void | |
2024 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
2025 gchar *new_text, gint new_text_length, gpointer user_data) | |
2026 { | |
10810 | 2027 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2028 GaimConversation *conv; | |
2029 | |
2030 g_return_if_fail(gtkconv != NULL); | |
11508 | 2031 |
10810 | 2032 conv = gtkconv->active_conv; |
4359 | 2033 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2034 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2035 return; |
2036 | |
10810 | 2037 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2038 gtk_text_iter_is_end(position))); | |
4359 | 2039 } |
2040 | |
2041 static void | |
2042 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2043 GtkTextIter *end_pos, gpointer user_data) | |
2044 { | |
10810 | 2045 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2046 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2047 GaimConvIm *im; |
4359 | 2048 |
10810 | 2049 g_return_if_fail(gtkconv != NULL); |
11508 | 2050 |
10810 | 2051 conv = gtkconv->active_conv; |
4359 | 2052 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2053 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2054 return; |
2055 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2056 im = GAIM_CONV_IM(conv); |
4359 | 2057 |
2058 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2059 | |
2060 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2061 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2062 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2063 |
2064 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2065 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2066 GAIM_NOT_TYPING); |
4359 | 2067 } |
2068 else { | |
2069 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2070 got_typing_keypress(gtkconv, FALSE); |
4359 | 2071 } |
2072 } | |
2073 | |
8189 | 2074 /************************************************************************** |
2075 * A bunch of buddy icon functions | |
2076 **************************************************************************/ | |
11581 | 2077 GdkPixbuf * |
2078 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2079 { |
10116 | 2080 GaimAccount *account = NULL; |
2081 const char *name = NULL; | |
7143 | 2082 GdkPixbuf *status = NULL; |
2083 | |
10116 | 2084 g_return_val_if_fail(conv != NULL, NULL); |
2085 | |
2086 account = gaim_conversation_get_account(conv); | |
2087 name = gaim_conversation_get_name(conv); | |
2088 | |
2089 g_return_val_if_fail(account != NULL, NULL); | |
2090 g_return_val_if_fail(name != NULL, NULL); | |
2091 | |
11338 | 2092 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2093 GaimBuddy *b = gaim_find_buddy(account, name); |
2094 if (b != NULL) { | |
2095 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2096 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2097 } |
2098 } | |
2099 | |
2100 if (!status) { | |
2101 GdkPixbuf *pixbuf; | |
10884 | 2102 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2103 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2104 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2105 { |
7143 | 2106 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2107 GDK_INTERP_BILINEAR); | |
2108 g_object_unref(pixbuf); | |
2109 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2110 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2111 status = pixbuf; |
7143 | 2112 } |
2113 return status; | |
2114 } | |
2115 | |
8189 | 2116 static void |
2117 update_tab_icon(GaimConversation *conv) | |
2118 { | |
2119 GaimGtkConversation *gtkconv; | |
11581 | 2120 GaimGtkWindow *win; |
8189 | 2121 GaimAccount *account; |
2122 const char *name; | |
2123 GdkPixbuf *status = NULL; | |
2124 | |
10116 | 2125 g_return_if_fail(conv != NULL); |
2126 | |
8189 | 2127 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2128 win = gtkconv->win; |
8189 | 2129 name = gaim_conversation_get_name(conv); |
2130 account = gaim_conversation_get_account(conv); | |
2131 | |
11581 | 2132 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2133 |
10116 | 2134 g_return_if_fail(status != NULL); |
2135 | |
8189 | 2136 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2137 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2138 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2139 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2140 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2141 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2142 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2143 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2144 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2145 { |
11581 | 2146 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2147 | |
2148 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2149 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2150 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2151 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2152 } |
8189 | 2153 } |
2154 | |
2155 static gboolean | |
2156 redraw_icon(gpointer data) | |
2157 { | |
10810 | 2158 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2159 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2160 GaimAccount *account; |
2161 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2162 |
2163 GdkPixbuf *buf; | |
2164 GdkPixbuf *scale; | |
2165 GdkPixmap *pm; | |
2166 GdkBitmap *bm; | |
2167 gint delay; | |
9318 | 2168 int scale_width, scale_height; |
8189 | 2169 |
2170 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2171 account = gaim_conversation_get_account(conv); |
2172 if(account && account->gc) | |
2173 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2174 |
2175 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2176 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2177 | |
10483 | 2178 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2179 NULL, &scale_width, &scale_height); |
2180 | |
2181 /* this code is ugly, and scares me */ | |
8189 | 2182 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2183 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2184 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2185 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2186 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2187 GDK_INTERP_BILINEAR); |
8189 | 2188 |
2189 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2190 g_object_unref(G_OBJECT(scale)); | |
2191 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2192 g_object_unref(G_OBJECT(pm)); | |
2193 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2194 | |
2195 if (bm) | |
2196 g_object_unref(G_OBJECT(bm)); | |
2197 | |
9131 | 2198 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2199 |
2200 if (delay < 100) | |
9131 | 2201 delay = 100; |
2202 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2203 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2204 |
2205 return FALSE; | |
2206 } | |
2207 | |
2208 static void | |
10810 | 2209 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2210 { |
2211 int delay; | |
2212 | |
8228 | 2213 if (gtkconv->u.im->anim == NULL) |
2214 return; | |
2215 | |
8202 | 2216 if (gtkconv->u.im->icon_timer != 0) |
2217 return; | |
2218 | |
8189 | 2219 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2220 return; | |
2221 | |
10639 | 2222 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2223 | |
2224 if (delay < 100) | |
2225 delay = 100; | |
2226 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2227 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2228 } |
2229 | |
2230 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2231 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2232 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2233 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2234 GaimGtkWindow *gtkwin; |
2235 | |
2236 g_return_if_fail(conv != NULL); | |
2237 | |
9887 | 2238 if (gtkconv->u.im->icon_container != NULL) |
2239 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2240 |
2241 if (gtkconv->u.im->anim != NULL) | |
2242 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2243 | |
2244 if (gtkconv->u.im->icon_timer != 0) | |
2245 g_source_remove(gtkconv->u.im->icon_timer); | |
2246 | |
2247 if (gtkconv->u.im->iter != NULL) | |
2248 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2249 | |
2250 gtkconv->u.im->icon_timer = 0; | |
2251 gtkconv->u.im->icon = NULL; | |
2252 gtkconv->u.im->anim = NULL; | |
2253 gtkconv->u.im->iter = NULL; | |
10456 | 2254 gtkconv->u.im->icon_container = NULL; |
9687 | 2255 gtkconv->u.im->show_icon = FALSE; |
10456 | 2256 |
11581 | 2257 gtkwin = gtkconv->win; |
10456 | 2258 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2259 } |
2260 | |
9497 | 2261 static void |
9504 | 2262 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2263 { |
10810 | 2264 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2265 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2266 FILE *fp; |
2267 GaimBuddyIcon *icon; | |
2268 const void *data; | |
2269 size_t len; | |
2270 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2271 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2272 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2273 return; |
2274 } | |
2275 | |
2276 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2277 data = gaim_buddy_icon_get_data(icon, &len); | |
2278 | |
2279 if ((len <= 0) || (data == NULL)) { | |
9504 | 2280 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2281 return; |
2282 } | |
2283 | |
2284 fwrite(data, 1, len, fp); | |
2285 fclose(fp); | |
2286 } | |
2287 | |
2288 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2289 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2290 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2291 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2292 const gchar *ext; |
9497 | 2293 gchar *buf; |
2294 | |
2295 g_return_if_fail(conv != NULL); | |
9504 | 2296 |
10953 | 2297 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2298 if (ext == NULL) | |
2299 ext = "icon"; | |
2300 | |
2301 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2302 |
2303 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2304 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2305 |
2306 g_free(buf); | |
2307 } | |
2308 | |
11581 | 2309 static void |
2310 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2311 { | |
2312 if (gtkconv->u.im->icon_timer != 0) | |
2313 g_source_remove(gtkconv->u.im->icon_timer); | |
2314 | |
2315 gtkconv->u.im->icon_timer = 0; | |
2316 } | |
2317 | |
2318 | |
2319 static void | |
2320 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2321 { | |
2322 gtkconv->u.im->animate = | |
2323 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2324 | |
2325 if (gtkconv->u.im->animate) | |
2326 start_anim(NULL, gtkconv); | |
2327 else | |
2328 stop_anim(NULL, gtkconv); | |
2329 } | |
2330 | |
8189 | 2331 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2332 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2333 { |
2334 static GtkWidget *menu = NULL; | |
2335 GtkWidget *button; | |
2336 | |
2337 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2338 return FALSE; | |
2339 | |
2340 /* | |
2341 * If a menu already exists, destroy it before creating a new one, | |
2342 * thus freeing-up the memory it occupied. | |
2343 */ | |
2344 if (menu != NULL) | |
2345 gtk_widget_destroy(menu); | |
2346 | |
2347 menu = gtk_menu_new(); | |
2348 | |
2349 if (gtkconv->u.im->anim && | |
2350 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2351 { | |
2352 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2353 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2354 gtkconv->u.im->icon_timer); |
2355 } | |
2356 | |
2357 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2358 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2359 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2360 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2361 gtk_widget_show(button); | |
2362 | |
2363 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
|
2364 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2365 0, 0, NULL); |
2366 | |
2367 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2368 | |
2369 return TRUE; | |
2370 } | |
10456 | 2371 |
2372 static void | |
2373 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2374 { | |
11581 | 2375 GaimGtkWindow *win = data; |
10456 | 2376 GaimConversation *conv; |
2377 GaimGtkConversation *gtkconv; | |
2378 gboolean active; | |
2379 | |
11581 | 2380 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2381 |
2382 if (!conv) | |
2383 return; | |
2384 | |
11338 | 2385 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2386 |
2387 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2388 | |
2389 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2390 gtkconv->u.im->show_icon = active; | |
2391 if (active) | |
2392 gaim_gtkconv_update_buddy_icon(conv); | |
2393 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2394 remove_icon(gtkconv); |
10456 | 2395 } |
2396 | |
8189 | 2397 /************************************************************************** |
2398 * End of the bunch of buddy icon functions | |
2399 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2400 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2401 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2402 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2403 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2404 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2405 if(gtkconv->win==hidden_convwin) { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
2406 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2407 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2408 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2409 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2410 gaim_gtkconv_set_active_conversation(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2411 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2412 gaim_gtk_conv_window_raise(gtkconv->win); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2413 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2414 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2415 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2416 GaimConversation * |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2417 gaim_gtk_conversations_get_first_unseen(GaimConversationType type, |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2418 GaimUnseenState min_state) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2419 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2420 GList *l; |
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 if(type==GAIM_CONV_TYPE_IM) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2423 l = gaim_get_ims(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2424 } else if(type==GAIM_CONV_TYPE_CHAT) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2425 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2426 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2427 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2428 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2429 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2430 for(; l!=NULL; l=l->next) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2431 GaimConversation *conv = (GaimConversation*)l->data; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2432 if (GAIM_GTK_CONVERSATION(conv)->unseen_state >= min_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2433 return conv; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2434 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2435 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2436 return NULL; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2437 } |
8189 | 2438 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2439 static void |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2440 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) |
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 g_return_if_fail(conv != NULL); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2443 gaim_gtkconv_present_conversation(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2444 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2445 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2446 guint |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2447 gaim_gtk_conversations_fill_unseen_menu(GtkWidget *menu, |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2448 GaimConversationType type, |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2449 GaimUnseenState min_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2450 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2451 GList *l; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2452 guint ret = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2453 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2454 g_return_val_if_fail(menu != NULL, 0); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2455 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2456 if (type == GAIM_CONV_TYPE_IM) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2457 l = gaim_get_ims(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2458 } else if (type == GAIM_CONV_TYPE_CHAT) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2459 l = gaim_get_chats(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2460 } else { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2461 l = gaim_get_conversations(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2462 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2463 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2464 for (; l != NULL ; l = l->next) { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2465 GaimConversation *conv = (GaimConversation*)l->data; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2466 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2467 |
12239 | 2468 if (gtkconv->unseen_state >= min_state && gtkconv->win == hidden_convwin) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2469 GtkWidget *icon = gtk_image_new(); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2470 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2471 GtkWidget *item; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2472 gchar *text = g_strdup_printf("%s (%d)", |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2473 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2474 gtkconv->unseen_count); |
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 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2477 g_object_unref(pbuf); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2478 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2479 item = gtk_image_menu_item_new_with_label(text); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2480 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
|
2481 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
|
2482 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2483 g_free(text); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2484 ret++; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2485 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2486 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2487 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2488 return ret; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2489 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2490 |
11581 | 2491 GaimGtkWindow * |
2492 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2493 { | |
2494 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2495 return gtkconv->win; | |
2496 } | |
2497 | |
2498 static GtkItemFactoryEntry menu_items[] = | |
2499 { | |
2500 /* Conversation menu */ | |
2501 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, | |
2502 | |
2503 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2504 0, "<StockItem>", GAIM_STOCK_IM }, | |
2505 | |
2506 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
2507 | |
2508 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2509 "<StockItem>", GTK_STOCK_FIND }, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2510 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", GAIM_STOCK_LOG }, |
11581 | 2511 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2512 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
12240 | 2513 { N_("/Conversation/Clea_r"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
11581 | 2514 |
2515 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, | |
2516 | |
2517 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2518 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2519 0, "<StockItem>", GAIM_STOCK_POUNCE }, |
11581 | 2520 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2521 "<StockItem>", GAIM_STOCK_INFO }, | |
2522 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2523 "<StockItem>", GAIM_STOCK_INVITE }, | |
2524 | |
2525 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
2526 | |
2527 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2528 "<StockItem>", GAIM_STOCK_EDIT }, | |
2529 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2530 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2531 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2532 "<StockItem>", GTK_STOCK_ADD }, | |
2533 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2534 "<StockItem>", GTK_STOCK_REMOVE }, | |
2535 | |
2536 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, | |
2537 | |
2538 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2539 "<StockItem>", GAIM_STOCK_LINK }, | |
2540 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2541 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2542 | |
2543 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, | |
2544 | |
2545 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2546 "<StockItem>", GTK_STOCK_CLOSE }, | |
2547 | |
2548 /* Options */ | |
2549 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, | |
2550 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2551 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
2552 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, | |
2553 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, | |
2554 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>" }, | |
2555 }; | |
2556 | |
2557 static const int menu_item_count = | |
2558 sizeof(menu_items) / sizeof(*menu_items); | |
2559 | |
2560 static char * | |
2561 item_factory_translate_func (const char *path, gpointer func_data) | |
2562 { | |
2563 return _((char *)path); | |
2564 } | |
2565 | |
2566 static GtkWidget * | |
2567 setup_menubar(GaimGtkWindow *win) | |
2568 { | |
2569 GtkAccelGroup *accel_group; | |
2570 | |
2571 accel_group = gtk_accel_group_new (); | |
2572 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2573 g_object_unref(accel_group); | |
2574 | |
2575 win->menu.item_factory = | |
2576 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2577 | |
2578 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2579 item_factory_translate_func, | |
2580 NULL, NULL); | |
2581 | |
2582 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2583 menu_items, win); | |
2584 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2585 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2586 | |
2587 | |
2588 win->menu.menubar = | |
2589 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2590 | |
2591 | |
2592 win->menu.view_log = | |
2593 gtk_item_factory_get_widget(win->menu.item_factory, | |
2594 N_("/Conversation/View Log")); | |
2595 | |
2596 /* --- */ | |
2597 | |
2598 win->menu.send_file = | |
2599 gtk_item_factory_get_widget(win->menu.item_factory, | |
2600 N_("/Conversation/Send File...")); | |
2601 | |
2602 win->menu.add_pounce = | |
2603 gtk_item_factory_get_widget(win->menu.item_factory, | |
2604 N_("/Conversation/Add Buddy Pounce...")); | |
2605 | |
2606 /* --- */ | |
2607 | |
2608 win->menu.get_info = | |
2609 gtk_item_factory_get_widget(win->menu.item_factory, | |
2610 N_("/Conversation/Get Info")); | |
2611 | |
2612 win->menu.invite = | |
2613 gtk_item_factory_get_widget(win->menu.item_factory, | |
2614 N_("/Conversation/Invite...")); | |
2615 | |
2616 /* --- */ | |
2617 | |
2618 win->menu.alias = | |
2619 gtk_item_factory_get_widget(win->menu.item_factory, | |
2620 N_("/Conversation/Alias...")); | |
2621 | |
2622 win->menu.block = | |
2623 gtk_item_factory_get_widget(win->menu.item_factory, | |
2624 N_("/Conversation/Block...")); | |
2625 | |
2626 win->menu.add = | |
2627 gtk_item_factory_get_widget(win->menu.item_factory, | |
2628 N_("/Conversation/Add...")); | |
2629 | |
2630 win->menu.remove = | |
2631 gtk_item_factory_get_widget(win->menu.item_factory, | |
2632 N_("/Conversation/Remove...")); | |
2633 | |
2634 /* --- */ | |
2635 | |
2636 win->menu.insert_link = | |
2637 gtk_item_factory_get_widget(win->menu.item_factory, | |
2638 N_("/Conversation/Insert Link...")); | |
2639 | |
2640 win->menu.insert_image = | |
2641 gtk_item_factory_get_widget(win->menu.item_factory, | |
2642 N_("/Conversation/Insert Image...")); | |
2643 | |
2644 /* --- */ | |
2645 | |
2646 win->menu.logging = | |
2647 gtk_item_factory_get_widget(win->menu.item_factory, | |
2648 N_("/Options/Enable Logging")); | |
2649 win->menu.sounds = | |
2650 gtk_item_factory_get_widget(win->menu.item_factory, | |
2651 N_("/Options/Enable Sounds")); | |
2652 win->menu.show_formatting_toolbar = | |
2653 gtk_item_factory_get_widget(win->menu.item_factory, | |
2654 N_("/Options/Show Formatting Toolbars")); | |
2655 win->menu.show_timestamps = | |
2656 gtk_item_factory_get_widget(win->menu.item_factory, | |
2657 N_("/Options/Show Timestamps")); | |
2658 win->menu.show_icon = | |
2659 gtk_item_factory_get_widget(win->menu.item_factory, | |
2660 N_("/Options/Show Buddy Icon")); | |
2661 | |
2662 | |
2663 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2664 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2665 win->menu.tray); | |
2666 gtk_widget_show(win->menu.tray); | |
2667 | |
2668 gtk_widget_show(win->menu.menubar); | |
2669 | |
2670 return win->menu.menubar; | |
2671 } | |
2672 | |
4359 | 2673 |
2674 /************************************************************************** | |
2675 * Utility functions | |
2676 **************************************************************************/ | |
2677 | |
2678 static void | |
10810 | 2679 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2680 { |
10810 | 2681 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2682 GaimConvIm *im; |
4685 | 2683 |
4359 | 2684 /* |
2685 * 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
|
2686 * send GAIM_TYPED any time soon. |
4359 | 2687 */ |
2688 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2689 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2690 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2691 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2692 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2693 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2694 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2695 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2696 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2697 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2698 |
2699 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2700 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2701 GAIM_TYPING); |
4359 | 2702 |
2703 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2704 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2705 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2706 gaim_conv_im_set_type_again(im, 0); |
4359 | 2707 } |
2708 } | |
2709 | |
4736 | 2710 static void |
10810 | 2711 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2712 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2713 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2714 GaimConvIm *im = NULL; |
10810 | 2715 GaimConversation *conv = gtkconv->active_conv; |
12008 | 2716 char *stock_id, *tooltip; |
11508 | 2717 |
11581 | 2718 gtkwin = gtkconv->win; |
4736 | 2719 |
12008 | 2720 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2721 im = GAIM_CONV_IM(conv); |
4736 | 2722 |
12008 | 2723 if (gtkwin->menu.typing_icon) { |
2724 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2725 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2726 |
12008 | 2727 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2728 return; | |
2729 | |
2730 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2731 stock_id = GAIM_STOCK_TYPING; | |
2732 tooltip = _("User is typing..."); | |
2733 } else { | |
2734 stock_id = GAIM_STOCK_TYPED; | |
2735 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2736 } |
12008 | 2737 |
2738 if (gtkwin->menu.typing_icon == NULL) | |
2739 { | |
2740 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
|
2741 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
|
2742 gtkwin->menu.typing_icon, |
12008 | 2743 tooltip); |
4736 | 2744 } |
12008 | 2745 else |
2746 { | |
2747 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2748 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2749 gtkwin->menu.typing_icon, | |
2750 tooltip); | |
2751 } | |
2752 | |
2753 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2754 } |
2755 | |
4685 | 2756 static gboolean |
11594 | 2757 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2758 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2759 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2760 GaimConversation *conv; |
4359 | 2761 GtkWidget *menu; |
2762 GList *child; | |
11594 | 2763 GaimBuddy *b; |
11581 | 2764 |
2765 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2766 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2767 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2768 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2769 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2770 account = gaim_conversation_get_account(conv); |
11581 | 2771 |
11594 | 2772 if (win->menu.send_to == NULL) |
4685 | 2773 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2774 |
11594 | 2775 if (!(b = gaim_find_buddy(account, conv->name))) |
2776 return FALSE; | |
2777 | |
2778 | |
2779 gtk_widget_show(win->menu.send_to); | |
4359 | 2780 |
2781 menu = gtk_menu_item_get_submenu( | |
11594 | 2782 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2783 |
2784 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2785 child != NULL; | |
2786 child = child->next) { | |
2787 | |
2788 GtkWidget *item = child->data; | |
11594 | 2789 GaimBuddy *item_buddy; |
2790 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2791 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2792 "gaim_buddy_name"); | |
2793 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2794 | |
2795 if (b == item_buddy) { | |
4359 | 2796 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2797 break; | |
2798 } | |
2799 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2800 |
4685 | 2801 return FALSE; |
4359 | 2802 } |
2803 | |
2804 static void | |
11594 | 2805 create_sendto_item(GtkWidget *menu, GtkSizeGroup *sg, GSList **group, GaimBuddy *bud) |
2806 { | |
2807 GaimAccount *account; | |
2808 GtkWidget *box; | |
2809 GtkWidget *label; | |
2810 GtkWidget *image; | |
2811 GtkWidget *menuitem; | |
11625 | 2812 GdkPixbuf *pixbuf; |
11616 | 2813 gchar *text; |
11594 | 2814 |
2815 account = bud->account; | |
2816 | |
2817 /* Create a pixmap for the protocol icon. */ | |
11625 | 2818 pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)bud, GAIM_STATUS_ICON_SMALL); |
11594 | 2819 /* Now convert it to GtkImage */ |
2820 if (pixbuf == NULL) | |
2821 image = gtk_image_new(); | |
2822 else | |
11625 | 2823 image = gtk_image_new_from_pixbuf(pixbuf); |
11594 | 2824 |
2825 gtk_size_group_add_widget(sg, image); | |
2826 | |
2827 g_object_unref(G_OBJECT(pixbuf)); | |
2828 | |
2829 /* Make our menu item */ | |
11616 | 2830 text = g_strdup_printf("%s (%s)", gaim_buddy_get_name(bud), gaim_account_get_username(bud->account)); |
2831 menuitem = gtk_radio_menu_item_new_with_label(*group, text); | |
2832 g_free(text); | |
11594 | 2833 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2834 | |
2835 /* Do some evil, see some evil, speak some evil. */ | |
2836 box = gtk_hbox_new(FALSE, 0); | |
2837 | |
2838 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
2839 g_object_ref(label); | |
2840 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
2841 | |
2842 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
2843 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
2844 | |
2845 g_object_unref(label); | |
2846 | |
2847 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
2848 | |
2849 gtk_widget_show(label); | |
2850 gtk_widget_show(image); | |
2851 gtk_widget_show(box); | |
2852 | |
2853 /* Set our data and callbacks. */ | |
2854 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
2855 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(gaim_buddy_get_name(bud)), g_free); | |
2856 | |
2857 g_signal_connect(G_OBJECT(menuitem), "activate", | |
2858 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2859 | |
2860 gtk_widget_show(menuitem); | |
2861 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2862 } | |
2863 | |
2864 static void | |
2865 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 2866 { |
4359 | 2867 GtkWidget *menu; |
2868 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2869 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 2870 GaimGtkConversation *gtkconv; |
2871 GSList *l, *buds; | |
2872 | |
2873 g_return_if_fail(win != NULL); | |
2874 | |
2875 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
2876 | |
11604 | 2877 g_return_if_fail(gtkconv != NULL); |
2878 | |
11594 | 2879 if (win->menu.send_to != NULL) |
2880 gtk_widget_destroy(win->menu.send_to); | |
2881 | |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12272
diff
changeset
|
2882 /* Build the Send To menu */ |
11594 | 2883 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
2884 gtk_widget_show(win->menu.send_to); | |
4359 | 2885 |
2886 menu = gtk_menu_new(); | |
11581 | 2887 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 2888 win->menu.send_to, 2); |
2889 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 2890 |
2891 gtk_widget_show(menu); | |
2892 | |
11604 | 2893 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
2894 buds = gaim_find_buddies(gtkconv->active_conv->account, gtkconv->active_conv->name); | |
2895 for (l = buds; l != NULL; l = l->next) { | |
2896 GaimBuddy *b; | |
2897 GaimBlistNode *node; | |
2898 | |
2899 b = l->data; | |
2900 node = (GaimBlistNode *) gaim_buddy_get_contact(b); | |
2901 | |
2902 for (node = node->child; node != NULL; node = node->next) | |
2903 if (GAIM_BLIST_NODE_IS_BUDDY(node) && gaim_account_is_connected(((GaimBuddy *)node)->account)) | |
2904 create_sendto_item(menu, sg, &group, (GaimBuddy *) node); | |
2905 } | |
2906 | |
2907 g_slist_free(buds); | |
4359 | 2908 } |
2909 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2910 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2911 |
11594 | 2912 gtk_widget_show(win->menu.send_to); |
2913 if (!group) | |
2914 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
2915 update_send_to_selection(win); | |
4359 | 2916 } |
2917 | |
2918 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2919 generate_invite_user_names(GaimConnection *gc) |
4359 | 2920 { |
6695 | 2921 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 2922 static GList *tmp = NULL; |
2923 | |
2924 if (tmp) | |
2925 g_list_free(tmp); | |
2926 | |
2927 tmp = g_list_append(NULL, ""); | |
2928 | |
2929 if (gc != NULL) { | |
4785 | 2930 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2931 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2932 continue; | |
6695 | 2933 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2934 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 2935 continue; |
6695 | 2936 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
2937 GaimBuddy *buddy; | |
2938 | |
2939 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2940 continue; | |
2941 | |
2942 buddy = (GaimBuddy *)bnode; | |
2943 | |
2944 if (buddy->account == gc->account && | |
2945 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 2946 tmp = g_list_insert_sorted(tmp, buddy->name, |
2947 (GCompareFunc)g_utf8_collate); | |
6695 | 2948 } |
4359 | 2949 } |
2950 } | |
2951 } | |
2952 | |
2953 return tmp; | |
2954 } | |
2955 | |
9498 | 2956 static GdkPixbuf * |
9554 | 2957 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 2958 { |
9554 | 2959 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 2960 char *filename; |
10274 | 2961 const char *image = NULL; |
9554 | 2962 |
2963 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 2964 image = "founder.png"; |
9554 | 2965 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 2966 image = "op.png"; |
9554 | 2967 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 2968 image = "halfop.png"; |
9554 | 2969 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 2970 image = "voice.png"; |
9554 | 2971 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 2972 image = "ignored.png"; |
2973 } else { | |
2974 return NULL; | |
9554 | 2975 } |
10274 | 2976 |
2977 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2978 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
2979 g_free(filename); | |
2980 | |
2981 if (!pixbuf) | |
2982 return NULL; | |
2983 | |
2984 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
2985 g_object_unref(pixbuf); | |
2986 | |
2987 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
2988 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 2989 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
2990 g_free(filename); | |
10274 | 2991 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 2992 g_object_unref(pixbuf); |
10274 | 2993 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
2994 g_object_unref(scale2); | |
9498 | 2995 } |
2996 | |
10274 | 2997 return scale; |
9498 | 2998 } |
2999 | |
4359 | 3000 static void |
11869 | 3001 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 3002 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3003 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3004 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3005 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3006 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3007 GaimPluginProtocolInfo *prpl_info; |
4359 | 3008 GtkListStore *ls; |
9498 | 3009 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3010 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3011 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3012 gboolean is_buddy; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3013 GdkColor send_color; |
11508 | 3014 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3015 gdk_color_parse(SEND_COLOR, &send_color); |
4359 | 3016 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3017 chat = GAIM_CONV_CHAT(conv); |
4359 | 3018 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3019 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3020 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3021 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3022 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3023 return; |
4359 | 3024 |
3025 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3026 | |
9554 | 3027 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 3028 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3029 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
|
3030 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3031 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3032 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3033 |
4359 | 3034 gtk_list_store_append(ls, &iter); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3035 gtk_list_store_set(ls, &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3036 CHAT_USERS_ICON_COLUMN, pixbuf, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3037 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3038 CHAT_USERS_NAME_COLUMN, name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3039 CHAT_USERS_FLAGS_COLUMN, flags, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3040 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
|
3041 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3042 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3043 |
9554 | 3044 if (pixbuf) |
3045 g_object_unref(pixbuf); | |
4359 | 3046 } |
3047 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3048 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3049 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
|
3050 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3051 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3052 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3053 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3054 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3055 return; |
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 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3058 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3059 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3060 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3061 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3062 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3063 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3064 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3065 *partial = g_strdup(name); |
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 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3068 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3069 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3070 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3071 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3072 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3073 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3074 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3075 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3076 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3077 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3078 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3079 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3080 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3081 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3082 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3083 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3084 |
9605 | 3085 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3086 tab_complete(GaimConversation *conv) |
4359 | 3087 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3088 GaimGtkConversation *gtkconv; |
4359 | 3089 GtkTextIter cursor, word_start, start_buffer; |
3090 int start; | |
3091 int most_matched = -1; | |
3092 char *entered, *partial = NULL; | |
3093 char *text; | |
8021 | 3094 char *nick_partial; |
9605 | 3095 const char *prefix; |
4359 | 3096 GList *matches = NULL; |
9605 | 3097 gboolean command = FALSE; |
4359 | 3098 |
3099 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3100 | |
3101 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3102 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3103 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3104 | |
3105 word_start = cursor; | |
3106 | |
3107 /* if there's nothing there just return */ | |
3108 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3109 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
|
3110 |
4359 | 3111 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3112 &cursor, FALSE); | |
3113 | |
3114 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3115 start = strlen(text) - 1; | |
3116 | |
8021 | 3117 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3118 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3119 start-=2; |
3120 } | |
4359 | 3121 |
3122 /* find the start of the word that we're tabbing */ | |
3123 while (start >= 0 && text[start] != ' ') { | |
3124 gtk_text_iter_backward_char(&word_start); | |
3125 start--; | |
3126 } | |
3127 | |
9605 | 3128 prefix = gaim_gtk_get_cmd_prefix(); |
3129 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3130 command = TRUE; | |
3131 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3132 } | |
3133 | |
4359 | 3134 g_free(text); |
3135 | |
3136 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3137 &cursor, FALSE); | |
3138 | |
8021 | 3139 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3140 g_free(entered); |
11338 | 3141 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3142 } |
3143 | |
8021 | 3144 nick_partial = g_malloc(strlen(entered)+1); |
3145 | |
9605 | 3146 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3147 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3148 GList *l; |
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 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3151 for (l = list; 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, l->data); |
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 g_list_free(list); |
11338 | 3156 } 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
|
3157 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3158 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3159 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
|
3160 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3161 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3162 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3163 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3164 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3165 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3166 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3167 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3168 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3169 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3170 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3171 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
|
3172 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3173 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3174 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3175 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3176 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3177 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3178 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3179 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3180 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3181 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3182 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3183 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3184 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3185 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3186 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3187 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3188 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3189 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3190 } |
9605 | 3191 } else { |
3192 g_free(nick_partial); | |
3193 g_free(entered); | |
3194 return FALSE; | |
3195 } | |
3196 | |
8021 | 3197 g_free(nick_partial); |
3198 | |
4359 | 3199 /* we're only here if we're doing new style */ |
3200 | |
3201 /* if there weren't any matches, return */ | |
3202 if (!matches) { | |
3203 /* if matches isn't set partials won't be either */ | |
3204 g_free(entered); | |
11338 | 3205 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3206 } |
3207 | |
3208 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3209 | |
3210 if (!matches->next) { | |
3211 /* there was only one match. fill it in. */ | |
3212 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3213 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3214 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3215 | |
3216 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3217 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3218 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3219 g_free(tmp); | |
3220 } | |
3221 else | |
3222 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3223 matches->data, -1); | |
3224 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3225 g_free(matches->data); |
4359 | 3226 matches = g_list_remove(matches, matches->data); |
3227 } | |
3228 else { | |
3229 /* | |
3230 * there were lots of matches, fill in as much as possible | |
3231 * and display all of them | |
3232 */ | |
3233 char *addthis = g_malloc0(1); | |
3234 | |
3235 while (matches) { | |
3236 char *tmp = addthis; | |
3237 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3238 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3239 g_free(matches->data); |
4359 | 3240 matches = g_list_remove(matches, matches->data); |
3241 } | |
3242 | |
6982 | 3243 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3244 time(NULL)); |
3245 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3246 g_free(addthis); | |
3247 } | |
3248 | |
3249 g_free(entered); | |
3250 g_free(partial); | |
9605 | 3251 |
3252 return TRUE; | |
4359 | 3253 } |
3254 | |
10810 | 3255 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3256 { |
3257 GaimPluginProtocolInfo *prpl_info = NULL; | |
3258 GaimConnection *gc; | |
10810 | 3259 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3260 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3261 char *new_topic; |
8858 | 3262 const char *current_topic; |
7971 | 3263 |
3264 gc = gaim_conversation_get_gc(conv); | |
3265 | |
3266 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3267 return; | |
3268 | |
3269 if(prpl_info->set_chat_topic == NULL) | |
3270 return; | |
3271 | |
3272 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3273 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3274 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3275 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3276 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3277 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3278 g_free(new_topic); |
7971 | 3279 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3280 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3281 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3282 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3283 |
8858 | 3284 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3285 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3286 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3287 g_free(new_topic); |
7971 | 3288 } |
3289 | |
9554 | 3290 static gint |
3291 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3292 { | |
3293 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3294 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3295 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3296 gint ret = 0; |
3297 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3298 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3299 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3300 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3301 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3302 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3303 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3304 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3305 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3306 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3307 -1); |
9554 | 3308 |
3309 if (user1 == NULL || user2 == NULL) { | |
3310 if (!(user1 == NULL && user2 == NULL)) | |
3311 ret = (user1 == NULL) ? -1: 1; | |
3312 } else if (f1 != f2) { | |
3313 /* sort more important users first */ | |
3314 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3315 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3316 ret = buddy1 ? -1 : 1; |
9554 | 3317 } else { |
10904 | 3318 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3319 } |
3320 | |
3321 g_free(user1); | |
3322 g_free(user2); | |
3323 | |
3324 return ret; | |
3325 } | |
3326 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3327 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3328 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
|
3329 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3330 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3331 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3332 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3333 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3334 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3335 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3336 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 g_return_if_fail(conv != NULL); |
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 /* 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
|
3341 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
|
3342 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3343 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
|
3344 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3345 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3346 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3347 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3348 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3349 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3350 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3351 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
|
3352 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3353 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3354 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3355 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3356 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3357 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3358 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3359 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3360 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3361 alias = gaim_buddy_get_contact_alias(buddy2); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3362 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3363 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3364 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3365 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3366 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3367 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3368 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3369 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3370 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3371 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3372 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3373 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3374 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3375 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3376 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3377 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3378 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3379 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3380 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3381 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
|
3382 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3383 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3384 GaimPluginProtocolInfo *prpl_info; |
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 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3387 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3388 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3389 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3390 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3391 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3392 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3393 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3394 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3395 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3396 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3397 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
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 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3400 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3401 for(bnode = node->child; bnode; bnode = bnode->next) { |
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 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3404 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3405 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3406 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
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 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3409 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3410 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3411 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3412 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3413 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3414 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3415 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3416 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3417 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3418 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3419 int f; |
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 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3422 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3423 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3424 /* 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
|
3425 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3426 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3427 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3428 /* 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
|
3429 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
|
3430 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3431 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
|
3432 return; |
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 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
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 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3437 char *name; |
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 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
|
3440 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3441 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3442 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
|
3443 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3444 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3445 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3446 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3447 f = gtk_tree_model_iter_next(model, &iter); |
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 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3450 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3451 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3452 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3453 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3454 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3455 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3456 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3457 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3458 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3459 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3460 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3461 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3462 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3463 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3464 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3465 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3466 /* 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
|
3467 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3468 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3469 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3470 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3471 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3472 |
4359 | 3473 static GtkWidget * |
10810 | 3474 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3475 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3476 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3477 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3478 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3479 GaimConnection *gc; |
4359 | 3480 GtkWidget *vpaned, *hpaned; |
10175 | 3481 GtkWidget *vbox, *hbox, *frame; |
4359 | 3482 GtkWidget *lbox, *bbox; |
3483 GtkWidget *label; | |
3484 GtkWidget *list; | |
3485 GtkWidget *button; | |
7949 | 3486 GtkWidget *sw; |
4359 | 3487 GtkListStore *ls; |
3488 GtkCellRenderer *rend; | |
3489 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3490 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3491 GList *focus_chain = NULL; |
4359 | 3492 |
3493 gtkchat = gtkconv->u.chat; | |
3494 gc = gaim_conversation_get_gc(conv); | |
3495 | |
3496 /* Setup the outer pane. */ | |
3497 vpaned = gtk_vpaned_new(); | |
3498 gtk_widget_show(vpaned); | |
3499 | |
3500 /* Setup the top part of the pane. */ | |
11243 | 3501 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3502 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3503 gtk_widget_show(vbox); |
3504 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3505 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3506 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3507 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3508 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3509 { |
11243 | 3510 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3511 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3512 gtk_widget_show(hbox); |
3513 | |
3514 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3515 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3516 gtk_widget_show(label); |
3517 | |
3518 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3519 |
7971 | 3520 if(prpl_info->set_chat_topic == NULL) { |
3521 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3522 } else { | |
3523 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3524 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3525 } |
3526 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3527 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3528 gtk_widget_show(gtkchat->topic_text); |
3529 } | |
3530 | |
3531 /* Setup the horizontal pane. */ | |
3532 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3533 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3534 gtk_widget_show(hpaned); |
3535 | |
10175 | 3536 /* Setup gtkihmtml. */ |
3537 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3538 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3539 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3540 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3541 gtk_widget_show(frame); | |
3542 | |
3543 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3544 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3545 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3546 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3547 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3548 |
4359 | 3549 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3550 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3551 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3552 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3553 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3554 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3555 |
3556 /* Build the right pane. */ | |
11243 | 3557 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3558 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3559 gtk_widget_show(lbox); |
3560 | |
3561 /* Setup the label telling how many people are in the room. */ | |
3562 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3563 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3564 gtk_widget_show(gtkchat->count); | |
3565 | |
3566 /* Setup the list of users. */ | |
7949 | 3567 sw = gtk_scrolled_window_new(NULL, NULL); |
3568 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3569 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3570 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3571 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3572 gtk_widget_show(sw); | |
4359 | 3573 |
9554 | 3574 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
|
3575 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
|
3576 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3577 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3578 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3579 GTK_SORT_ASCENDING); |
3580 | |
3581 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3582 | |
9498 | 3583 rend = gtk_cell_renderer_pixbuf_new(); |
3584 | |
4359 | 3585 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3586 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3587 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3588 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3589 |
3590 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3591 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3592 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3593 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3594 |
9498 | 3595 rend = gtk_cell_renderer_text_new(); |
3596 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3597 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3598 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3599 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3600 NULL); |
4359 | 3601 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3602 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3603 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3604 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3605 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3606 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3607 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3608 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3609 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3610 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3611 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3612 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3613 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3614 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3615 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3616 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3617 #endif |
4359 | 3618 |
3619 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3620 | |
3621 gtk_widget_set_size_request(list, 150, -1); | |
3622 | |
3623 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3624 gtk_widget_show(list); | |
3625 | |
3626 gtkchat->list = list; | |
3627 | |
7949 | 3628 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3629 |
3630 /* Setup the user list toolbar. */ | |
11243 | 3631 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3632 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3633 gtk_widget_show(bbox); | |
3634 | |
3635 /* IM */ | |
10221 | 3636 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3637 GAIM_BUTTON_VERTICAL); |
10500 | 3638 gtkchat->userlist_im = button; |
4359 | 3639 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3640 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
|
3641 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3642 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3643 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3644 |
3645 gtk_widget_show(button); | |
3646 | |
3647 /* Ignore */ | |
3648 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3649 GAIM_BUTTON_VERTICAL); | |
10500 | 3650 gtkchat->userlist_ignore = button; |
4359 | 3651 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3652 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
|
3653 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3654 _("Ignore the user"), NULL); |
4359 | 3655 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3656 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3657 gtk_widget_show(button); |
3658 | |
3659 /* Info */ | |
3660 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3661 GAIM_BUTTON_VERTICAL); | |
10500 | 3662 gtkchat->userlist_info = button; |
4359 | 3663 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3664 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3665 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3666 _("Get the user's information"), NULL); |
4359 | 3667 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3668 G_CALLBACK(info_cb), gtkconv); |
4359 | 3669 |
3670 gtk_widget_show(button); | |
3671 | |
10175 | 3672 /* Setup the bottom half of the conversation window */ |
11243 | 3673 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3674 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3675 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3676 |
11243 | 3677 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3678 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3679 gtk_widget_show(gtkconv->lower_hbox); | |
3680 | |
11243 | 3681 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3682 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3683 gtk_widget_show(vbox); | |
3684 | |
10175 | 3685 /* Setup the toolbar, entry widget and all signals */ |
3686 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3687 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3688 gtk_widget_show(frame); |
3689 | |
9005 | 3690 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3691 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3692 gaim_account_get_protocol_name(conv->account)); |
10175 | 3693 gtk_widget_set_size_request(gtkconv->entry, -1, |
3694 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3695 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3696 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3697 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3698 |
3699 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3700 G_CALLBACK(entry_key_press_cb), gtkconv); |
10115 | 3701 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
10810 | 3702 G_CALLBACK(send_cb), gtkconv); |
4359 | 3703 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3704 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3705 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3706 G_CALLBACK(size_allocate_cb), gtkconv); |
3707 | |
3708 default_formatize(gtkconv); | |
4359 | 3709 |
9080 | 3710 /* |
3711 * Focus for chat windows should be as follows: | |
3712 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3713 * user list buttons -> entry -> buttons at bottom | |
3714 */ | |
9332 | 3715 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3716 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3717 | |
4359 | 3718 return vpaned; |
3719 } | |
3720 | |
3721 static GtkWidget * | |
10810 | 3722 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 3723 { |
10810 | 3724 GaimConversation *conv = gtkconv->active_conv; |
10175 | 3725 GtkWidget *frame; |
4359 | 3726 GtkWidget *paned; |
10175 | 3727 GtkWidget *vbox; |
3728 GtkWidget *vbox2; | |
9080 | 3729 GList *focus_chain = NULL; |
4359 | 3730 |
10175 | 3731 /* Setup the outer pane */ |
4359 | 3732 paned = gtk_vpaned_new(); |
3733 gtk_widget_show(paned); | |
3734 | |
10175 | 3735 /* Setup the top part of the pane */ |
11243 | 3736 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3737 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3738 gtk_widget_show(vbox); |
3739 | |
10175 | 3740 /* Setup the gtkimhtml widget */ |
3741 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3742 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3743 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 3744 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
3745 gtk_widget_show(frame); | |
3746 | |
3747 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3748 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3749 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 3750 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3751 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3752 |
3753 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 3754 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 3755 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 3756 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3757 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 3758 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 3759 |
10175 | 3760 /* Setup the bottom half of the conversation window */ |
11243 | 3761 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3762 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3763 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3764 |
11243 | 3765 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3766 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3767 gtk_widget_show(gtkconv->lower_hbox); | |
3768 | |
11243 | 3769 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3770 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
3771 gtk_widget_show(vbox2); | |
8821 | 3772 |
10175 | 3773 /* Setup the toolbar, entry widget and all signals */ |
3774 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3775 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 3776 gtk_widget_show(frame); |
3777 | |
9005 | 3778 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3779 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3780 gaim_account_get_protocol_name(conv->account)); |
10175 | 3781 gtk_widget_set_size_request(gtkconv->entry, -1, |
3782 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3783 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3784 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3785 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
|
3786 |
4359 | 3787 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 3788 G_CALLBACK(entry_key_press_cb), gtkconv); |
3789 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), gtkconv); | |
4359 | 3790 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3791 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3792 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3793 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3794 |
3795 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 3796 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 3797 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 3798 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 3799 |
8481 | 3800 /* had to move this after the imtoolbar is attached so that the |
3801 * signals get fired to toggle the buttons on the toolbar as well. | |
3802 */ | |
10810 | 3803 default_formatize(gtkconv); |
4359 | 3804 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3805 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3806 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3807 |
8758 | 3808 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 3809 gtkconv->u.im->show_icon = TRUE; |
4359 | 3810 |
9080 | 3811 /* |
3812 * Focus for IM windows should be as follows: | |
10356 | 3813 * Tab title -> conversation scrollback -> entry |
9080 | 3814 */ |
9332 | 3815 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3816 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 3817 |
4359 | 3818 return paned; |
3819 } | |
3820 | |
3821 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3822 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 3823 GtkSelectionData *sd, guint info, guint t, |
3824 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3825 { |
10810 | 3826 GaimConversation *conv = gtkconv->active_conv; |
11581 | 3827 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3828 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3829 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3830 { |
4781 | 3831 GaimBlistNode *n = NULL; |
6695 | 3832 GaimBuddy *b; |
11581 | 3833 GaimGtkConversation *gtkconv = NULL; |
9622 | 3834 |
11812 | 3835 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3836 |
6695 | 3837 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
3838 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
3839 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
3840 b = (GaimBuddy*)n; | |
3841 else | |
4781 | 3842 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3843 |
9622 | 3844 /* |
3845 * If we already have an open conversation with this buddy, then | |
3846 * just move the conv to this window. Otherwise, create a new | |
3847 * conv and add it to this window. | |
3848 */ | |
11338 | 3849 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 3850 if (c != NULL) { |
11581 | 3851 GaimGtkWindow *oldwin; |
3852 gtkconv = GAIM_GTK_CONVERSATION(c); | |
3853 oldwin = gtkconv->win; | |
9622 | 3854 if (oldwin != win) { |
11581 | 3855 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
3856 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 3857 } |
3858 } else { | |
11338 | 3859 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 3860 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3861 if (gtkconv->win != win) |
3862 { | |
3863 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3864 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3865 } | |
9622 | 3866 } |
3867 | |
3868 /* Make this conversation the active conversation */ | |
11581 | 3869 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3870 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3871 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 3872 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3873 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
|
3874 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3875 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3876 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3877 GaimAccount *account; |
11581 | 3878 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3879 |
11137 | 3880 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 3881 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3882 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3883 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3884 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3885 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3886 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3887 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3888 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3889 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3890 { |
11338 | 3891 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 3892 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3893 if (gtkconv->win != win) |
3894 { | |
3895 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3896 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3897 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3898 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3899 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3900 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3901 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3902 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3903 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3904 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3905 } |
9525 | 3906 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 3907 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 3908 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 3909 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 3910 } |
10145 | 3911 else |
3912 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3913 } |
4359 | 3914 |
3915 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3916 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3917 { |
10145 | 3918 GTK_IMHTML_DND_TARGETS, |
3919 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
3920 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3921 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3922 |
10810 | 3923 static GaimGtkConversation * |
3924 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
3925 { | |
3926 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
3927 GaimContact *c; | |
3928 GaimBlistNode *cn; | |
10935 | 3929 |
10810 | 3930 if (!bud) |
3931 return NULL; | |
10935 | 3932 |
10810 | 3933 if (!(c = gaim_buddy_get_contact(bud))) |
3934 return NULL; | |
10935 | 3935 |
10810 | 3936 cn = (GaimBlistNode *)c; |
3937 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
3938 GaimConversation *conv; | |
11338 | 3939 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 3940 if (conv->ui_data) |
3941 return conv->ui_data; | |
3942 } | |
3943 } | |
10935 | 3944 |
10810 | 3945 return NULL; |
3946 } | |
3947 | |
11855 | 3948 static void |
3949 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
3950 { | |
3951 GList *list; | |
3952 | |
3953 g_return_if_fail(bnode); | |
3954 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
3955 | |
3956 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
3957 { | |
3958 GaimGtkWindow *win = list->data; | |
3959 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
3960 | |
3961 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
3962 continue; | |
3963 | |
3964 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); | |
3965 } | |
3966 } | |
3967 | |
11581 | 3968 /************************************************************************** |
3969 * Conversation UI operations | |
3970 **************************************************************************/ | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
3971 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
3972 private_gtkconv_new(GaimConversation *conv, gboolean hidden) |
11581 | 3973 { |
3974 GaimGtkConversation *gtkconv; | |
3975 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 3976 GtkWidget *pane = NULL; |
3977 GtkWidget *tab_cont; | |
11581 | 3978 |
3979 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 3980 conv->ui_data = gtkconv; |
3981 if (!g_list_find(gtkconv->convs, conv)) | |
3982 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 3983 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 3984 return; |
4359 | 3985 } |
3986 | |
11581 | 3987 gtkconv = g_new0(GaimGtkConversation, 1); |
3988 conv->ui_data = gtkconv; | |
3989 gtkconv->active_conv = conv; | |
3990 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
3991 | |
3992 /* Setup some initial variables. */ | |
3993 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
3994 gtkconv->tooltips = gtk_tooltips_new(); | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
3995 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
3996 gtkconv->unseen_count = 0; |
11581 | 3997 |
3998 if (conv_type == GAIM_CONV_TYPE_IM) { | |
3999 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
4000 | |
4001 pane = setup_im_pane(gtkconv); | |
4002 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
4003 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
4004 pane = setup_chat_pane(gtkconv); | |
4005 } | |
4006 | |
12101 | 4007 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
4008 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
4009 | |
11581 | 4010 if (pane == NULL) { |
4011 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
4012 g_free(gtkconv->u.chat); | |
4013 else if (conv_type == GAIM_CONV_TYPE_IM) | |
4014 g_free(gtkconv->u.im); | |
4015 | |
4016 g_free(gtkconv); | |
4017 conv->ui_data = NULL; | |
4018 return; | |
10449 | 4019 } |
11581 | 4020 |
4021 /* Setup drag-and-drop */ | |
4022 gtk_drag_dest_set(pane, | |
4023 GTK_DEST_DEFAULT_MOTION | | |
4024 GTK_DEST_DEFAULT_DROP, | |
4025 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4026 GDK_ACTION_COPY); | |
4027 gtk_drag_dest_set(pane, | |
4028 GTK_DEST_DEFAULT_MOTION | | |
4029 GTK_DEST_DEFAULT_DROP, | |
4030 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4031 GDK_ACTION_COPY); | |
4032 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4033 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4034 GDK_ACTION_COPY); | |
4035 | |
4036 gtk_drag_dest_set(gtkconv->entry, 0, | |
4037 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4038 GDK_ACTION_COPY); | |
4039 | |
4040 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
4041 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4042 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
4043 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4044 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
4045 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4046 | |
4047 /* Setup the container for the tab. */ | |
4048 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
4049 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
4050 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
4051 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
4052 gtk_widget_show(pane); | |
4053 | |
4054 gtkconv->make_sound = TRUE; | |
4055 | |
4056 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
4057 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4058 else |
11581 | 4059 gtk_widget_hide(gtkconv->toolbar); |
4060 | |
12188 | 4061 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), |
4062 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4063 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4064 gaim_account_get_protocol_name(conv->account)); |
11581 | 4065 |
4066 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
4067 G_CALLBACK(gtk_widget_grab_focus), | |
4068 gtkconv->entry); | |
4069 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4070 if (hidden) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4071 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4072 else |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4073 gaim_gtkconv_placement_place(gtkconv); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
4074 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
4075 if(NULL == nick_colors) |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
4076 nick_colors = generate_nick_colors(NUM_NICK_COLORS, gtk_widget_get_style(gtkconv->imhtml)->base[GTK_STATE_NORMAL]); |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4077 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4078 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4079 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4080 gaim_gtkconv_new_hidden(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4081 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4082 private_gtkconv_new(conv, TRUE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4083 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4084 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4085 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4086 gaim_gtkconv_new(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4087 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4088 private_gtkconv_new(conv, FALSE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4089 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4090 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4091 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4092 received_im_msg_cb(GaimAccount *account, char *sender, char *message, |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4093 GaimConversation *conv, int flags) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4094 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4095 GaimConversationUiOps *ui_ops = gaim_gtk_conversations_get_conv_ui_ops(); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4096 if(conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4097 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4098 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4099 /* create hidden conv if hide_new pref is always */ |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4100 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "always")==0) { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4101 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4102 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4103 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4104 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4105 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4106 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4107 /* create hidden conv if hide_new pref is away and account is away */ |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4108 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away")==0 |
12310 | 4109 && !gaim_status_is_available(gaim_account_get_active_status(account))) { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4110 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4111 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4112 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4113 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4114 } |
11581 | 4115 } |
4116 | |
4359 | 4117 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4118 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4119 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4120 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4121 |
10810 | 4122 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4123 /* Don't destroy ourselves until all our convos are gone */ | |
4124 if (gtkconv->convs) | |
4125 return; | |
11508 | 4126 |
11581 | 4127 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4128 | |
9504 | 4129 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4130 gaim_request_close_with_handle(conv); | |
4359 | 4131 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4132 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4133 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4134 |
11338 | 4135 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4136 if (gtkconv->u.im->icon_timer != 0) |
4137 g_source_remove(gtkconv->u.im->icon_timer); | |
4138 | |
4359 | 4139 if (gtkconv->u.im->anim != NULL) |
4793 | 4140 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4141 |
4142 g_free(gtkconv->u.im); | |
11581 | 4143 } 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
|
4144 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4145 g_free(gtkconv->u.chat); |
4146 } | |
4147 | |
4633 | 4148 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4149 | |
4359 | 4150 g_free(gtkconv); |
4151 } | |
4152 | |
4153 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4154 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4155 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4156 time_t mtime) |
4359 | 4157 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4158 GaimGtkConversation *gtkconv; |
4359 | 4159 |
4160 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4161 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4162 |
6982 | 4163 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4164 } |
4165 | |
4166 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4167 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4168 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4169 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4170 GaimGtkConversation *gtkconv; |
4359 | 4171 |
4172 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4173 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4174 |
10398 | 4175 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4176 |
6982 | 4177 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4178 } |
4179 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4180 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4181 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4182 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4183 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4184 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4185 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4186 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4187 char *buddyname; |
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 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4190 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4191 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4192 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4193 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4194 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4195 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4196 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4197 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4198 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4199 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4200 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4201 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4202 GtkTextIter start, end; |
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 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4205 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4206 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4207 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4208 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4209 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4210 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4211 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4212 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4213 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4214 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4215 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4216 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4217 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4218 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4219 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4220 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4221 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4222 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4223 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4224 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4225 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4226 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4227 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4228 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4229 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4230 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4231 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4232 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4233 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4234 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4235 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4236 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4237 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4238 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4239 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4240 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4241 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4242 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4243 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4244 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4245 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4246 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4247 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4248 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4249 buddytag = gtk_text_buffer_create_tag( |
11096 | 4250 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4251 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4252 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4253 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4254 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4255 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4256 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4257 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4258 |
4359 | 4259 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4260 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4261 const char *message, GaimMessageFlags flags, |
4359 | 4262 time_t mtime) |
4263 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4264 GaimGtkConversation *gtkconv; |
11581 | 4265 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4266 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4267 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4268 GaimPluginProtocolInfo *prpl_info; |
4359 | 4269 int gtk_font_options = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4270 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4271 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4272 int line_count; |
4359 | 4273 char buf2[BUF_LONG]; |
4274 char mdate[64]; | |
4275 char color[10]; | |
4276 char *str; | |
4277 char *with_font_tag; | |
4896 | 4278 char *sml_attrib = NULL; |
6982 | 4279 size_t length = strlen(message) + 1; |
4895 | 4280 |
4359 | 4281 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4282 |
4283 /* Set the active conversation to the one that just messaged us. */ | |
4284 /* 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
|
4285 gaim_gtkconv_set_active_conversation(conv); |
11581 | 4286 |
4359 | 4287 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4288 account = gaim_conversation_get_account(conv); |
11581 | 4289 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4290 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4291 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4292 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4293 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4294 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4295 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4296 /* 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
|
4297 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4298 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4299 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4300 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4301 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4302 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4303 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4304 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4305 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4306 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4307 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4308 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4309 |
8677 | 4310 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
4311 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
4312 | |
5133 | 4313 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4314 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4315 else | |
4316 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4317 |
4896 | 4318 if(gc) |
9699 | 4319 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4320 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4321 |
10503 | 4322 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4323 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4324 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4325 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4326 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4327 |
7956 | 4328 /* this is gonna crash one day, I can feel it. */ |
4329 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4330 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4331 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4332 } |
4359 | 4333 |
10737 | 4334 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4335 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4336 g_snprintf(buf2, sizeof(buf2), |
8690 | 4337 "<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
|
4338 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4339 |
8962 | 4340 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 4341 |
8722 | 4342 } else if (flags & GAIM_MESSAGE_ERROR) { |
4343 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4344 "<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
|
4345 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4346 |
8962 | 4347 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
4348 | |
7431 | 4349 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4350 g_snprintf(buf2, BUF_LONG, |
8690 | 4351 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4352 sml_attrib ? sml_attrib : "", message); |
7440 | 4353 |
10884 | 4354 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
10346 | 4355 } else if (flags & GAIM_MESSAGE_RAW) { |
10348 | 4356 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); |
10346 | 4357 } else { |
4895 | 4358 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4359 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
|
4360 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4361 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4362 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
|
4363 int tag_end_offset = 0; |
7440 | 4364 |
6621 | 4365 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4366 str = g_malloc(1024); |
7440 | 4367 |
4359 | 4368 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4369 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4370 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4371 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4372 tag_start_offset += 3; |
4359 | 4373 } |
4374 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4375 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4376 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4377 tag_end_offset = 2; |
4359 | 4378 strcpy(color, "#00FF00"); |
4379 } | |
7440 | 4380 } |
4359 | 4381 else { |
10504 | 4382 if (gaim_message_meify(new_message, -1)) { |
4359 | 4383 str = g_malloc(1024); |
7440 | 4384 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4385 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4386 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
|
4387 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4388 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4389 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4390 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4391 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4392 } |
7440 | 4393 |
6621 | 4394 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4395 strcpy(color, "#AF7F00"); |
4396 else | |
4397 strcpy(color, "#062585"); | |
4398 } | |
4399 else { | |
4400 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4401 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4402 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
|
4403 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4404 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4405 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4406 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4407 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4408 } |
6621 | 4409 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4410 strcpy(color, "#AF7F00"); |
6621 | 4411 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4412 if (flags & GAIM_MESSAGE_COLORIZE) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4413 GdkColor *col = get_nick_color(gtkconv, alias); |
10346 | 4414 |
10108 | 4415 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4416 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4417 } else |
7854 | 4418 strcpy(color, RECV_COLOR); |
4359 | 4419 } |
6621 | 4420 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4421 strcpy(color, SEND_COLOR); |
10892 | 4422 else { |
4423 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4424 strcpy(color, "#000000"); | |
4425 } | |
4359 | 4426 } |
4427 } | |
10892 | 4428 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4429 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4430 g_free(alias_escaped); |
11508 | 4431 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4432 /* 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
|
4433 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4434 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4435 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4436 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4437 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4438 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4439 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4440 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4441 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4442 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4443 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4444 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4445 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4446 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4447 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4448 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4449 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4450 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4451 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4452 /* 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
|
4453 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4454 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4455 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4456 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4457 } |
7440 | 4458 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4459 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4460 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4461 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4462 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4463 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4464 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4465 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4466 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4467 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4468 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4469 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4470 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4471 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4472 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4473 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4474 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4475 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4476 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4477 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4478 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4479 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4480 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4481 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4482 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4483 |
4359 | 4484 g_free(str); |
4485 | |
4895 | 4486 if(gc){ |
4896 | 4487 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4488 char *post = "</font>"; |
4489 int pre_len = strlen(pre); | |
4490 int post_len = strlen(post); | |
7440 | 4491 |
4895 | 4492 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4493 |
4895 | 4494 strcpy(with_font_tag, pre); |
4495 memcpy(with_font_tag + pre_len, new_message, length); | |
4496 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4497 |
4895 | 4498 length += pre_len + post_len; |
4499 g_free(pre); | |
4500 } | |
4608 | 4501 else |
4895 | 4502 with_font_tag = g_memdup(new_message, length); |
7440 | 4503 |
8962 | 4504 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
4505 with_font_tag, gtk_font_options); | |
7440 | 4506 |
4507 g_free(with_font_tag); | |
7447 | 4508 g_free(new_message); |
7440 | 4509 } |
4510 | |
5012 | 4511 if(sml_attrib) |
4512 g_free(sml_attrib); | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4513 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4514 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4515 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4516 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4517 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4518 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4519 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4520 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4521 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4522 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4523 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4524 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
|
4525 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4526 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4527 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4528 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4529 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4530 } |
4359 | 4531 } |
4532 | |
4533 static void | |
11869 | 4534 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
|
4535 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4536 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4537 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4538 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4539 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4540 GList *ll; |
11869 | 4541 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4542 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4543 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4544 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4545 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4546 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4547 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4548 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4549 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
|
4550 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4551 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4552 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4553 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4554 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4555 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4556 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4557 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4558 l = users; |
11869 | 4559 ll = flags; |
4560 lll = aliases; | |
4561 while (l != NULL && ll != NULL && lll != NULL) { | |
4562 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
|
4563 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4564 ll = ll->next; |
11869 | 4565 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4566 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4567 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4568 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4569 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4570 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
|
4571 const char *new_name, const char *new_alias) |
4359 | 4572 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4573 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4574 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4575 GaimGtkChatPane *gtkchat; |
11869 | 4576 GaimConvChatBuddyFlags flags; |
4359 | 4577 GtkTreeIter iter; |
4578 GtkTreeModel *model; | |
4579 int f = 1; | |
4580 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4581 chat = GAIM_CONV_CHAT(conv); |
4359 | 4582 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4583 gtkchat = gtkconv->u.chat; | |
4584 | |
9554 | 4585 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4586 | |
4587 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4588 return; | |
4589 | |
4590 while (f != 0) { | |
4591 char *val; | |
4592 | |
11869 | 4593 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4594 |
4595 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4596 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4597 g_free(val); | |
4359 | 4598 break; |
4599 } | |
9554 | 4600 |
4601 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4602 | |
4603 g_free(val); | |
4359 | 4604 } |
4605 | |
9554 | 4606 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4607 return; |
4608 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4609 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4610 |
11869 | 4611 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4612 } |
4613 | |
4614 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4615 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 4616 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4617 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4618 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4619 GaimGtkChatPane *gtkchat; |
4359 | 4620 GtkTreeIter iter; |
4621 GtkTreeModel *model; | |
4622 char tmp[BUF_LONG]; | |
4623 int num_users; | |
4624 int f = 1; | |
4625 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4626 chat = GAIM_CONV_CHAT(conv); |
4359 | 4627 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4628 gtkchat = gtkconv->u.chat; | |
4629 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4630 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
|
4631 |
9554 | 4632 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4633 | |
4634 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4635 return; | |
4636 | |
4637 while (f != 0) { | |
4638 char *val; | |
4639 | |
4640 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4641 | |
4642 if (!gaim_utf8_strcasecmp(user, val)) { | |
4643 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4644 g_free(val); | |
4359 | 4645 break; |
4646 } | |
9554 | 4647 |
4648 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4649 | |
4650 g_free(val); | |
4359 | 4651 } |
4652 | |
9554 | 4653 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 4654 return; |
4655 | |
4656 g_snprintf(tmp, sizeof(tmp), | |
9554 | 4657 ngettext("%d person in room", "%d people in room", |
4658 num_users), num_users); | |
4359 | 4659 |
4660 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4661 | |
4662 } | |
4663 | |
4664 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4665 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4666 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4667 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4668 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4669 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4670 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4671 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4672 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4673 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4674 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4675 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4676 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4677 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4678 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4679 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4680 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4681 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
|
4682 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4683 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4684 for (l = users; l != NULL; l = l->next) { |
9554 | 4685 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4686 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4687 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4688 continue; |
4689 | |
4690 do { | |
4691 char *val; | |
4692 | |
4693 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4694 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4695 | |
9696 | 4696 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4697 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4698 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4699 #else |
4700 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4701 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4702 #endif | |
4703 } | |
9554 | 4704 else |
4705 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4706 | |
4707 g_free(val); | |
4708 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4709 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4710 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4711 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4712 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4713 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4714 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4715 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4716 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4717 |
9554 | 4718 static void |
4719 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4720 { | |
4721 GaimConvChat *chat; | |
11869 | 4722 GaimConvChatBuddyFlags flags; |
9554 | 4723 GaimGtkConversation *gtkconv; |
4724 GaimGtkChatPane *gtkchat; | |
4725 GtkTreeIter iter; | |
4726 GtkTreeModel *model; | |
4727 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4728 char *alias = NULL; |
9554 | 4729 |
4730 chat = GAIM_CONV_CHAT(conv); | |
4731 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4732 gtkchat = gtkconv->u.chat; | |
4733 | |
4734 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4735 | |
4736 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4737 return; | |
4738 | |
4739 while (f != 0) { | |
4740 char *val; | |
4741 | |
4742 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4743 | |
4744 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4745 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4746 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4747 g_free(val); | |
4748 break; | |
4749 } | |
4750 | |
4751 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4752 | |
4753 g_free(val); | |
4754 } | |
4755 | |
4756 if (!gaim_conv_chat_find_user(chat, user)) | |
4757 return; | |
4758 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4759 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4760 |
11869 | 4761 flags = gaim_conv_chat_user_get_flags(chat, user); |
4762 | |
4763 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4764 g_free(alias); |
9554 | 4765 } |
4766 | |
11581 | 4767 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4768 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4769 { |
11581 | 4770 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4771 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4772 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4773 |
11581 | 4774 win = gtkconv->win; |
4775 | |
4776 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
|
4777 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4778 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4779 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4780 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4781 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4782 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4783 |
12335 | 4784 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data) |
4785 { | |
4786 GtkIMHtmlSmiley *smiley; | |
4787 | |
4788 smiley = (GtkIMHtmlSmiley *)user_data; | |
4789 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
4790 | |
4791 if (smiley->icon) | |
4792 g_object_ref(G_OBJECT(smiley->icon)); | |
4793 #ifdef DEBUG_CUSTOM_SMILEY | |
4794 gaim_debug_info("custom-smiley", "%s(): got GdkPixbufAnimation %p for smiley '%s'\n", __FUNCTION__, smiley->icon, smiley->smile); | |
4795 #endif | |
4796 } | |
4797 | |
4798 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data) | |
4799 { | |
4800 GtkIMHtmlSmiley *smiley; | |
4801 GtkWidget *icon = NULL; | |
4802 GtkTextChildAnchor *anchor = NULL; | |
4803 GSList *current = NULL; | |
4804 | |
4805 smiley = (GtkIMHtmlSmiley *)user_data; | |
4806 if (!smiley->imhtml) { | |
4807 #ifdef DEBUG_CUSTOM_SMILEY | |
4808 gaim_debug_error("custom-smiley", "%s(): orphan smiley found: %p\n", __FUNCTION__, smiley); | |
4809 #endif | |
4810 g_object_unref(G_OBJECT(loader)); | |
4811 smiley->loader = NULL; | |
4812 return; | |
4813 } | |
4814 | |
4815 for (current = smiley->anchors; current; current = g_slist_next(current)) { | |
4816 | |
4817 icon = gtk_image_new_from_animation(smiley->icon); | |
4818 | |
4819 #ifdef DEBUG_CUSTOM_SMILEY | |
4820 gaim_debug_info("custom-smiley", "%s(): got GtkImage %p from GtkPixbufAnimation %p for smiley '%s'\n", | |
4821 __FUNCTION__, icon, smiley->icon, smiley->smile); | |
4822 #endif | |
4823 if (icon) { | |
4824 gtk_widget_show(icon); | |
4825 | |
4826 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); | |
4827 | |
4828 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smiley->smile)), g_free); | |
4829 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley->smile), g_free); | |
4830 | |
4831 if (smiley->imhtml) | |
4832 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(smiley->imhtml), icon, anchor); | |
4833 } | |
4834 | |
4835 } | |
4836 | |
4837 g_slist_free(smiley->anchors); | |
4838 smiley->anchors = NULL; | |
4839 | |
4840 g_object_unref(G_OBJECT(loader)); | |
4841 smiley->loader = NULL; | |
4842 } | |
4843 | |
10526 | 4844 static gboolean |
4845 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
4846 { | |
4847 GaimGtkConversation *gtkconv; | |
4848 GtkIMHtmlSmiley *smiley; | |
4849 GdkPixbufLoader *loader; | |
11525 | 4850 struct smiley_list *list; |
4851 const char *sml = NULL, *conv_sml; | |
4852 | |
4853 if (!conv || !smile || !*smile) { | |
10526 | 4854 return FALSE; |
4855 } | |
4856 | |
11525 | 4857 /* If smileys are off, return false */ |
4858 if (gaim_gtkthemes_smileys_disabled()) | |
4859 return FALSE; | |
4860 | |
4861 /* If possible add this smiley to the current theme. | |
4862 * The addition is only temporary: custom smilies aren't saved to disk. */ | |
4863 conv_sml = gaim_account_get_protocol_name(conv->account); | |
10526 | 4864 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11525 | 4865 |
4866 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | |
4867 if (!strcmp(list->sml, conv_sml)) { | |
4868 sml = list->sml; | |
4869 break; | |
4870 } | |
4871 } | |
4872 | |
10526 | 4873 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
4874 | |
4875 if (smiley) { | |
11525 | 4876 |
4877 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
4878 return FALSE; | |
4879 } | |
4880 | |
4881 /* Close the old GdkPixbufAnimation, then create a new one for | |
4882 * the smiley we are about to receive */ | |
4883 g_object_unref(G_OBJECT(smiley->icon)); | |
4884 | |
4885 smiley->loader = gdk_pixbuf_loader_new(); | |
12335 | 4886 smiley->icon = NULL; |
4887 | |
4888 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); | |
4889 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
4890 | |
11525 | 4891 return TRUE; |
10526 | 4892 } |
4893 | |
4894 loader = gdk_pixbuf_loader_new(); | |
4895 | |
4896 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
4897 /* 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
|
4898 GtkIMHtmlSmiley by opaque */ |
10526 | 4899 smiley = g_new0(GtkIMHtmlSmiley, 1); |
4900 smiley->file = NULL; | |
4901 smiley->smile = g_strdup(smile); | |
4902 smiley->loader = loader; | |
11525 | 4903 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 4904 |
12335 | 4905 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); |
4906 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
11525 | 4907 |
10526 | 4908 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); |
10537 | 4909 |
10526 | 4910 return TRUE; |
4911 } | |
4912 | |
10537 | 4913 static void |
10526 | 4914 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 4915 const guchar *data, gsize size) |
10526 | 4916 { |
4917 GaimGtkConversation *gtkconv; | |
4918 GtkIMHtmlSmiley *smiley; | |
10537 | 4919 GdkPixbufLoader *loader; |
10526 | 4920 const char *sml; |
4921 | |
4922 sml = gaim_account_get_protocol_name(conv->account); | |
4923 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4924 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4925 | |
10537 | 4926 if (!smiley) |
10526 | 4927 return; |
10537 | 4928 |
10526 | 4929 loader = smiley->loader; |
10537 | 4930 if (!loader) |
10526 | 4931 return; |
4932 | |
4933 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
4934 } | |
4935 | |
4936 static void | |
4937 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
4938 { | |
4939 GaimGtkConversation *gtkconv; | |
4940 GtkIMHtmlSmiley *smiley; | |
4941 GdkPixbufLoader *loader; | |
4942 const char *sml; | |
4943 | |
4944 g_return_if_fail(conv != NULL); | |
4945 g_return_if_fail(smile != NULL); | |
4946 | |
4947 sml = gaim_account_get_protocol_name(conv->account); | |
4948 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4949 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4950 | |
10537 | 4951 if (!smiley) |
10526 | 4952 return; |
4953 | |
4954 loader = smiley->loader; | |
4955 | |
10537 | 4956 if (!loader) |
10526 | 4957 return; |
10537 | 4958 |
12335 | 4959 |
11525 | 4960 |
10526 | 4961 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
4962 | |
4963 gdk_pixbuf_loader_close(loader, NULL); | |
12335 | 4964 |
10526 | 4965 } |
4966 | |
11581 | 4967 /* |
4968 * Makes sure all the menu items and all the buttons are hidden/shown and | |
4969 * sensitive/insensitive. This is called after changing tabs and when an | |
4970 * account signs on or off. | |
4971 */ | |
4972 static void | |
4973 gray_stuff_out(GaimGtkConversation *gtkconv) | |
4974 { | |
4975 GaimGtkWindow *win; | |
4976 GaimConversation *conv = gtkconv->active_conv; | |
4977 GaimConnection *gc; | |
4978 GaimPluginProtocolInfo *prpl_info = NULL; | |
4979 GdkPixbuf *window_icon = NULL; | |
4980 GtkIMHtmlButtons buttons; | |
4981 GaimAccount *account; | |
4982 | |
4983 win = gaim_gtkconv_get_window(gtkconv); | |
4984 gc = gaim_conversation_get_gc(conv); | |
4985 account = gaim_conversation_get_account(conv); | |
4986 | |
4987 if (gc != NULL) | |
4988 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
4989 | |
11594 | 4990 if (win->menu.send_to != NULL) |
11734 | 4991 update_send_to_selection(win); |
11581 | 4992 |
4993 /* | |
4994 * Handle hiding and showing stuff based on what type of conv this is. | |
4995 * Stuff that Gaim IMs support in general should be shown for IM | |
4996 * conversations. Stuff that Gaim chats support in general should be | |
4997 * shown for chat conversations. It doesn't matter whether the PRPL | |
4998 * supports it or not--that only affects if the button or menu item | |
4999 * is sensitive or not. | |
5000 */ | |
5001 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
5002 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
5003 | |
5004 /* Deal with menu items */ | |
5005 gtk_widget_show(win->menu.view_log); | |
5006 gtk_widget_show(win->menu.send_file); | |
5007 gtk_widget_show(win->menu.add_pounce); | |
5008 gtk_widget_show(win->menu.get_info); | |
5009 gtk_widget_hide(win->menu.invite); | |
5010 gtk_widget_show(win->menu.alias); | |
5011 gtk_widget_show(win->menu.block); | |
5012 | |
5013 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
5014 gtk_widget_show(win->menu.add); | |
5015 gtk_widget_hide(win->menu.remove); | |
5016 } else { | |
5017 gtk_widget_show(win->menu.remove); | |
5018 gtk_widget_hide(win->menu.add); | |
5019 } | |
5020 | |
5021 gtk_widget_show(win->menu.insert_link); | |
5022 gtk_widget_show(win->menu.insert_image); | |
5023 gtk_widget_show(win->menu.show_icon); | |
5024 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
5025 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
5026 | |
5027 /* Deal with menu items */ | |
5028 gtk_widget_show(win->menu.view_log); | |
5029 gtk_widget_hide(win->menu.send_file); | |
5030 gtk_widget_hide(win->menu.add_pounce); | |
5031 gtk_widget_hide(win->menu.get_info); | |
5032 gtk_widget_show(win->menu.invite); | |
5033 gtk_widget_show(win->menu.alias); | |
5034 gtk_widget_hide(win->menu.block); | |
5035 gtk_widget_hide(win->menu.show_icon); | |
5036 | |
5037 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
5038 /* If the chat is NOT in the buddy list */ | |
5039 gtk_widget_show(win->menu.add); | |
5040 gtk_widget_hide(win->menu.remove); | |
5041 } else { | |
5042 /* If the chat IS in the buddy list */ | |
5043 gtk_widget_hide(win->menu.add); | |
5044 gtk_widget_show(win->menu.remove); | |
5045 } | |
5046 | |
5047 gtk_widget_show(win->menu.insert_link); | |
5048 gtk_widget_hide(win->menu.insert_image); | |
5049 } | |
5050 | |
5051 /* | |
5052 * Handle graying stuff out based on whether an account is connected | |
5053 * and what features that account supports. | |
5054 */ | |
5055 if ((gc != NULL) && | |
12012 | 5056 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
5057 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
5058 { | |
11581 | 5059 /* Account is online */ |
5060 /* Deal with the toolbar */ | |
12012 | 5061 if (conv->features & GAIM_CONNECTION_HTML) |
5062 { | |
5063 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
5064 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
5065 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
5066 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
5067 { | |
5068 buttons &= ~GTK_IMHTML_GROW; | |
5069 buttons &= ~GTK_IMHTML_SHRINK; | |
5070 } | |
5071 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
5072 buttons &= ~GTK_IMHTML_LINKDESC; | |
5073 } else { | |
12216 | 5074 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
12012 | 5075 } |
12216 | 5076 |
5077 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
5078 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
5079 buttons &= ~GTK_IMHTML_IMAGE; | |
5080 | |
12012 | 5081 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); |
5082 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 5083 |
5084 /* Deal with menu items */ | |
12012 | 5085 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5086 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5087 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
5088 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
5089 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
5090 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 5091 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 5092 |
5093 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
5094 { | |
5095 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
5096 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
5097 gtk_widget_set_sensitive(win->menu.send_file, | |
5098 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
5099 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
5100 gtk_widget_set_sensitive(win->menu.alias, | |
5101 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
5102 } | |
5103 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5104 { | |
5105 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
5106 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
5107 gtk_widget_set_sensitive(win->menu.alias, | |
5108 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
5109 } | |
11581 | 5110 |
5111 /* Deal with chat userlist buttons */ | |
12012 | 5112 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5113 { | |
5114 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
5115 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
5116 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
5117 } | |
5118 } else { | |
11581 | 5119 /* Account is offline */ |
5120 /* Or it's a chat that we've left. */ | |
5121 | |
5122 /* Then deal with menu items */ | |
12012 | 5123 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5124 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
5125 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5126 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
5127 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
5128 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
5129 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
5130 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
5131 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
5132 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
5133 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 5134 |
5135 /* Deal with chat userlist buttons */ | |
12012 | 5136 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5137 { | |
5138 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5139 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5140 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5141 } | |
5142 } | |
11581 | 5143 |
5144 /* | |
5145 * Update the window's icon | |
5146 */ | |
12171 | 5147 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5148 { |
12171 | 5149 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
5150 (gtkconv->u.im->anim)) | |
5151 { | |
5152 window_icon = | |
5153 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5154 g_object_ref(window_icon); | |
5155 } else { | |
5156 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5157 } | |
5158 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5159 if (window_icon != NULL) | |
5160 g_object_unref(G_OBJECT(window_icon)); | |
5161 } | |
11581 | 5162 } |
5163 | |
10526 | 5164 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5165 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5166 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 5167 { |
11581 | 5168 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5169 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5170 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5171 GaimConvChat *chat; |
4359 | 5172 |
10116 | 5173 g_return_if_fail(conv != NULL); |
5174 | |
4359 | 5175 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5176 win = gtkconv->win; |
10810 | 5177 conv = gtkconv->active_conv; /* Gross hack */ |
11581 | 5178 /* Maybe we should just ignore it if conv != gtkconv->active_conv, |
5179 * instead of the gross hack? | |
5180 */ | |
4359 | 5181 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5182 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5183 { |
4359 | 5184 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5185 |
11338 | 5186 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5187 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5188 |
4359 | 5189 gaim_gtkconv_update_buttons_by_protocol(conv); |
5190 | |
11734 | 5191 update_send_to_selection(win); |
4359 | 5192 |
11525 | 5193 gaim_gtkthemes_smiley_themeize(gtkconv->imhtml); |
6394 | 5194 |
6395 | 5195 update_tab_icon(conv); |
4359 | 5196 } |
5197 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5198 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5199 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5200 { |
9472 | 5201 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5202 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5203 GaimAccount *account = gaim_conversation_get_account(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5204 /* 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
|
5205 char style[51]; |
4736 | 5206 |
11338 | 5207 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5208 im = GAIM_CONV_IM(conv); |
4359 | 5209 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5210 if (!gaim_account_is_connected(account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5211 || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5212 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5213 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5214 else | |
5215 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5216 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5217 *style = '\0'; |
4359 | 5218 |
5219 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5220 gtk_widget_realize(gtkconv->tab_label); | |
5221 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5222 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5223 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5224 { |
11759 | 5225 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5226 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5227 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5228 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5229 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5230 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5231 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5232 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5233 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5234 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5235 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5236 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5237 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5238 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5239 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5240 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5241 { |
11758 | 5242 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5243 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5244 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5245 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5246 { |
8536 | 5247 char *html_title,*label; |
5248 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5249 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5250 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5251 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5252 style, html_title); |
8536 | 5253 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5254 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5255 g_free(label); |
4359 | 5256 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5257 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5258 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5259 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5260 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5261 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5262 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5263 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5264 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5265 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5266 gtk_window_set_title(GTK_WINDOW(win->window), title); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5267 } |
9472 | 5268 |
5269 g_free(title); | |
4359 | 5270 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5271 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5272 { |
7154 | 5273 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5274 chat = GAIM_CONV_CHAT(conv); |
4359 | 5275 gtkchat = gtkconv->u.chat; |
5276 | |
7154 | 5277 topic = gaim_conv_chat_get_topic(chat); |
5278 | |
9554 | 5279 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5280 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5281 topic ? topic : "", NULL); |
4359 | 5282 } |
5283 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5284 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5285 { |
11581 | 5286 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); |
11594 | 5287 generate_send_to_items(win); |
8946 | 5288 update_tab_icon(conv); |
9472 | 5289 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5290 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5291 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5292 { |
8946 | 5293 update_tab_icon(conv); |
4359 | 5294 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5295 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
|
5296 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5297 { |
9472 | 5298 gaim_conversation_autoset_title(conv); |
10810 | 5299 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5300 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5301 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5302 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5303 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5304 } |
10665 | 5305 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5306 { | |
10810 | 5307 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5308 } |
4359 | 5309 } |
5310 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5311 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5312 { |
11581 | 5313 gaim_gtkconv_new, |
4359 | 5314 gaim_gtkconv_destroy, /* destroy_conversation */ |
5315 gaim_gtkconv_write_chat, /* write_chat */ | |
5316 gaim_gtkconv_write_im, /* write_im */ | |
5317 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5318 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5319 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5320 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5321 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5322 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5323 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5324 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5325 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5326 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5327 gaim_gtkconv_updated /* updated */ |
5328 }; | |
5329 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5330 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5331 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5332 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5333 return &conversation_ui_ops; |
4359 | 5334 } |
5335 | |
5336 /************************************************************************** | |
5337 * Public conversation utility functions | |
5338 **************************************************************************/ | |
5339 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5340 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5341 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5342 GaimGtkConversation *gtkconv; |
11581 | 5343 GaimGtkWindow *win; |
4359 | 5344 |
10381 | 5345 GdkPixbufLoader *loader; |
5346 GdkPixbufAnimation *anim; | |
4359 | 5347 GError *err = NULL; |
5348 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5349 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5350 size_t len; |
4359 | 5351 |
5352 GdkPixbuf *buf; | |
5353 | |
5354 GtkWidget *event; | |
5355 GtkWidget *frame; | |
5356 GdkPixbuf *scale; | |
5357 GdkPixmap *pm; | |
5358 GdkBitmap *bm; | |
9318 | 5359 int scale_width, scale_height; |
5360 | |
5361 GaimAccount *account; | |
5362 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5363 |
9324 | 5364 GaimBuddyIcon *icon; |
5365 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5366 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5367 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5368 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5369 |
5370 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5371 win = gtkconv->win; |
10175 | 5372 |
9687 | 5373 if (!gtkconv->u.im->show_icon) |
5374 return; | |
5375 | |
9318 | 5376 account = gaim_conversation_get_account(conv); |
5377 if(account && account->gc) | |
5378 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5379 |
9845 | 5380 /* Remove the current icon stuff */ |
9885 | 5381 if (gtkconv->u.im->icon_container != NULL) |
5382 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5383 gtkconv->u.im->icon_container = NULL; | |
9845 | 5384 |
5385 if (gtkconv->u.im->anim != NULL) | |
5386 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5387 | |
9887 | 5388 gtkconv->u.im->anim = NULL; |
5389 | |
9845 | 5390 if (gtkconv->u.im->icon_timer != 0) |
5391 g_source_remove(gtkconv->u.im->icon_timer); | |
5392 | |
5393 gtkconv->u.im->icon_timer = 0; | |
5394 | |
5395 if (gtkconv->u.im->iter != NULL) | |
5396 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5397 |
10116 | 5398 gtkconv->u.im->iter = NULL; |
5399 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5400 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5401 return; |
5402 | |
5403 if (gaim_conversation_get_gc(conv) == NULL) | |
5404 return; | |
5405 | |
9324 | 5406 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5407 | |
5408 if (icon == NULL) | |
5409 return; | |
5410 | |
5411 data = gaim_buddy_icon_get_data(icon, &len); | |
5412 | |
10381 | 5413 loader = gdk_pixbuf_loader_new(); |
5414 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5415 anim = gdk_pixbuf_loader_get_animation(loader); | |
5416 if (anim) | |
5417 g_object_ref(G_OBJECT(anim)); | |
5418 gdk_pixbuf_loader_close(loader, &err); | |
5419 g_object_unref(loader); | |
5420 | |
5421 if (!anim) | |
9324 | 5422 return; |
10381 | 5423 gtkconv->u.im->anim = anim; |
9324 | 5424 |
4359 | 5425 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5426 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5427 "Buddy icon error: %s\n", err->message); |
4359 | 5428 g_error_free(err); |
5429 } | |
5430 | |
5431 if (!gtkconv->u.im->anim) | |
5432 return; | |
5433 | |
5434 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5435 gtkconv->u.im->iter = NULL; | |
5436 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5437 } else { | |
5438 gtkconv->u.im->iter = | |
8496 | 5439 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5440 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5441 if (gtkconv->u.im->animate) |
10810 | 5442 start_anim(NULL, gtkconv); |
4359 | 5443 } |
5444 | |
10483 | 5445 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5446 NULL, &scale_width, &scale_height); |
4359 | 5447 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5448 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5449 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5450 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5451 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5452 GDK_INTERP_BILINEAR); |
4359 | 5453 |
5454 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5455 g_object_unref(G_OBJECT(scale)); |
4359 | 5456 |
8821 | 5457 |
9885 | 5458 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5459 |
4359 | 5460 frame = gtk_frame_new(NULL); |
5461 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5462 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5463 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5464 FALSE, FALSE, 0); | |
8821 | 5465 |
4359 | 5466 event = gtk_event_box_new(); |
5467 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5468 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5469 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5470 gtk_widget_show(event); |
5471 | |
4635 | 5472 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5473 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5474 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5475 gtk_widget_show(gtkconv->u.im->icon); | |
5476 | |
4793 | 5477 g_object_unref(G_OBJECT(pm)); |
4359 | 5478 |
5479 if (bm) | |
4793 | 5480 g_object_unref(G_OBJECT(bm)); |
7143 | 5481 |
10356 | 5482 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5483 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5484 |
9885 | 5485 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5486 gtk_widget_show(frame); |
5487 | |
7143 | 5488 /* The buddy icon code needs badly to be fixed. */ |
5489 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
|
5490 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5491 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
4359 | 5492 } |
5493 | |
5494 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5495 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5496 { |
11581 | 5497 GaimGtkWindow *win; |
4359 | 5498 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5499 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5500 return; |
5501 | |
11581 | 5502 win = GAIM_GTK_CONVERSATION(conv)->win; |
5503 | |
5504 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5505 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5506 } |
5507 | |
5508 int | |
11614 | 5509 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5510 { |
4359 | 5511 gint nb_x, nb_y, x_rel, y_rel; |
5512 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5513 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5514 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5515 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5516 gboolean horiz; |
4359 | 5517 |
11614 | 5518 if (to_right) |
5519 *to_right = FALSE; | |
5520 | |
11581 | 5521 notebook = GTK_NOTEBOOK(win->notebook); |
5522 | |
5523 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5524 x_rel = x - nb_x; |
5525 y_rel = y - nb_y; | |
5526 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5527 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5528 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5529 |
11780 | 5530 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5531 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5532 #else |
5533 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5534 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5535 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5536 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5537 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5538 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5539 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5540 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5541 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5542 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5543 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5544 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
|
5545 page_num = i; |
11614 | 5546 |
5547 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5548 *to_right = TRUE; | |
5549 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5550 break; |
4359 | 5551 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5552 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5553 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5554 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
|
5555 page_num = i; |
11614 | 5556 |
5557 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5558 *to_right = TRUE; | |
5559 | |
4359 | 5560 break; |
5561 } | |
5562 } | |
5563 } | |
5564 | |
5565 return page_num; | |
5566 } | |
5567 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5568 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5569 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
|
5570 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5571 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5572 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5573 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5574 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5575 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5576 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5577 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5578 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5579 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5580 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5581 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5582 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5583 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5584 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5585 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5586 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5587 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5588 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5589 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5590 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5591 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5592 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5593 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5594 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5595 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5596 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5597 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5598 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5599 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5600 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5601 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5602 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5603 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5604 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5605 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5606 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5607 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5608 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5609 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5610 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5611 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5612 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5613 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5614 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5615 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5616 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5617 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5618 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5619 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5620 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5621 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5622 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5623 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5624 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5625 GtkPositionType pos; |
11581 | 5626 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5627 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5628 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5629 |
11581 | 5630 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5631 win = l->data; | |
5632 | |
11619 | 5633 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
|
5634 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5635 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5636 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5637 static void |
12188 | 5638 show_timestamps_pref_cb(const char *name, GaimPrefType type, |
5639 gpointer value, gpointer data) | |
5640 { | |
5641 GList *l; | |
5642 GaimConversation *conv; | |
5643 GaimGtkConversation *gtkconv; | |
5644 GaimGtkWindow *win; | |
5645 | |
5646 for (l = gaim_get_conversations(); l != NULL; l = l->next) | |
5647 { | |
5648 conv = (GaimConversation *)l->data; | |
5649 | |
5650 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
5651 continue; | |
5652 | |
5653 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5654 win = gtkconv->win; | |
5655 | |
5656 gtk_check_menu_item_set_active( | |
5657 GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
5658 (gboolean)GPOINTER_TO_INT(value)); | |
5659 | |
5660 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
5661 (gboolean)GPOINTER_TO_INT(value)); | |
5662 } | |
5663 } | |
5664 | |
5665 static void | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5666 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5667 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5668 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5669 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5670 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5671 GaimGtkConversation *gtkconv; |
11581 | 5672 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5673 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5674 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5675 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5676 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5677 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5678 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5679 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5680 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5681 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5682 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5683 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5684 gtk_check_menu_item_set_active( |
11581 | 5685 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5686 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5687 |
5688 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5689 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5690 else |
8317 | 5691 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5692 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5693 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5694 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5695 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5696 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5697 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5698 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5699 GList *l; |
8189 | 5700 GaimConversation *conv; |
5701 GaimGtkConversation *gtkconv; | |
11581 | 5702 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5703 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5704 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
|
5705 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5706 |
8189 | 5707 /* Set the "animate" flag for each icon based on the new preference */ |
5708 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5709 conv = (GaimConversation *)l->data; | |
5710 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5711 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5712 } |
8189 | 5713 |
5714 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5715 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5716 win = l->data; | |
5717 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5718 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5719 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5720 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5721 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5722 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5723 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
|
5724 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5725 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5726 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5727 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5728 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5729 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5730 |
11338 | 5731 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 5732 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5733 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5734 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5735 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
5736 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5737 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5738 gpointer value, gpointer data) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5739 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5740 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5741 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5742 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5743 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5744 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5745 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5746 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5747 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5748 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5749 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5750 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5751 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
|
5752 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5753 |
12310 | 5754 if(gaim_status_is_available(oldstatus) || !gaim_status_is_available(newstatus)) |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5755 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5756 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5757 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5758 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5759 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5760 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5761 |
12310 | 5762 if(!gaim_status_is_available( |
5763 gaim_account_get_active_status( | |
5764 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5765 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5766 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5767 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5768 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5769 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5770 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5771 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5772 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5773 hide_new_pref_cb(const char *name, GaimPrefType type, gpointer value, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5774 gpointer data) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5775 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5776 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5777 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5778 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5779 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5780 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5781 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5782 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5783 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5784 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
|
5785 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5786 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5787 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
|
5788 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5789 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5790 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5791 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5792 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5793 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5794 |
12310 | 5795 if(when_away && !gaim_status_is_available( |
5796 gaim_account_get_active_status( | |
5797 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5798 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5799 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5800 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5801 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5802 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5803 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5804 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5805 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5806 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5807 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5808 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5809 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5810 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5811 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5812 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5813 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5814 |
11581 | 5815 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5816 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5817 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5818 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5819 |
11581 | 5820 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5821 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5822 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5823 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5824 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5825 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5826 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5827 GaimAccount *account; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5828 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5829 account = gaim_connection_get_account(gc); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5830 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5831 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5832 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5833 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5834 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5835 if (gaim_conversation_get_account(conv) == account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5836 gaim_conversation_update(conv, GPOINTER_TO_INT(event)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5837 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5838 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5839 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5840 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5841 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5842 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5843 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5844 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5845 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5846 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5847 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5848 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5849 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5850 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5851 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5852 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5853 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5854 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5855 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5856 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5857 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5858 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5859 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5860 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5861 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5862 |
12264 | 5863 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5864 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 5865 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 5866 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5867 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 5868 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 5869 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5870 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5871 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5872 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5873 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5874 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
|
5875 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5876 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5877 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5878 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5879 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5880 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5881 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5882 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5883 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5884 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 5885 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5886 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 5887 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5888 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5889 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5890 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 5891 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
|
5892 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5893 /* convert old queuing prefs to hide_new 3-way pref */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5894 if(gaim_prefs_exists("/plugins/gtk/docklet/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5895 gaim_prefs_get_bool("/plugins/gtk/docklet/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5896 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "always"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5897 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5898 else if(gaim_prefs_exists("/gaim/gtk/away/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5899 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5900 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "away"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5901 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5902 else { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5903 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "never"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5904 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5905 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5906 /* Connect callbacks. */ |
10087 | 5907 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
|
5908 close_on_tabs_pref_cb, NULL); |
12188 | 5909 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
5910 show_timestamps_pref_cb, NULL); | |
10087 | 5911 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
|
5912 show_formatting_toolbar_pref_cb, NULL); |
10087 | 5913 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5914 spellcheck_pref_cb, NULL); |
10087 | 5915 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5916 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5917 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5918 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5919 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5920 |
10087 | 5921 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5922 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5923 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5924 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5925 /* IM callbacks */ |
10087 | 5926 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
|
5927 animate_buddy_icons_pref_cb, NULL); |
10087 | 5928 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
|
5929 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5930 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5931 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5932 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5933 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5934 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5935 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5936 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5937 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
5938 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5939 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5940 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5941 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5942 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5943 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 5944 |
5945 /********************************************************************** | |
5946 * Register commands | |
5947 **********************************************************************/ | |
9829 | 5948 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
5949 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
5950 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 5951 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
5952 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5953 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 5954 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
5955 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5956 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
|
5957 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5958 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5959 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 5960 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 5961 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
5962 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 5963 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5964 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5965 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5966 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5967 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5968 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5969 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5970 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5971 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5972 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5973 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5974 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5975 gaim_signal_connect(blist_handle, "buddy-added", handle, |
11855 | 5976 G_CALLBACK(buddy_update_cb), NULL); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5977 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
11855 | 5978 G_CALLBACK(buddy_update_cb), NULL); |
5979 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5980 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5981 handle, G_CALLBACK(received_im_msg_cb), NULL); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5982 |
11581 | 5983 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5984 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5985 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5986 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5987 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5988 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5989 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5990 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5991 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5992 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5993 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5994 { |
10443 | 5995 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 5996 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5997 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5998 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5999 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6000 } |
11581 | 6001 |
6002 | |
6003 | |
6004 | |
6005 | |
6006 | |
6007 | |
6008 | |
6009 | |
6010 | |
6011 | |
6012 | |
6013 | |
6014 | |
6015 | |
6016 | |
6017 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
6018 * and touch each others' private members all day long */ | |
6019 | |
6020 /** | |
6021 * @file gtkconvwin.c GTK+ Conversation Window API | |
6022 * @ingroup gtkui | |
6023 * | |
6024 * gaim | |
6025 * | |
6026 * Gaim is the legal property of its developers, whose names are too numerous | |
6027 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6028 * source distribution. | |
6029 * | |
6030 * This program is free software; you can redistribute it and/or modify | |
6031 * it under the terms of the GNU General Public License as published by | |
6032 * the Free Software Foundation; either version 2 of the License, or | |
6033 * (at your option) any later version. | |
6034 * | |
6035 * This program is distributed in the hope that it will be useful, | |
6036 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
6037 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
6038 * GNU General Public License for more details. | |
6039 * | |
6040 * You should have received a copy of the GNU General Public License | |
6041 * along with this program; if not, write to the Free Software | |
6042 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
6043 * | |
6044 */ | |
6045 #include "internal.h" | |
6046 #include "gtkgaim.h" | |
6047 | |
6048 | |
6049 #include <gdk/gdkkeysyms.h> | |
6050 | |
6051 #include "account.h" | |
6052 #include "cmds.h" | |
6053 #include "debug.h" | |
6054 #include "imgstore.h" | |
6055 #include "log.h" | |
6056 #include "notify.h" | |
6057 #include "prpl.h" | |
6058 #include "request.h" | |
6059 #include "util.h" | |
6060 | |
6061 #include "gtkdnd-hints.h" | |
6062 #include "gtkblist.h" | |
6063 #include "gtkconv.h" | |
6064 #include "gtkdialogs.h" | |
6065 #include "gtkmenutray.h" | |
6066 #include "gtkpounce.h" | |
6067 #include "gtkprefs.h" | |
6068 #include "gtkprivacy.h" | |
6069 #include "gtkutils.h" | |
6070 #include "gtkstock.h" | |
6071 #include "gtkimhtml.h" | |
6072 #include "gtkimhtmltoolbar.h" | |
6073 | |
6074 static void | |
6075 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
6076 { | |
6077 gtk_widget_destroy(warn_close_dialog); | |
6078 warn_close_dialog = NULL; | |
6079 | |
6080 if (resp == GTK_RESPONSE_OK) | |
6081 gaim_gtk_conv_window_destroy(win); | |
6082 } | |
6083 | |
6084 static void | |
6085 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
6086 { | |
6087 GtkWidget *label; | |
6088 GtkWidget *vbox, *hbox; | |
6089 GtkWidget *img; | |
6090 | |
6091 g_return_if_fail(warn_close_dialog == NULL); | |
6092 | |
6093 | |
6094 warn_close_dialog = gtk_dialog_new_with_buttons( | |
6095 _("Confirm close"), | |
6096 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
6097 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
6098 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
6099 | |
6100 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
6101 GTK_RESPONSE_OK); | |
6102 | |
6103 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
6104 6); | |
6105 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
6106 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
6107 FALSE); | |
6108 | |
6109 /* Setup the outside spacing. */ | |
6110 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
6111 | |
6112 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
6113 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
6114 | |
6115 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
6116 GTK_ICON_SIZE_DIALOG); | |
6117 /* Setup the inner hbox and put the dialog's icon in it. */ | |
6118 hbox = gtk_hbox_new(FALSE, 12); | |
6119 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
6120 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
6121 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
6122 | |
6123 /* Setup the right vbox. */ | |
6124 vbox = gtk_vbox_new(FALSE, 12); | |
6125 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
6126 | |
6127 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
6128 gtk_widget_set_size_request(label, 350, -1); | |
6129 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
6130 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
6131 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
6132 | |
6133 /* Connect the signals. */ | |
6134 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
6135 G_CALLBACK(do_close), gtkwin); | |
6136 | |
6137 } | |
6138 | |
6139 /************************************************************************** | |
6140 * Callbacks | |
6141 **************************************************************************/ | |
6142 | |
6143 static gboolean | |
6144 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
6145 { | |
6146 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6147 GList *l; |
11581 | 6148 |
6149 /* If there are unread messages then show a warning dialog */ | |
6150 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
6151 l != NULL; l = l->next) | |
6152 { | |
6153 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6154 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
|
6155 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6156 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6157 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6158 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6159 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6160 return TRUE; |
11581 | 6161 } |
6162 } | |
6163 | |
6164 gaim_gtk_conv_window_destroy(win); | |
6165 | |
6166 return TRUE; | |
6167 } | |
6168 | |
11604 | 6169 static void |
6170 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
6171 { | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6172 if (state == GAIM_UNSEEN_NONE) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6173 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6174 gtkconv->unseen_count = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6175 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6176 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6177 else |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6178 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6179 gtkconv->unseen_count++; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6180 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6181 if (state > gtkconv->unseen_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6182 gtkconv->unseen_state = state; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6183 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6184 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6185 /* 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
|
6186 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
|
6187 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6188 |
11581 | 6189 /* |
6190 * When a conversation window is focused, we know the user | |
6191 * has looked at it so we know there are no longer unseen | |
6192 * messages. | |
6193 */ | |
6194 static gint | |
6195 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6196 { | |
6197 GaimGtkWindow *win = d; | |
11604 | 6198 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6199 | |
6200 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6201 |
6202 return FALSE; | |
6203 } | |
6204 | |
11851 | 6205 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6206 /* Courtesy of Galeon! */ |
6207 static void | |
6208 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6209 { | |
6210 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6211 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6212 } | |
11851 | 6213 #endif |
11581 | 6214 |
6215 static void | |
6216 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6217 { | |
6218 static GdkCursor *cursor = NULL; | |
6219 | |
6220 gtkwin->in_drag = TRUE; | |
6221 | |
6222 if (gtkwin->drag_leave_signal) { | |
6223 g_signal_handler_disconnect(G_OBJECT(widget), | |
6224 gtkwin->drag_leave_signal); | |
6225 gtkwin->drag_leave_signal = 0; | |
6226 } | |
6227 | |
6228 if (cursor == NULL) | |
6229 cursor = gdk_cursor_new(GDK_FLEUR); | |
6230 | |
6231 /* Grab the pointer */ | |
6232 gtk_grab_add(gtkwin->notebook); | |
6233 #ifndef _WIN32 | |
6234 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6235 always be true after a button press. */ | |
6236 if (!gdk_pointer_is_grabbed()) | |
6237 #endif | |
6238 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6239 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6240 NULL, cursor, GDK_CURRENT_TIME); | |
6241 } | |
6242 | |
6243 static gboolean | |
6244 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6245 { | |
6246 | |
6247 /* | |
6248 * Make sure the user moved the mouse far enough for the | |
6249 * drag to be initiated. | |
6250 */ | |
6251 if (win->in_predrag) { | |
6252 if (e->x_root < win->drag_min_x || | |
6253 e->x_root >= win->drag_max_x || | |
6254 e->y_root < win->drag_min_y || | |
6255 e->y_root >= win->drag_max_y) { | |
6256 | |
6257 win->in_predrag = FALSE; | |
6258 notebook_init_grab(win, widget); | |
6259 } | |
6260 } | |
6261 else { /* Otherwise, draw the arrows. */ | |
6262 GaimGtkWindow *dest_win; | |
6263 GtkNotebook *dest_notebook; | |
6264 GtkWidget *tab; | |
6265 gint nb_x, nb_y, page_num; | |
6266 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6267 gboolean horiz_tabs = FALSE; | |
11614 | 6268 GaimGtkConversation *gtkconv; |
6269 gboolean to_right = FALSE; | |
11581 | 6270 |
6271 /* Get the window that the cursor is over. */ | |
6272 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6273 | |
6274 if (dest_win == NULL) { | |
6275 dnd_hints_hide_all(); | |
6276 | |
6277 return TRUE; | |
6278 } | |
6279 | |
6280 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6281 | |
6282 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6283 | |
6284 arrow1_x = arrow2_x = nb_x; | |
6285 arrow1_y = arrow2_y = nb_y; | |
6286 | |
6287 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6288 e->x_root, e->y_root, &to_right); |
6289 to_right = to_right && (win != dest_win); | |
11581 | 6290 |
6291 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6292 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6293 | |
6294 horiz_tabs = TRUE; | |
6295 } | |
6296 | |
11614 | 6297 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6298 tab = gtkconv->tabby; | |
11581 | 6299 |
6300 if (horiz_tabs) { | |
6301 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6302 | |
11614 | 6303 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6304 arrow1_x += tab->allocation.width; |
6305 arrow2_x += tab->allocation.width; | |
6306 } | |
6307 | |
6308 arrow1_y = nb_y + tab->allocation.y; | |
6309 arrow2_y = nb_y + tab->allocation.y + | |
6310 tab->allocation.height; | |
6311 } else { | |
6312 arrow1_x = nb_x + tab->allocation.x; | |
6313 arrow2_x = nb_x + tab->allocation.x + | |
6314 tab->allocation.width; | |
6315 arrow1_y = arrow2_y = nb_y + tab->allocation.y + tab->allocation.height/2; | |
6316 | |
6317 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
6318 arrow1_y += tab->allocation.height; | |
6319 arrow2_y += tab->allocation.height; | |
6320 } | |
6321 } | |
6322 | |
6323 if (horiz_tabs) { | |
6324 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6325 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6326 } else { | |
6327 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6328 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6329 } | |
6330 } | |
6331 | |
6332 return TRUE; | |
6333 } | |
6334 | |
6335 static gboolean | |
6336 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6337 { | |
6338 if (win->in_drag) | |
6339 return FALSE; | |
6340 | |
6341 if (e->x_root < win->drag_min_x || | |
6342 e->x_root >= win->drag_max_x || | |
6343 e->y_root < win->drag_min_y || | |
6344 e->y_root >= win->drag_max_y) { | |
6345 | |
6346 win->in_predrag = FALSE; | |
6347 notebook_init_grab(win, widget); | |
6348 } | |
6349 | |
6350 return TRUE; | |
6351 } | |
6352 | |
6353 /* | |
6354 * THANK YOU GALEON! | |
6355 */ | |
6356 static gboolean | |
6357 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6358 { | |
6359 gint nb_x, nb_y, x_rel, y_rel; | |
6360 int tab_clicked; | |
6361 GtkWidget *page; | |
6362 GtkWidget *tab; | |
6363 | |
6364 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6365 return FALSE; | |
6366 | |
6367 | |
6368 if (win->in_drag) { | |
6369 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6370 "Already in the middle of a window drag at tab_press_cb\n"); | |
6371 return TRUE; | |
6372 } | |
6373 | |
6374 /* | |
6375 * Make sure a tab was actually clicked. The arrow buttons | |
6376 * mess things up. | |
6377 */ | |
11614 | 6378 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6379 |
6380 if (tab_clicked == -1) | |
6381 return FALSE; | |
6382 | |
6383 /* | |
6384 * Get the relative position of the press event, with regards to | |
6385 * the position of the notebook. | |
6386 */ | |
6387 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6388 | |
6389 x_rel = e->x_root - nb_x; | |
6390 y_rel = e->y_root - nb_y; | |
6391 | |
6392 /* Reset the min/max x/y */ | |
6393 win->drag_min_x = 0; | |
6394 win->drag_min_y = 0; | |
6395 win->drag_max_x = 0; | |
6396 win->drag_max_y = 0; | |
6397 | |
6398 /* Find out which tab was dragged. */ | |
6399 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6400 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6401 | |
6402 win->drag_min_x = tab->allocation.x + nb_x; | |
6403 win->drag_min_y = tab->allocation.y + nb_y; | |
6404 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6405 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6406 | |
6407 /* Make sure the click occurred in the tab. */ | |
6408 if (e->x_root < win->drag_min_x || | |
6409 e->x_root >= win->drag_max_x || | |
6410 e->y_root < win->drag_min_y || | |
6411 e->y_root >= win->drag_max_y) { | |
6412 | |
6413 return FALSE; | |
6414 } | |
6415 | |
6416 win->in_predrag = TRUE; | |
6417 win->drag_tab = tab_clicked; | |
6418 | |
6419 /* Connect the new motion signals. */ | |
6420 win->drag_motion_signal = | |
6421 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6422 G_CALLBACK(notebook_motion_cb), win); | |
6423 | |
6424 win->drag_leave_signal = | |
6425 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6426 G_CALLBACK(notebook_leave_cb), win); | |
6427 | |
6428 return FALSE; | |
6429 } | |
6430 | |
6431 static gboolean | |
6432 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6433 { | |
6434 GaimGtkWindow *dest_win; | |
6435 GaimConversation *conv; | |
6436 GaimGtkConversation *gtkconv; | |
6437 gint dest_page_num = 0; | |
6438 gboolean new_window = FALSE; | |
11614 | 6439 gboolean to_right = FALSE; |
11581 | 6440 |
6441 /* | |
6442 * Don't check to make sure that the event's window matches the | |
6443 * widget's, because we may be getting an event passed on from the | |
6444 * close button. | |
6445 */ | |
6446 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6447 return FALSE; | |
6448 | |
6449 if (gdk_pointer_is_grabbed()) { | |
6450 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6451 gtk_grab_remove(widget); | |
6452 } | |
6453 | |
6454 if (!win->in_predrag && !win->in_drag) | |
6455 return FALSE; | |
6456 | |
6457 /* Disconnect the motion signal. */ | |
6458 if (win->drag_motion_signal) { | |
6459 g_signal_handler_disconnect(G_OBJECT(widget), | |
6460 win->drag_motion_signal); | |
6461 | |
6462 win->drag_motion_signal = 0; | |
6463 } | |
6464 | |
6465 /* | |
6466 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6467 * signal. | |
6468 */ | |
6469 if (win->in_predrag) { | |
6470 win->in_predrag = FALSE; | |
6471 | |
6472 if (win->drag_leave_signal) { | |
6473 g_signal_handler_disconnect(G_OBJECT(widget), | |
6474 win->drag_leave_signal); | |
6475 | |
6476 win->drag_leave_signal = 0; | |
6477 } | |
6478 } | |
6479 | |
6480 /* If we're not in drag... */ | |
6481 /* We're perfectly normal people! */ | |
6482 if (!win->in_drag) | |
6483 return FALSE; | |
6484 | |
6485 win->in_drag = FALSE; | |
6486 | |
6487 dnd_hints_hide_all(); | |
6488 | |
6489 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6490 | |
6491 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6492 | |
6493 if (dest_win == NULL) { | |
6494 /* If the current window doesn't have any other conversations, | |
6495 * there isn't much point transferring the conv to a new window. */ | |
6496 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6497 /* Make a new window to stick this to. */ | |
6498 dest_win = gaim_gtk_conv_window_new(); | |
6499 new_window = TRUE; | |
6500 } | |
6501 } | |
6502 | |
6503 if (dest_win == NULL) | |
6504 return FALSE; | |
6505 | |
6506 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6507 "conversation-dragging", win, dest_win); | |
6508 | |
6509 /* Get the destination page number. */ | |
6510 if (!new_window) | |
6511 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6512 e->x_root, e->y_root, &to_right); |
11581 | 6513 |
6514 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6515 | |
6516 if (win == dest_win) { | |
6517 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6518 } else { | |
6519 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6520 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 6521 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 6522 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
6523 if (new_window) { | |
6524 gint win_width, win_height; | |
6525 | |
6526 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6527 &win_width, &win_height); | |
6528 | |
6529 gtk_window_move(GTK_WINDOW(dest_win->window), | |
6530 e->x_root - (win_width / 2), | |
6531 e->y_root - (win_height / 2)); | |
6532 | |
6533 gaim_gtk_conv_window_show(dest_win); | |
6534 } | |
6535 } | |
6536 | |
6537 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
6538 | |
6539 return TRUE; | |
6540 } | |
6541 | |
6542 | |
6543 static void | |
6544 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6545 gpointer user_data) | |
6546 { | |
6547 GaimGtkWindow *win; | |
6548 GaimConversation *conv; | |
6549 GaimGtkConversation *gtkconv; | |
6550 | |
6551 win = user_data; | |
6552 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6553 | |
6554 g_return_if_fail(conv != NULL); | |
6555 | |
6556 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
6557 return; | |
6558 | |
6559 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6560 | |
6561 stop_anim(NULL, gtkconv); | |
6562 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6563 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6564 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6565 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6566 close_win_cb(w, NULL, 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 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6569 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6570 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6571 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6572 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6573 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6574 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6575 gtkconv = g_object_get_data(menu, "clicked_tab"); |
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 (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6578 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6579 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6580 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6581 /* 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
|
6582 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6583 return; |
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 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6586 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6587 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6588 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6589 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6590 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6591 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6592 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6593 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6594 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6595 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6596 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6597 GaimGtkWindow *win; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6598 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6599 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6600 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6601 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6602 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6603 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6604 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6605 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6606 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
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 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6609 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6610 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6611 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6612 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6613 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6614 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6615 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6616 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6617 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6618 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6619 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6620 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6621 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6622 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6623 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6624 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6625 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6626 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6627 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6628 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6629 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6630 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6631 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6632 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6633 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6634 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6635 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6636 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6637 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
6638 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
|
6639 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6640 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6641 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6642 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6643 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6644 } |
12188 | 6645 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6646 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6647 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6648 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6649 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6650 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6651 item = gtk_menu_item_new_with_label("Detach this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6652 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6653 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6654 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6655 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6656 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6657 item = gtk_menu_item_new_with_label("Close this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6658 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6659 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6660 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6661 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6662 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6663 gaim_separator(menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6664 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6665 item = gtk_menu_item_new_with_label("Close other tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6666 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6667 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6668 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6669 G_CALLBACK(close_others_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6670 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6671 item = gtk_menu_item_new_with_label("Close all tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6672 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6673 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6674 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6675 G_CALLBACK(close_window), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6676 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6677 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6678 } |
11581 | 6679 |
6680 static void | |
6681 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6682 gpointer user_data) | |
6683 { | |
6684 GaimGtkWindow *win; | |
6685 GaimConversation *conv; | |
6686 GaimGtkConversation *gtkconv; | |
6687 | |
6688 win = user_data; | |
6689 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
6690 conv = gtkconv->active_conv; | |
6691 | |
6692 g_return_if_fail(conv != NULL); | |
6693 | |
6694 /* | |
6695 * Only set "unseen" to "none" if the window has focus | |
6696 */ | |
6697 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 6698 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 6699 |
6700 /* Update the menubar */ | |
6701 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6702 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
|
6703 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6704 |
11594 | 6705 generate_send_to_items(win); |
6706 | |
11604 | 6707 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 6708 |
6709 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), | |
6710 gtkconv->make_sound); | |
6711 | |
6712 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
6713 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
6714 | |
6715 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
12188 | 6716 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
11581 | 6717 |
6718 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6719 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), | |
6720 gtkconv->u.im->show_icon); | |
11604 | 6721 |
11581 | 6722 /* |
6723 * We pause icons when they are not visible. If this icon should | |
6724 * be animated then start it back up again. | |
6725 */ | |
6726 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
6727 (gtkconv->u.im->animate)) | |
6728 start_anim(NULL, gtkconv); | |
6729 } | |
6730 | |
6731 /************************************************************************** | |
6732 * GTK+ window ops | |
6733 **************************************************************************/ | |
6734 | |
6735 GList * | |
6736 gaim_gtk_conv_windows_get_list() | |
6737 { | |
6738 return window_list; | |
6739 } | |
6740 | |
6741 GaimGtkWindow * | |
6742 gaim_gtk_conv_window_new() | |
6743 { | |
6744 GaimGtkWindow *win; | |
6745 GtkPositionType pos; | |
6746 GtkWidget *testidea; | |
6747 GtkWidget *menubar; | |
6748 | |
6749 win = g_malloc0(sizeof(GaimGtkWindow)); | |
6750 | |
6751 window_list = g_list_append(window_list, win); | |
6752 | |
6753 /* Create the window. */ | |
6754 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
6755 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
6756 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
6757 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
6758 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
6759 | |
6760 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
6761 G_CALLBACK(close_win_cb), win); | |
6762 | |
6763 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
6764 G_CALLBACK(focus_win_cb), win); | |
6765 | |
6766 /* Create the notebook. */ | |
6767 win->notebook = gtk_notebook_new(); | |
6768 | |
6769 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
6770 | |
6771 #if 0 | |
6772 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
6773 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
6774 #endif | |
6775 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
6776 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
6777 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
6778 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
6779 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
6780 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6781 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6782 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6783 |
11581 | 6784 gtk_widget_show(win->notebook); |
6785 | |
6786 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
6787 G_CALLBACK(before_switch_conv_cb), win); | |
6788 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
6789 G_CALLBACK(switch_conv_cb), win); | |
6790 | |
6791 /* Setup the tab drag and drop signals. */ | |
6792 gtk_widget_add_events(win->notebook, | |
6793 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
6794 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
6795 G_CALLBACK(notebook_press_cb), win); | |
6796 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
6797 G_CALLBACK(notebook_release_cb), win); | |
6798 | |
6799 testidea = gtk_vbox_new(FALSE, 0); | |
6800 | |
6801 /* Setup the menubar. */ | |
6802 menubar = setup_menubar(win); | |
6803 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
6804 | |
6805 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
6806 | |
6807 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
6808 | |
6809 gtk_widget_show(testidea); | |
6810 | |
6811 return win; | |
6812 } | |
6813 | |
6814 void | |
6815 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
6816 { | |
6817 window_list = g_list_remove(window_list, win); | |
6818 | |
11611 | 6819 if (win->gtkconvs) { |
6820 while (win->gtkconvs) { | |
6821 GList *nextgtk = win->gtkconvs->next; | |
6822 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
6823 GList *nextcore = gtkconv->convs->next; | |
6824 GaimConversation *conv = gtkconv->convs->data; | |
6825 gaim_conversation_destroy(conv); | |
6826 if (!nextgtk && !nextcore) | |
6827 /* we'll end up invoking ourselves when we destroy our last child */ | |
6828 /* so don't destroy ourselves right now */ | |
6829 return; | |
6830 } | |
6831 return; | |
6832 } | |
11581 | 6833 gtk_widget_destroy(win->window); |
6834 | |
6835 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
6836 | |
6837 g_free(win); | |
6838 } | |
6839 | |
6840 void | |
6841 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
6842 { | |
6843 gtk_widget_show(win->window); | |
6844 } | |
6845 | |
6846 void | |
6847 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
6848 { | |
6849 gtk_widget_hide(win->window); | |
6850 } | |
6851 | |
6852 void | |
6853 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
6854 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
6855 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 6856 } |
6857 | |
6858 void | |
6859 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6860 { | |
6861 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
6862 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
6863 gtkconv->tab_cont)); | |
6864 } | |
6865 | |
6866 void | |
6867 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6868 { | |
6869 GaimConversation *conv = gtkconv->active_conv; | |
6870 GaimGtkConversation *focus_gtkconv; | |
6871 GtkWidget *tabby, *menu_tabby; | |
6872 GtkWidget *tab_cont = gtkconv->tab_cont; | |
6873 GtkWidget *close_image; | |
6874 GaimConversationType conv_type; | |
6875 const char *name; | |
6876 const gchar *tmp_lab; | |
6877 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 6878 gboolean tabs_side = FALSE; |
6879 gint angle = 0; | |
11581 | 6880 |
6881 name = gaim_conversation_get_name(conv); | |
6882 conv_type = gaim_conversation_get_type(conv); | |
6883 | |
6884 | |
6885 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
6886 gtkconv->win = win; | |
6887 | |
11619 | 6888 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
6889 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
6890 tabs_side = TRUE; | |
6891 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
6892 angle = 90; | |
6893 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6894 angle = 270; | |
6895 | |
6896 if (angle) | |
6897 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
6898 else | |
6899 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 6900 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
6901 | |
6902 /* Close button. */ | |
6903 gtkconv->close = gtk_button_new(); | |
6904 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
6905 if (gtk_check_version(2, 4, 2) == NULL) { | |
6906 /* Need to account for extra padding around the gtkbutton */ | |
6907 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
6908 "focus-line-width", &focus_width, | |
6909 "focus-padding", &focus_pad, | |
6910 NULL); | |
6911 close_button_width += (focus_width + focus_pad) * 2; | |
6912 close_button_height += (focus_width + focus_pad) * 2; | |
6913 } | |
6914 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
6915 close_button_width, close_button_height); | |
6916 | |
6917 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
6918 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
6919 gtk_widget_show(close_image); | |
6920 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
6921 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
6922 _("Close conversation"), NULL); | |
6923 | |
6924 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
6925 G_CALLBACK(close_conv_cb), gtkconv); | |
6926 | |
11851 | 6927 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6928 /* |
6929 * I love Galeon. They have a fix for that stupid annoying visible | |
6930 * border bug. I love you guys! -- ChipX86 | |
6931 */ | |
11851 | 6932 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 6933 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
6934 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 6935 #endif |
11581 | 6936 |
6937 /* Status icon. */ | |
6938 gtkconv->icon = gtk_image_new(); | |
6939 gtkconv->menu_icon = gtk_image_new(); | |
6940 update_tab_icon(conv); | |
6941 | |
6942 /* Tab label. */ | |
6943 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 6944 |
11581 | 6945 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 6946 if (!angle) |
6947 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 6948 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 6949 if (tabs_side) { |
6950 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
6951 } | |
6952 if (angle) | |
6953 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 6954 #endif |
6955 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6956 #if 0 | |
6957 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
6958 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
6959 #endif | |
6960 | |
6961 /* Pack it all together. */ | |
11619 | 6962 if (angle == 90) |
6963 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
6964 else | |
6965 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 6966 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
6967 FALSE, FALSE, 0); | |
6968 | |
6969 gtk_widget_show_all(gtkconv->icon); | |
6970 gtk_widget_show_all(gtkconv->menu_icon); | |
6971 | |
6972 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
6973 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
6974 gtk_widget_show(gtkconv->tab_label); | |
6975 gtk_widget_show(gtkconv->menu_label); | |
6976 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
6977 | |
11619 | 6978 if (angle == 90) |
6979 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
6980 else | |
6981 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 6982 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
6983 gtk_widget_show(gtkconv->close); | |
6984 | |
6985 gtk_widget_show(tabby); | |
6986 gtk_widget_show(menu_tabby); | |
6987 | |
6988 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6989 gaim_gtkconv_update_buddy_icon(conv); | |
6990 | |
6991 /* Add this pane to the conversation's notebook. */ | |
6992 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 6993 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 6994 |
6995 | |
6996 gtk_widget_show(tab_cont); | |
6997 | |
6998 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
6999 /* Er, bug in notebooks? Switch to the page manually. */ | |
7000 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
7001 | |
7002 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7003 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7004 } else | |
7005 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
7006 | |
7007 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
7008 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
7009 gtk_widget_grab_focus(focus_gtkconv->entry); | |
7010 | |
7011 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 7012 update_send_to_selection(win); |
11581 | 7013 } |
7014 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7015 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7016 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
11581 | 7017 { |
7018 unsigned int index; | |
7019 GaimConversationType conv_type; | |
7020 | |
7021 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
7022 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
7023 | |
7024 g_object_ref(gtkconv->tab_cont); | |
7025 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
7026 | |
7027 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
7028 | |
7029 /* go back to tabless if need be */ | |
7030 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
7031 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7032 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7033 } | |
7034 | |
7035 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 7036 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7037 if (!win->gtkconvs && win != hidden_convwin) |
11582 | 7038 gaim_gtk_conv_window_destroy(win); |
11581 | 7039 } |
7040 | |
7041 GaimGtkConversation * | |
7042 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
7043 { | |
7044 GtkWidget *tab_cont; | |
7045 | |
7046 if (index == -1) | |
7047 index = 0; | |
7048 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 7049 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 7050 } |
7051 | |
7052 GaimGtkConversation * | |
7053 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
7054 { | |
7055 int index; | |
7056 GtkWidget *tab_cont; | |
7057 | |
7058 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
7059 if (index == -1) | |
7060 index = 0; | |
7061 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
7062 if (!tab_cont) | |
7063 return NULL; | |
7064 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
7065 } | |
7066 | |
7067 | |
7068 GaimConversation * | |
7069 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
7070 { | |
7071 GaimGtkConversation *gtkconv; | |
7072 | |
7073 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
7074 return gtkconv ? gtkconv->active_conv : NULL; | |
7075 } | |
7076 | |
7077 gboolean | |
7078 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
7079 { | |
7080 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
7081 } | |
7082 | |
7083 gboolean | |
7084 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
7085 { | |
7086 gboolean has_focus = FALSE; | |
7087 | |
7088 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
7089 | |
7090 return has_focus; | |
7091 } | |
7092 | |
7093 GaimGtkWindow * | |
7094 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
7095 { | |
7096 GaimGtkWindow *win; | |
7097 GdkWindow *gdkwin; | |
7098 GList *l; | |
7099 | |
7100 gdkwin = gdk_window_at_pointer(&x, &y); | |
7101 | |
7102 if (gdkwin) | |
7103 gdkwin = gdk_window_get_toplevel(gdkwin); | |
7104 | |
7105 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
7106 win = l->data; | |
7107 | |
7108 if (gdkwin == win->window->window) | |
7109 return win; | |
7110 } | |
7111 | |
7112 return NULL; | |
7113 } | |
7114 | |
7115 GList * | |
7116 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
7117 { | |
7118 return win->gtkconvs; | |
7119 } | |
7120 | |
7121 guint | |
7122 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
7123 { | |
7124 return g_list_length(win->gtkconvs); | |
7125 } | |
7126 | |
7127 GaimGtkWindow * | |
7128 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
7129 { | |
7130 GList *wins, *convs; | |
7131 GaimGtkWindow *win; | |
7132 GaimGtkConversation *conv; | |
7133 | |
7134 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7135 return NULL; | |
7136 | |
7137 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7138 win = wins->data; | |
7139 | |
7140 for (convs = win->gtkconvs; | |
7141 convs != NULL; | |
7142 convs = convs->next) { | |
7143 | |
7144 conv = convs->data; | |
7145 | |
7146 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7147 return win; | |
7148 } | |
7149 } | |
7150 | |
7151 return NULL; | |
7152 } | |
7153 | |
7154 GaimGtkWindow * | |
7155 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
7156 { | |
7157 GList *wins, *convs; | |
7158 GaimGtkWindow *win; | |
7159 GaimGtkConversation *conv; | |
7160 | |
7161 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7162 return NULL; | |
7163 | |
7164 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7165 wins != NULL; | |
7166 wins = wins->prev) { | |
7167 | |
7168 win = wins->data; | |
7169 | |
7170 for (convs = win->gtkconvs; | |
7171 convs != NULL; | |
7172 convs = convs->next) { | |
7173 | |
7174 conv = convs->data; | |
7175 | |
7176 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7177 return win; | |
7178 } | |
7179 } | |
7180 | |
7181 return NULL; | |
7182 } | |
7183 | |
7184 | |
7185 /************************************************************************** | |
7186 * Conversation placement functions | |
7187 **************************************************************************/ | |
7188 typedef struct | |
7189 { | |
7190 char *id; | |
7191 char *name; | |
7192 GaimConvPlacementFunc fnc; | |
7193 | |
7194 } ConvPlacementData; | |
7195 | |
7196 static GList *conv_placement_fncs = NULL; | |
7197 static GaimConvPlacementFunc place_conv = NULL; | |
7198 | |
7199 /* This one places conversations in the last made window. */ | |
7200 static void | |
7201 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7202 { | |
7203 GaimGtkWindow *win; | |
7204 | |
7205 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7206 win = l ? l->data : NULL;; | |
7207 | |
7208 if (win == NULL) { | |
7209 win = gaim_gtk_conv_window_new(); | |
7210 | |
7211 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7212 gaim_gtk_conv_window_show(win); | |
7213 } else { | |
7214 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7215 } | |
7216 } | |
7217 | |
7218 /* This one places conversations in the last made window of the same type. */ | |
7219 static void | |
7220 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7221 { | |
7222 GaimGtkWindow *win; | |
7223 | |
7224 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7225 | |
7226 if (win == NULL) { | |
7227 win = gaim_gtk_conv_window_new(); | |
7228 | |
7229 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7230 gaim_gtk_conv_window_show(win); | |
7231 } else | |
7232 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7233 } | |
7234 | |
7235 /* This one places each conversation in its own window. */ | |
7236 static void | |
7237 conv_placement_new_window(GaimGtkConversation *conv) | |
7238 { | |
7239 GaimGtkWindow *win; | |
7240 | |
7241 win = gaim_gtk_conv_window_new(); | |
7242 | |
7243 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7244 | |
7245 gaim_gtk_conv_window_show(win); | |
7246 } | |
7247 | |
7248 static GaimGroup * | |
7249 conv_get_group(GaimGtkConversation *conv) | |
7250 { | |
7251 GaimGroup *group = NULL; | |
7252 | |
7253 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7254 GaimBuddy *buddy; | |
7255 | |
7256 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7257 gaim_conversation_get_name(conv->active_conv)); | |
7258 | |
7259 if (buddy != NULL) | |
12088 | 7260 group = gaim_buddy_get_group(buddy); |
11581 | 7261 |
7262 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7263 GaimChat *chat; | |
7264 | |
7265 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7266 gaim_conversation_get_name(conv->active_conv)); | |
7267 | |
7268 if (chat != NULL) | |
7269 group = gaim_chat_get_group(chat); | |
7270 } | |
7271 | |
7272 return group; | |
7273 } | |
7274 | |
7275 /* | |
7276 * This groups things by, well, group. Buddies from groups will always be | |
7277 * grouped together, and a buddy from a group not belonging to any currently | |
7278 * open windows will get a new window. | |
7279 */ | |
7280 static void | |
7281 conv_placement_by_group(GaimGtkConversation *conv) | |
7282 { | |
7283 GaimConversationType type; | |
7284 GaimGroup *group = NULL; | |
7285 GList *wl, *cl; | |
7286 | |
7287 type = gaim_conversation_get_type(conv->active_conv); | |
7288 | |
7289 group = conv_get_group(conv); | |
7290 | |
7291 /* Go through the list of IMs and find one with this group. */ | |
7292 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7293 GaimGtkWindow *win2; | |
7294 GaimGtkConversation *conv2; | |
7295 GaimGroup *group2 = NULL; | |
7296 | |
7297 win2 = wl->data; | |
7298 | |
7299 for (cl = win2->gtkconvs; | |
7300 cl != NULL; | |
7301 cl = cl->next) { | |
7302 conv2 = cl->data; | |
7303 | |
7304 group2 = conv_get_group(conv2); | |
7305 | |
7306 if (group == group2) { | |
7307 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7308 | |
7309 return; | |
7310 } | |
7311 } | |
7312 } | |
7313 | |
7314 /* Make a new window. */ | |
7315 conv_placement_new_window(conv); | |
7316 } | |
7317 | |
7318 /* This groups things by account. Otherwise, the same semantics as above */ | |
7319 static void | |
7320 conv_placement_by_account(GaimGtkConversation *conv) | |
7321 { | |
7322 GaimConversationType type; | |
7323 GList *wins, *convs; | |
7324 GaimAccount *account; | |
7325 | |
7326 account = gaim_conversation_get_account(conv->active_conv); | |
7327 type = gaim_conversation_get_type(conv->active_conv); | |
7328 | |
7329 /* Go through the list of IMs and find one with this group. */ | |
7330 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7331 GaimGtkWindow *win2; | |
7332 GaimGtkConversation *conv2; | |
7333 | |
7334 win2 = wins->data; | |
7335 | |
7336 for (convs = win2->gtkconvs; | |
7337 convs != NULL; | |
7338 convs = convs->next) { | |
7339 conv2 = convs->data; | |
7340 | |
7341 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7342 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7343 return; | |
7344 } | |
7345 } | |
7346 } | |
7347 | |
7348 /* Make a new window. */ | |
7349 conv_placement_new_window(conv); | |
7350 } | |
7351 | |
7352 static ConvPlacementData * | |
7353 get_conv_placement_data(const char *id) | |
7354 { | |
7355 ConvPlacementData *data = NULL; | |
7356 GList *n; | |
7357 | |
7358 for (n = conv_placement_fncs; n; n = n->next) { | |
7359 data = n->data; | |
7360 if (!strcmp(data->id, id)) | |
7361 return data; | |
7362 } | |
7363 | |
7364 return NULL; | |
7365 } | |
7366 | |
7367 static void | |
7368 add_conv_placement_fnc(const char *id, const char *name, | |
7369 GaimConvPlacementFunc fnc) | |
7370 { | |
7371 ConvPlacementData *data; | |
7372 | |
7373 data = g_new(ConvPlacementData, 1); | |
7374 | |
7375 data->id = g_strdup(id); | |
7376 data->name = g_strdup(name); | |
7377 data->fnc = fnc; | |
7378 | |
7379 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7380 } | |
7381 | |
7382 static void | |
7383 ensure_default_funcs(void) | |
7384 { | |
7385 if (conv_placement_fncs == NULL) { | |
7386 add_conv_placement_fnc("last", _("Last created window"), | |
7387 conv_placement_last_created_win); | |
7388 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7389 conv_placement_last_created_win_type); | |
7390 add_conv_placement_fnc("new", _("New window"), | |
7391 conv_placement_new_window); | |
7392 add_conv_placement_fnc("group", _("By group"), | |
7393 conv_placement_by_group); | |
7394 add_conv_placement_fnc("account", _("By account"), | |
7395 conv_placement_by_account); | |
7396 } | |
7397 } | |
7398 | |
7399 GList * | |
7400 gaim_gtkconv_placement_get_options(void) | |
7401 { | |
7402 GList *n, *list = NULL; | |
7403 ConvPlacementData *data; | |
7404 | |
7405 ensure_default_funcs(); | |
7406 | |
7407 for (n = conv_placement_fncs; n; n = n->next) { | |
7408 data = n->data; | |
7409 list = g_list_append(list, data->name); | |
7410 list = g_list_append(list, data->id); | |
7411 } | |
7412 | |
7413 return list; | |
7414 } | |
7415 | |
7416 | |
7417 void | |
7418 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
7419 GaimConvPlacementFunc fnc) | |
7420 { | |
7421 g_return_if_fail(id != NULL); | |
7422 g_return_if_fail(name != NULL); | |
7423 g_return_if_fail(fnc != NULL); | |
7424 | |
7425 ensure_default_funcs(); | |
7426 | |
7427 add_conv_placement_fnc(id, name, fnc); | |
7428 } | |
7429 | |
7430 void | |
7431 gaim_gtkconv_placement_remove_fnc(const char *id) | |
7432 { | |
7433 ConvPlacementData *data = get_conv_placement_data(id); | |
7434 | |
7435 if (data == NULL) | |
7436 return; | |
7437 | |
7438 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
7439 | |
7440 g_free(data->id); | |
7441 g_free(data->name); | |
7442 g_free(data); | |
7443 } | |
7444 | |
7445 const char * | |
7446 gaim_gtkconv_placement_get_name(const char *id) | |
7447 { | |
7448 ConvPlacementData *data; | |
7449 | |
7450 ensure_default_funcs(); | |
7451 | |
7452 data = get_conv_placement_data(id); | |
7453 | |
7454 if (data == NULL) | |
7455 return NULL; | |
7456 | |
7457 return data->name; | |
7458 } | |
7459 | |
7460 GaimConvPlacementFunc | |
7461 gaim_gtkconv_placement_get_fnc(const char *id) | |
7462 { | |
7463 ConvPlacementData *data; | |
7464 | |
7465 ensure_default_funcs(); | |
7466 | |
7467 data = get_conv_placement_data(id); | |
7468 | |
7469 if (data == NULL) | |
7470 return NULL; | |
7471 | |
7472 return data->fnc; | |
7473 } | |
7474 | |
7475 void | |
7476 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
7477 { | |
7478 g_return_if_fail(func != NULL); | |
7479 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7480 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7481 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7482 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7483 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7484 place_conv = NULL; |
11581 | 7485 } |
7486 | |
7487 GaimConvPlacementFunc | |
7488 gaim_gtkconv_placement_get_current_func(void) | |
7489 { | |
7490 return place_conv; | |
7491 } | |
7492 | |
7493 void | |
7494 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
7495 { | |
7496 if (place_conv) | |
7497 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7498 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7499 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7500 } |
12239 | 7501 |
7502 gboolean | |
7503 gaim_gtkconv_is_hidden(GaimGtkConversation *gtkconv) | |
7504 { | |
7505 g_return_val_if_fail(gtkconv != NULL, FALSE); | |
7506 | |
7507 return (gtkconv->win == hidden_convwin); | |
7508 } | |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7509 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7510 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7511 /* Algorithm from http://www.w3.org/TR/AERT#color-contrast */ |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7512 gboolean |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7513 color_is_visible(GdkColor foreground, GdkColor background) |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7514 { |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7515 gulong fg_brightness, |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7516 bg_brightness, |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7517 br_diff, |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7518 col_diff; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7519 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7520 fg_brightness = (foreground.red * 299 + foreground.green * 587 + foreground.blue * 114) / 1000; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7521 bg_brightness = (background.red * 299 + background.green * 587 + background.blue * 114) / 1000; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7522 br_diff = abs(fg_brightness - bg_brightness); |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7523 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7524 col_diff = abs(foreground.red - background.red) + abs(foreground.green - background.green) + abs(foreground.blue - background.blue); |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7525 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7526 return ((col_diff > MIN_COLOR_CONTRAST) && (br_diff > MIN_BRIGHTNESS_CONTRAST)); |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7527 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7528 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7529 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7530 GdkColor* |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7531 generate_nick_colors(guint numcolors, GdkColor background) |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7532 { |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7533 guint i; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7534 GdkColor *colors = (GdkColor*)g_malloc(numcolors * sizeof(GdkColor)); |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7535 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7536 srand(background.red + 1 * background.green + 1 * background.blue + 1); |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7537 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7538 for(i = 0; i < numcolors;){ |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7539 GdkColor color = { 0, rand()%65536, rand()%65536, rand()%65536 }; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7540 if(color_is_visible(color, background)){ |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7541 colors[i] = color; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7542 i++; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7543 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7544 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7545 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7546 return colors; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7547 } |