Mercurial > pidgin
annotate src/gtkconv.c @ 13419:3e9c865abd3f
[gaim-migrate @ 15794]
Resolve CID 22:
Event assign_zero: Variable "prpl_info" assigned value 0.
3764 GaimPluginProtocolInfo *prpl_info = NULL;
3795 if (gc != NULL)
3796 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
Event var_deref_op: Variable "prpl_info" tracked as NULL was dereferenced.
3798 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC)
Basically, if gc == NULL, then prpl_info == NULL, so this crashes.
Let's be safe and use a g_return_if_fail(). I also added one to the write_conv stuff I changed in my last commit. We seem to do that in a lot of places, so I guess I'll p
lay it safe.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 07 Mar 2006 02:09:05 +0000 |
parents | 7d1ebac854ba |
children | d52b9874c0de |
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 |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
69 #include "gtknickcolors.h" |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
70 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
71 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
72 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
73 typedef enum |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
74 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
75 GAIM_GTKCONV_SET_TITLE = 1 << 0, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
76 GAIM_GTKCONV_BUDDY_ICON = 1 << 1, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
77 GAIM_GTKCONV_MENU = 1 << 2, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
78 GAIM_GTKCONV_TAB_ICON = 1 << 3, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
79 GAIM_GTKCONV_TOPIC = 1 << 4, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
80 GAIM_GTKCONV_SMILEY_THEME = 1 << 5, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
81 GAIM_GTKCONV_COLORIZE_TITLE = 1 << 6 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
82 }GaimGtkConvFields; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
83 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
84 #define GAIM_GTKCONV_ALL ((1 << 7) - 1) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
85 |
12359
cbf9f2e26916
[gaim-migrate @ 14663]
Richard Laager <rlaager@wiktel.com>
parents:
12358
diff
changeset
|
86 #define SEND_COLOR "#204a87" |
cbf9f2e26916
[gaim-migrate @ 14663]
Richard Laager <rlaager@wiktel.com>
parents:
12358
diff
changeset
|
87 #define RECV_COLOR "#cc0000" |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
88 #define HIGHLIGHT_COLOR "#AF7F00" |
7854 | 89 |
12335 | 90 /* Undef this to turn off "custom-smiley" debug messages */ |
91 #define DEBUG_CUSTOM_SMILEY | |
92 | |
10108 | 93 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
94 | |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
95 #if 0 |
10108 | 96 /* These colors come from the default GNOME palette */ |
97 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
98 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
99 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
100 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
101 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
102 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
103 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
104 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
105 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
106 {0, 34816, 17920, 12544}, /* Red Dark */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
107 {0, 49408, 14336, 8704}, /* Red Shadow */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
108 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
109 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
110 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
111 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
112 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
113 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
114 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
115 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
116 {0, 57088, 16896, 7680}, /* Accent Red */ |
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
117 {0, 39168, 0, 0}, /* Accent Red Dark */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
118 {0, 17920, 40960, 17920}, /* Accent Green */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
119 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 120 }; |
6291 | 121 |
4359 | 122 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
123 #endif |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
124 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
125 /* From http://www.w3.org/TR/AERT#color-contrast */ |
12354
709548d845a1
[gaim-migrate @ 14658]
Luke Schierer <lschiere@pidgin.im>
parents:
12353
diff
changeset
|
126 #define MIN_BRIGHTNESS_CONTRAST 75 |
709548d845a1
[gaim-migrate @ 14658]
Luke Schierer <lschiere@pidgin.im>
parents:
12353
diff
changeset
|
127 #define MIN_COLOR_CONTRAST 200 |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
128 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
129 #define NUM_NICK_COLORS 220 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
130 static GdkColor *nick_colors = NULL; |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
131 static guint nbr_nick_colors; |
4359 | 132 |
11581 | 133 typedef struct { |
4359 | 134 GtkWidget *window; |
135 | |
136 GtkWidget *entry; | |
137 GtkWidget *message; | |
138 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
139 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
140 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
141 } InviteBuddyInfo; |
4359 | 142 |
143 static GtkWidget *invite_dialog = NULL; | |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
144 static GtkWidget *warn_close_dialog = NULL; |
4359 | 145 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
146 static GaimGtkWindow *hidden_convwin = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
147 static GList *window_list = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
148 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
149 |
11594 | 150 static gboolean update_send_to_selection(GaimGtkWindow *win); |
151 static void generate_send_to_items(GaimGtkWindow *win); | |
11581 | 152 |
4359 | 153 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
10810 | 154 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
11604 | 155 static void gray_stuff_out(GaimGtkConversation *gtkconv); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
156 static GList *generate_invite_user_names(GaimConnection *gc); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
157 static void add_chat_buddy_common(GaimConversation *conv, const char *name, |
11869 | 158 GaimConvChatBuddyFlags flags, const char *alias, const char *old_name); |
9605 | 159 static gboolean tab_complete(GaimConversation *conv); |
11604 | 160 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); |
11613 | 161 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); |
10810 | 162 static void update_typing_icon(GaimGtkConversation *gtkconv); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
163 static const 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
|
164 gboolean gaim_gtkconv_has_focus(GaimConversation *conv); |
12335 | 165 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data); |
166 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data); | |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
167 static GdkColor* generate_nick_colors(guint *numcolors, GdkColor background); |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
168 static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
169 static void gaim_gtkconv_update_fields(GaimConversation *conv, GaimGtkConvFields fields); |
4359 | 170 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
171 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
172 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
173 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
174 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
175 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
176 col = nick_colors[g_str_hash(name) % nbr_nick_colors]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
177 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
178 (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
|
179 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
180 /* 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
|
181 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
182 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
183 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
184 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
185 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
186 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
187 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
188 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
189 |
4359 | 190 /************************************************************************** |
191 * Callbacks | |
192 **************************************************************************/ | |
10971 | 193 |
4359 | 194 static gint |
10810 | 195 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 196 { |
10810 | 197 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 198 |
10810 | 199 l = list; |
200 while (l) { | |
201 GaimConversation *conv = l->data; | |
202 gaim_conversation_destroy(conv); | |
203 l = l->next; | |
204 } | |
11508 | 205 |
10810 | 206 g_list_free(list); |
11508 | 207 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
208 return TRUE; |
4359 | 209 } |
210 | |
8914 | 211 static gboolean |
10810 | 212 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 213 { |
10810 | 214 GaimConversation *conv = gtkconv->active_conv; |
11508 | 215 |
8914 | 216 if (!GTK_WIDGET_VISIBLE(w)) |
217 return FALSE; | |
218 | |
219 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
220 return FALSE; | |
221 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
222 /* 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
|
223 * 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
|
224 * 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
|
225 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
226 /* 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
|
227 * negate it anyway. --luke */ |
11338 | 228 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 229 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
230 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
231 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
|
232 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
|
233 } |
8914 | 234 if (w == gtkconv->entry) |
235 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
236 } | |
11338 | 237 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 238 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
239 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
240 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
|
241 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
|
242 } |
8914 | 243 if (w == gtkconv->entry) |
244 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
245 } | |
246 | |
247 return FALSE; | |
248 } | |
249 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
250 static void |
10810 | 251 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
252 { |
10810 | 253 GaimConversation *conv = c->active_conv; |
11508 | 254 |
10665 | 255 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
256 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
259 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 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
|
261 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
262 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 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
|
264 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
266 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
|
267 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
268 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
269 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
270 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
271 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
272 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
273 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
274 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
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 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
|
277 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
278 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
279 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
280 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
281 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
282 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
283 fg_color.blue / 256); |
8061 | 284 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
285 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
286 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
287 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
288 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
289 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
290 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
291 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
292 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
293 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
294 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
295 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
296 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
297 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
298 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
299 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
300 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
301 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
302 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
303 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
304 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
305 g_free(color); |
8677 | 306 |
9025 | 307 |
10665 | 308 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 309 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
310 else | |
311 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 312 } |
313 } | |
9130 | 314 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
315 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
316 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
317 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
318 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
319 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
320 |
9130 | 321 static const char * |
322 gaim_gtk_get_cmd_prefix(void) | |
323 { | |
324 return "/"; | |
325 } | |
326 | |
9167 | 327 static GaimCmdRet |
9829 | 328 say_command_cb(GaimConversation *conv, |
329 const char *cmd, char **args, char **error, void *data) | |
330 { | |
11338 | 331 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 332 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 333 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 334 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
335 | |
336 return GAIM_CMD_RET_OK; | |
337 } | |
338 | |
339 static GaimCmdRet | |
9167 | 340 me_command_cb(GaimConversation *conv, |
9597 | 341 const char *cmd, char **args, char **error, void *data) |
9167 | 342 { |
343 char *tmp; | |
344 | |
345 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 346 |
11338 | 347 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 348 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 349 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 350 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
351 | |
352 g_free(tmp); | |
353 return GAIM_CMD_RET_OK; | |
354 } | |
355 | |
9212 | 356 static GaimCmdRet |
357 debug_command_cb(GaimConversation *conv, | |
9597 | 358 const char *cmd, char **args, char **error, void *data) |
9212 | 359 { |
360 char *tmp, *markup; | |
361 GaimCmdStatus status; | |
362 | |
363 if (!g_ascii_strcasecmp(args[0], "version")) { | |
13369 | 364 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
|
365 markup = g_markup_escape_text(tmp, -1); |
9212 | 366 |
367 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
368 | |
369 g_free(tmp); | |
370 g_free(markup); | |
371 return status; | |
372 } else { | |
373 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
374 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
375 return GAIM_CMD_STATUS_OK; | |
376 } | |
377 } | |
378 | |
9213 | 379 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
380 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
381 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
382 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
383 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
384 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
385 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
386 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
387 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
388 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
389 } |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
390 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
391 static GaimCmdRet |
9213 | 392 help_command_cb(GaimConversation *conv, |
9597 | 393 const char *cmd, char **args, char **error, void *data) |
9213 | 394 { |
9597 | 395 GList *l, *text; |
9213 | 396 GString *s; |
9597 | 397 |
398 if (args[0] != NULL) { | |
399 s = g_string_new(""); | |
400 text = gaim_cmd_help(conv, args[0]); | |
401 | |
402 if (text) { | |
403 for (l = text; l; l = l->next) | |
404 if (l->next) | |
9816 | 405 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 406 else |
9816 | 407 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 408 } else { |
409 g_string_append(s, _("No such command (in this context).")); | |
410 } | |
411 } else { | |
412 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
413 "The following commands are available in this context:\n")); | |
414 | |
415 text = gaim_cmd_list(conv); | |
416 for (l = text; l; l = l->next) | |
9213 | 417 if (l->next) |
9597 | 418 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 419 else |
9597 | 420 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 421 } |
422 | |
423 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
424 g_string_free(s, TRUE); | |
425 | |
426 return GAIM_CMD_STATUS_OK; | |
427 } | |
428 | |
4359 | 429 static void |
9374 | 430 send_history_add(GaimConversation *conv, const char *message) |
431 { | |
432 GList *first; | |
433 | |
434 first = g_list_first(conv->send_history); | |
435 | |
436 if (first->data) | |
437 g_free(first->data); | |
438 | |
439 first->data = g_strdup(message); | |
440 | |
441 conv->send_history = g_list_prepend(first, NULL); | |
442 } | |
443 | |
9832 | 444 static gboolean |
445 check_for_and_do_command(GaimConversation *conv) | |
446 { | |
447 GaimGtkConversation *gtkconv; | |
448 char *cmd; | |
449 const char *prefix; | |
450 GaimAccount *account; | |
451 GtkTextIter start; | |
452 | |
453 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
454 account = gaim_conversation_get_account(conv); | |
455 prefix = gaim_gtk_get_cmd_prefix(); | |
456 | |
457 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
458 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
459 | |
460 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
461 && !gtk_text_iter_get_child_anchor(&start)) { | |
462 GaimCmdStatus status; | |
463 char *error, *cmdline, *markup, *send_history; | |
464 GtkTextIter end; | |
465 | |
466 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
467 send_history_add(conv, send_history); | |
468 g_free(send_history); | |
469 | |
470 cmdline = cmd + strlen(prefix); | |
471 | |
472 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
473 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
474 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
475 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
476 g_free(cmd); | |
477 g_free(markup); | |
478 | |
479 switch (status) { | |
480 case GAIM_CMD_STATUS_OK: | |
481 return TRUE; | |
482 case GAIM_CMD_STATUS_NOT_FOUND: | |
483 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
484 gaim_conversation_write(conv, "", _("No such command."), | |
485 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
486 | |
487 return TRUE; | |
488 } | |
489 return FALSE; | |
490 case GAIM_CMD_STATUS_WRONG_ARGS: | |
491 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
492 "to that command."), | |
493 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
494 return TRUE; | |
495 case GAIM_CMD_STATUS_FAILED: | |
496 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
497 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
498 if(error) | |
499 g_free(error); | |
500 return TRUE; | |
501 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 502 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 503 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 504 GAIM_MESSAGE_NO_LOG, time(NULL)); |
505 else | |
10843 | 506 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 507 GAIM_MESSAGE_NO_LOG, time(NULL)); |
508 return TRUE; | |
509 case GAIM_CMD_STATUS_WRONG_PRPL: | |
510 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
511 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
512 return TRUE; | |
513 } | |
514 } | |
515 | |
516 g_free(cmd); | |
517 return FALSE; | |
518 } | |
519 | |
9374 | 520 static void |
10810 | 521 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 522 { |
10810 | 523 GaimConversation *conv = gtkconv->active_conv; |
8655 | 524 GaimAccount *account; |
8677 | 525 GaimConnection *gc; |
12216 | 526 GaimMessageFlags flags = 0; |
8448 | 527 char *buf, *clean; |
4359 | 528 |
8655 | 529 account = gaim_conversation_get_account(conv); |
9130 | 530 |
9471 | 531 if (!gaim_account_is_connected(account)) |
532 return; | |
533 | |
11338 | 534 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 535 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 536 return; |
537 | |
9832 | 538 if (check_for_and_do_command(conv)) { |
539 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
540 return; | |
9130 | 541 } |
542 | |
8442 | 543 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 544 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 545 |
4359 | 546 gtk_widget_grab_focus(gtkconv->entry); |
547 | |
8448 | 548 if (strlen(clean) == 0) { |
549 g_free(clean); | |
4359 | 550 return; |
551 } | |
552 | |
12272 | 553 gaim_idle_touch(); |
554 | |
12216 | 555 /* XXX: is there a better way to tell if the message has images? */ |
556 if (GTK_IMHTML(gtkconv->entry)->im_images != NULL) | |
557 flags |= GAIM_MESSAGE_IMAGES; | |
558 | |
8677 | 559 gc = gaim_account_get_connection(account); |
10665 | 560 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 561 char **bufs; |
562 int i; | |
563 | |
564 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
565 for (i = 0; bufs[i]; i++) { | |
9374 | 566 send_history_add(conv, bufs[i]); |
11338 | 567 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 568 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), bufs[i], flags); |
11338 | 569 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 570 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), bufs[i], flags); |
8677 | 571 } |
572 | |
573 g_strfreev(bufs); | |
574 | |
575 } else { | |
9374 | 576 send_history_add(conv, buf); |
11338 | 577 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 578 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), buf, flags); |
11338 | 579 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 580 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), buf, flags); |
8677 | 581 } |
4359 | 582 |
8677 | 583 g_free(clean); |
4359 | 584 g_free(buf); |
585 | |
8061 | 586 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 587 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 588 } |
589 | |
590 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
591 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 592 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
593 GaimAccount *account; |
4359 | 594 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
595 GaimConversation *conv = gtkconv->active_conv; |
4359 | 596 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
597 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
598 name = gaim_conversation_get_name(conv); |
7879 | 599 |
11338 | 600 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 601 GaimBuddy *b; |
602 | |
603 b = gaim_find_buddy(account, name); | |
604 if (b != NULL) | |
9730 | 605 gaim_gtkdialogs_remove_buddy(b); |
7859 | 606 else if (account != NULL && gaim_account_is_connected(account)) |
607 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 608 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 609 GaimChat *c; |
610 | |
611 c = gaim_blist_find_chat(account, name); | |
612 if (c != NULL) | |
9730 | 613 gaim_gtkdialogs_remove_chat(c); |
7859 | 614 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 615 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 616 } |
4359 | 617 |
618 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
619 } | |
620 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
621 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 622 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
623 GaimConversation *conv = gtkconv->active_conv; |
7975 | 624 GaimPluginProtocolInfo *prpl_info = NULL; |
625 GaimConnection *gc; | |
626 | |
627 if ((gc = gaim_conversation_get_gc(conv))) { | |
628 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
629 | |
630 /* | |
631 * If there are special needs for getting info on users in | |
632 * buddy chat "rooms"... | |
633 */ | |
634 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
635 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
636 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
637 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
638 } |
7975 | 639 else |
640 prpl_info->get_info(gc, who); | |
641 } | |
642 } | |
643 | |
644 | |
4359 | 645 static void |
10810 | 646 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 647 { |
10810 | 648 GaimConversation *conv = gtkconv->active_conv; |
4359 | 649 |
11338 | 650 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 651 serv_get_info(gaim_conversation_get_gc(conv), |
652 gaim_conversation_get_name(conv)); | |
653 | |
654 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 655 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 656 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
657 GaimGtkChatPane *gtkchat; |
4359 | 658 GtkTreeIter iter; |
659 GtkTreeModel *model; | |
660 GtkTreeSelection *sel; | |
9554 | 661 char *name; |
4359 | 662 |
663 gtkchat = gtkconv->u.chat; | |
664 | |
665 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
666 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
667 | |
668 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 669 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 670 else |
671 return; | |
672 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
673 chat_do_info(gtkconv, name); |
9554 | 674 g_free(name); |
4359 | 675 } |
676 } | |
677 | |
678 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
679 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 680 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
681 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
682 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
683 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
684 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
685 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
686 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
687 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 688 |
689 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
690 } | |
691 | |
692 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
693 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 694 { |
695 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
696 GaimGtkConversation *gtkconv; |
4359 | 697 |
698 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
699 | |
700 if (resp == GTK_RESPONSE_OK) { | |
701 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
702 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
703 | |
10113 | 704 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 705 return; |
706 | |
707 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
708 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 709 message, buddy); |
710 } | |
711 | |
712 gtk_widget_destroy(invite_dialog); | |
713 invite_dialog = NULL; | |
714 | |
715 g_free(info); | |
716 } | |
717 | |
718 static void | |
9909 | 719 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
720 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
721 { | |
722 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
723 const char *convprotocol; | |
724 | |
725 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
726 | |
727 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
728 { | |
729 GaimBlistNode *node = NULL; | |
730 GaimBuddy *buddy; | |
731 | |
732 memcpy(&node, sd->data, sizeof(node)); | |
733 | |
734 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
735 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
736 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
737 buddy = (GaimBuddy *)node; | |
738 else | |
739 return; | |
740 | |
741 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
742 { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
743 gaim_notify_error(GAIM_GTK_CONVERSATION(info->conv), NULL, |
9909 | 744 _("That buddy is not on the same protocol as this " |
10843 | 745 "chat."), NULL); |
9909 | 746 } |
747 else | |
748 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
749 | |
750 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
751 } | |
752 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
753 { | |
754 char *protocol = NULL; | |
755 char *username = NULL; | |
756 GaimAccount *account; | |
757 | |
11137 | 758 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 759 &protocol, &username, NULL)) |
760 { | |
761 if (account == NULL) | |
762 { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
763 gaim_notify_error(GAIM_GTK_CONVERSATION(info->conv), NULL, |
9909 | 764 _("You are not currently signed on with an account that " |
765 "can invite that buddy."), NULL); | |
766 } | |
767 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
768 { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
769 gaim_notify_error(GAIM_GTK_CONVERSATION(info->conv), NULL, |
9909 | 770 _("That buddy is not on the same protocol as this " |
10843 | 771 "chat."), NULL); |
9909 | 772 } |
773 else | |
774 { | |
775 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
776 } | |
777 } | |
778 | |
779 if (username != NULL) g_free(username); | |
780 if (protocol != NULL) g_free(protocol); | |
781 | |
782 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
783 } | |
784 } | |
785 | |
786 static const GtkTargetEntry dnd_targets[] = | |
787 { | |
788 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
789 {"application/x-im-contact", 0, 1} | |
790 }; | |
791 | |
792 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
793 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 794 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
795 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
796 InviteBuddyInfo *info = NULL; |
4359 | 797 |
798 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
799 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
800 GaimGtkWindow *gtkwin; |
4359 | 801 GtkWidget *label; |
802 GtkWidget *vbox, *hbox; | |
803 GtkWidget *table; | |
804 GtkWidget *img; | |
805 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
806 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 807 GTK_ICON_SIZE_DIALOG); |
4359 | 808 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
809 info = g_new0(InviteBuddyInfo, 1); |
4359 | 810 info->conv = conv; |
811 | |
11581 | 812 gc = gaim_conversation_get_gc(conv); |
813 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 814 |
815 /* Create the new dialog. */ | |
816 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 817 _("Invite Buddy Into Chat Room"), |
7879 | 818 GTK_WINDOW(gtkwin->window), 0, |
819 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
820 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 821 |
822 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 823 GTK_RESPONSE_OK); |
11243 | 824 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 825 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
826 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
827 | |
9909 | 828 info->window = GTK_WIDGET(invite_dialog); |
829 | |
4359 | 830 /* Setup the outside spacing. */ |
831 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
832 | |
11243 | 833 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
834 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 835 |
836 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 837 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 838 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
839 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
840 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
841 | |
842 /* Setup the right vbox. */ | |
843 vbox = gtk_vbox_new(FALSE, 0); | |
844 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
845 | |
846 /* Put our happy label in it. */ | |
847 label = gtk_label_new(_("Please enter the name of the user you wish " | |
848 "to invite, along with an optional invite " | |
849 "message.")); | |
850 gtk_widget_set_size_request(label, 350, -1); | |
851 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
852 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
853 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
854 | |
855 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 856 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 857 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
858 | |
859 /* Setup the table we're going to use to lay stuff out. */ | |
860 table = gtk_table_new(2, 2, FALSE); | |
11243 | 861 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
862 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
863 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 864 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
865 | |
866 /* Now the Buddy label */ | |
867 label = gtk_label_new(NULL); | |
868 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
869 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
870 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
871 | |
872 /* Now the Buddy drop-down entry field. */ | |
873 info->entry = gtk_combo_new(); | |
874 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
875 gtk_entry_set_activates_default( | |
876 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
877 | |
878 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
879 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
880 | |
881 /* Fill in the names. */ | |
882 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
883 generate_invite_user_names(gc)); | |
884 | |
885 | |
886 /* Now the label for "Message" */ | |
887 label = gtk_label_new(NULL); | |
888 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
889 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
890 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
891 | |
892 | |
893 /* And finally, the Message entry field. */ | |
894 info->message = gtk_entry_new(); | |
895 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
896 | |
897 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
898 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
899 | |
900 /* Connect the signals. */ | |
901 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
902 G_CALLBACK(do_invite), info); | |
9909 | 903 /* Setup drag-and-drop */ |
904 gtk_drag_dest_set(info->window, | |
905 GTK_DEST_DEFAULT_MOTION | | |
906 GTK_DEST_DEFAULT_DROP, | |
907 dnd_targets, | |
908 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
909 GDK_ACTION_COPY); | |
910 gtk_drag_dest_set(info->entry, | |
911 GTK_DEST_DEFAULT_MOTION | | |
912 GTK_DEST_DEFAULT_DROP, | |
913 dnd_targets, | |
914 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
915 GDK_ACTION_COPY); | |
916 | |
917 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
918 G_CALLBACK(invite_dnd_recv), info); | |
919 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
920 G_CALLBACK(invite_dnd_recv), info); | |
921 | |
4359 | 922 } |
923 | |
924 gtk_widget_show_all(invite_dialog); | |
925 | |
926 if (info != NULL) | |
927 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
928 } | |
929 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
930 static void |
7748 | 931 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
932 { | |
9714 | 933 gaim_gtkdialogs_im(); |
7748 | 934 } |
935 | |
936 static void | |
9504 | 937 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 938 { |
9504 | 939 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 940 FILE *fp; |
941 const char *name; | |
10849 | 942 gchar *text; |
9489 | 943 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
944 if ((fp = g_fopen(filename, "w+")) == NULL) { |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
945 gaim_notify_error(GAIM_GTK_CONVERSATION(conv), NULL, _("Unable to open file."), NULL); |
9489 | 946 return; |
947 } | |
948 | |
949 name = gaim_conversation_get_name(conv); | |
10849 | 950 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 951 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 952 |
953 text = gtk_imhtml_get_markup( | |
954 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
955 fprintf(fp, "%s", text); | |
956 g_free(text); | |
957 | |
958 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 959 fclose(fp); |
960 } | |
961 | |
10849 | 962 /* |
963 * It would be kinda cool if this gave the option of saving a | |
964 * plaintext v. HTML file. | |
965 */ | |
9489 | 966 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
967 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
968 { |
11581 | 969 GaimGtkWindow *win = data; |
970 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 971 gchar *buf; |
972 | |
973 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 974 |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
975 gaim_request_file(GAIM_GTK_CONVERSATION(conv), _("Save Conversation"), |
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
976 gaim_escape_filename(buf), |
10849 | 977 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); |
9489 | 978 |
979 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
980 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
981 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
982 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
983 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
984 { |
11581 | 985 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
986 GaimConversation *conv; |
9917 | 987 GaimLogType type; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
988 GaimGtkBuddyList *gtkblist; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
989 GdkCursor *cursor; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
990 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
991 GaimAccount *account; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
992 GSList *buddies; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
993 GSList *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
994 |
11581 | 995 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
996 |
11338 | 997 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 998 type = GAIM_LOG_IM; |
11338 | 999 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 1000 type = GAIM_LOG_CHAT; |
1001 else | |
1002 return; | |
1003 | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1004 gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1005 cursor = gdk_cursor_new(GDK_WATCH); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1006 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1007 gdk_window_set_cursor(gtkblist->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1008 gdk_window_set_cursor(win->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1009 gdk_cursor_unref(cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1010 while (gtk_events_pending()) |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1011 gtk_main_iteration(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1012 |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1013 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1014 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1015 |
10845 | 1016 buddies = gaim_find_buddies(account, name); |
1017 for (cur = buddies; cur != NULL; cur = cur->next) | |
1018 { | |
1019 GaimBlistNode *node = cur->data; | |
10846 | 1020 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 1021 { |
1022 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
1023 g_slist_free(buddies); | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1024 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1025 gdk_window_set_cursor(win->window->window, NULL); |
10845 | 1026 return; |
1027 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1028 } |
10845 | 1029 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1030 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1031 gaim_gtk_log_show(type, name, account); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1032 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1033 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1034 gdk_window_set_cursor(win->window->window, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1035 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1036 |
8974 | 1037 static void |
1038 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
1039 { | |
11581 | 1040 GaimGtkWindow *win = data; |
8974 | 1041 GaimConversation *conv; |
1042 GaimGtkConversation *gtkconv; | |
1043 | |
11581 | 1044 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 1045 gtkconv = GAIM_GTK_CONVERSATION(conv); |
1046 | |
1047 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1048 } | |
1049 | |
7295 | 1050 struct _search { |
1051 GaimGtkConversation *gtkconv; | |
1052 GtkWidget *entry; | |
1053 }; | |
1054 | |
7929 | 1055 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 1056 { |
7929 | 1057 switch (resp) { |
1058 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1059 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1060 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1061 break; |
1062 | |
1063 case GTK_RESPONSE_DELETE_EVENT: | |
1064 case GTK_RESPONSE_CLOSE: | |
1065 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1066 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1067 s->gtkconv->dialogs.search = NULL; | |
1068 g_free(s); | |
1069 break; | |
1070 } | |
7295 | 1071 } |
1072 | |
1073 static void | |
7751 | 1074 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1075 { |
11581 | 1076 GaimGtkWindow *gtkwin = data; |
1077 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1078 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1079 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1080 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1081 GTK_ICON_SIZE_DIALOG); |
7929 | 1082 GtkWidget *label; |
7295 | 1083 struct _search *s; |
1084 | |
7798 | 1085 if (gtkconv->dialogs.search) { |
1086 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1087 return; |
7798 | 1088 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1089 |
7295 | 1090 s = g_malloc(sizeof(struct _search)); |
1091 s->gtkconv = gtkconv; | |
7929 | 1092 |
1093 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1094 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1095 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1096 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1097 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1098 GTK_RESPONSE_OK); |
7929 | 1099 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1100 G_CALLBACK(do_search_cb), s); | |
1101 | |
11243 | 1102 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1103 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1104 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1105 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
|
1106 gtk_container_set_border_width( |
11243 | 1107 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1108 | |
1109 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1110 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1111 hbox); |
7929 | 1112 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1113 | |
1114 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1115 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1116 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1117 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1118 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1119 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1120 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1121 | |
1122 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1123 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1124 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1125 g_signal_connect(G_OBJECT(s->entry), "changed", |
1126 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1127 gtkconv->dialogs.search); | |
1128 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
|
1129 |
7295 | 1130 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1131 gtk_widget_grab_focus(s->entry); |
7295 | 1132 } |
1133 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1134 static void |
9468 | 1135 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1136 { | |
11581 | 1137 GaimGtkWindow *win = data; |
1138 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1139 |
11338 | 1140 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1141 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1142 } | |
1143 | |
1144 } | |
1145 | |
1146 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1147 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1148 { |
11581 | 1149 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1150 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1151 |
11581 | 1152 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
|
1153 |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1154 gaim_gtk_pounce_editor_show(gaim_conversation_get_account(conv), |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1155 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1156 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1157 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1159 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1160 { |
11581 | 1161 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1162 GaimGtkConversation *gtkconv; |
8756 | 1163 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1164 |
11581 | 1165 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1166 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1167 | |
1168 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1169 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1170 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1171 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1172 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1173 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1174 { |
11581 | 1175 GaimGtkWindow *win = data; |
8756 | 1176 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1177 GaimGtkConversation *gtkconv; |
8756 | 1178 GtkIMHtmlToolbar *toolbar; |
1179 | |
11581 | 1180 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1181 conv = gtkconv->active_conv; | |
8756 | 1182 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1183 | |
1184 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1185 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1186 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1187 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1188 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1189 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1190 { |
11581 | 1191 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1192 GaimConversation *conv; |
7879 | 1193 GaimAccount *account; |
1194 const char *name; | |
1195 | |
11581 | 1196 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1197 account = gaim_conversation_get_account(conv); |
1198 name = gaim_conversation_get_name(conv); | |
1199 | |
11338 | 1200 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1201 GaimBuddy *b; |
1202 | |
1203 b = gaim_find_buddy(account, name); | |
1204 if (b != NULL) | |
9730 | 1205 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1206 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1207 GaimChat *c; |
1208 | |
1209 c = gaim_blist_find_chat(account, name); | |
1210 if (c != NULL) | |
9730 | 1211 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1212 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1216 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 { |
11581 | 1218 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1219 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1220 |
11581 | 1221 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1222 |
10810 | 1223 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1224 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1225 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1226 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1227 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1228 { |
11581 | 1229 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1230 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1231 |
11581 | 1232 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1233 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1234 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1235 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1236 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1237 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1238 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1239 { |
11581 | 1240 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1241 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1242 |
11581 | 1243 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1244 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1245 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
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_add_remove_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; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1253 |
11581 | 1254 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1255 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1256 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1257 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1258 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1259 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1260 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1261 { |
11581 | 1262 GaimGtkWindow *win = data; |
1263 | |
1264 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
|
1265 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1266 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1267 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1268 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1269 { |
11581 | 1270 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1271 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1272 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1273 |
11581 | 1274 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1275 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1276 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1277 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1278 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1279 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
|
1280 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1281 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1282 return; |
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 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1285 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1286 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1287 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1288 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1289 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1290 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1291 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1292 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1293 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1294 } |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1295 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1296 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1297 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1298 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1299 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1300 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1301 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1302 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1303 /* 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
|
1304 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1305 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1306 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1307 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1309 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1310 { |
10377 | 1311 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1312 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
|
1313 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1314 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1315 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1316 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1317 { |
11581 | 1318 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1319 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1320 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1321 |
11581 | 1322 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
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 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1325 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1326 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1327 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1328 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1329 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1330 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1331 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1332 |
7961 | 1333 static void |
9188 | 1334 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1335 { | |
12188 | 1336 gaim_prefs_set_bool("/gaim/gtk/conversations/show_timestamps", |
9188 | 1337 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
1338 } | |
1339 | |
1340 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1341 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1342 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1343 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1344 GaimAccount *account; |
1345 GaimConnection *gc; | |
7961 | 1346 GaimPluginProtocolInfo *prpl_info = NULL; |
1347 char *real_who; | |
1348 | |
1349 account = gaim_conversation_get_account(conv); | |
10431 | 1350 g_return_if_fail(account != NULL); |
1351 | |
1352 gc = gaim_account_get_connection(account); | |
1353 g_return_if_fail(gc != NULL); | |
1354 | |
1355 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1356 | |
1357 if (prpl_info && prpl_info->get_cb_real_name) | |
1358 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1359 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1360 else | |
1361 real_who = g_strdup(who); | |
1362 | |
1363 if(!real_who) | |
1364 return; | |
1365 | |
10431 | 1366 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1367 |
1368 g_free(real_who); | |
1369 } | |
1370 | |
1371 static void | |
10810 | 1372 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1373 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1374 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1375 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1376 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1377 GtkTreeSelection *sel; |
9554 | 1378 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1379 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1380 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1381 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1382 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1383 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
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 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1386 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
|
1387 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1388 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1389 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1390 chat_do_im(gtkconv, name); |
9554 | 1391 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1392 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1393 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1394 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1395 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1396 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1397 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1398 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1399 GaimConvChat *chat; |
11869 | 1400 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1401 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1402 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1403 GtkTreeSelection *sel; |
10504 | 1404 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1405 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1406 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1407 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1408 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1409 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1410 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1411 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
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 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1414 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1415 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1416 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1417 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1418 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1419 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1420 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1421 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1422 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1423 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1424 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1425 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1426 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1427 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1428 |
11869 | 1429 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1430 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1431 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1432 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1433 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1434 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1435 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1436 { |
1437 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1438 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1439 chat_do_im(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1440 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1441 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1442 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1443 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1444 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1445 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1446 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1447 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1448 | |
1449 serv_send_file(gc, who, NULL); | |
1450 } | |
1451 | |
1452 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1453 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1454 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1455 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1456 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1457 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1458 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1459 chat_do_info(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1460 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1461 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1462 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1463 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1464 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1465 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1466 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1467 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1468 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1469 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1470 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1471 who = g_object_get_data(G_OBJECT(w), "user_data"); |
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 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1474 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1475 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1476 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1477 * 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
|
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 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1481 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1482 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1483 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1484 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1485 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1486 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1487 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1488 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1489 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1490 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1491 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1492 GaimAccount *account; |
6695 | 1493 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1494 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1495 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1496 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1497 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1498 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1499 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1500 if (b != NULL) |
9730 | 1501 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1502 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1503 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1504 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1505 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1506 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1507 |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1508 static GtkTextMark * |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1509 get_mark_for_user(GaimGtkConversation *gtkconv, const char *who) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1510 { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1511 GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1512 char *tmp = g_strconcat("user:", who, NULL); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1513 GtkTextMark *mark = gtk_text_buffer_get_mark(buf, tmp); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1514 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1515 g_free(tmp); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1516 return mark; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1517 } |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1518 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1519 static void |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1520 menu_last_said_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1521 { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1522 GtkTextMark *mark; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1523 const char *who; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1524 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1525 who = g_object_get_data(G_OBJECT(w), "user_data"); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1526 mark = get_mark_for_user(gtkconv, who); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1527 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1528 if (mark != NULL) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1529 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(gtkconv->imhtml), mark, 0.1, FALSE, 0, 0); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1530 else |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1531 g_return_if_reached(); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1532 } |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1533 |
8143 | 1534 static GtkWidget * |
10504 | 1535 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1536 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1537 { | |
1538 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1539 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1540 gboolean is_me = FALSE; |
8143 | 1541 GtkWidget *button; |
1542 | |
1543 /* | |
1544 * If a menu already exists, destroy it before creating a new one, | |
1545 * thus freeing-up the memory it occupied. | |
1546 */ | |
1547 if (menu) | |
1548 gtk_widget_destroy(menu); | |
1549 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1550 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1551 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1552 |
8143 | 1553 menu = gtk_menu_new(); |
1554 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1555 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1556 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1557 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
|
1558 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
|
1559 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1560 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1561 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1562 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1563 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1564 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1565 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
|
1566 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1567 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1568 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
|
1569 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
|
1570 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1571 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1572 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1573 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1574 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1575 } |
9498 | 1576 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1577 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1578 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
|
1579 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1580 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1581 } |
1582 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1583 if (prpl_info->get_cb_away) { |
10221 | 1584 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
|
1585 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1586 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1587 } |
1588 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1589 if (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1590 if (gaim_find_buddy(gc->account, who)) |
10221 | 1591 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
|
1592 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1593 else |
10221 | 1594 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
|
1595 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1596 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1597 } |
1598 | |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1599 button = gaim_new_item_from_stock(menu, _("Last said"), GTK_STOCK_INDEX, |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1600 G_CALLBACK(menu_last_said_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1601 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1602 if (!get_mark_for_user(GAIM_GTK_CONVERSATION(conv), who)) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1603 gtk_widget_set_sensitive(button, FALSE); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1604 |
8143 | 1605 return menu; |
1606 } | |
1607 | |
1608 | |
1609 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1610 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1611 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1612 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1613 GaimPluginProtocolInfo *prpl_info = NULL; |
1614 GaimGtkChatPane *gtkchat; | |
1615 GaimConnection *gc; | |
1616 GaimAccount *account; | |
1617 GtkTreeSelection *sel; | |
1618 GtkTreeIter iter; | |
1619 GtkTreeModel *model; | |
1620 GtkWidget *menu; | |
1621 gchar *who; | |
1622 | |
1623 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1624 gtkchat = gtkconv->u.chat; | |
1625 account = gaim_conversation_get_account(conv); | |
1626 gc = account->gc; | |
1627 | |
1628 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1629 | |
1630 if (gc != NULL) | |
1631 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1632 | |
1633 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1634 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1635 return FALSE; | |
1636 | |
9498 | 1637 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1638 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1639 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1640 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1641 0, GDK_CURRENT_TIME); |
10504 | 1642 g_free(who); |
8143 | 1643 |
1644 return TRUE; | |
1645 } | |
1646 | |
1647 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1648 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1649 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1650 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1651 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1652 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1653 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1654 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1655 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1656 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1657 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1658 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1659 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1660 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1661 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1662 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1663 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1664 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1665 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1666 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1667 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1668 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1669 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1670 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
|
1671 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1672 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1673 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1674 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1675 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1676 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1677 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1678 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1679 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1680 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1681 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1682 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1683 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
|
1684 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1685 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1686 chat_do_im(gtkconv, who); |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1687 } else if (event->button == 2 && event->type == GDK_BUTTON_PRESS) { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1688 /* Move to user's anchor */ |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1689 GtkTextMark *mark = get_mark_for_user(gtkconv, who); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1690 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1691 if(mark != NULL) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1692 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(gtkconv->imhtml), mark, 0.1, FALSE, 0, 0); |
7398 | 1693 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1694 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1695 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1696 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1697 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1698 |
10504 | 1699 g_free(who); |
1700 gtk_tree_path_free(path); | |
1701 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1702 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1703 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1704 |
8133 | 1705 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1706 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1707 { |
10827 | 1708 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1709 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1710 int index, i, total, found = 0; |
8133 | 1711 |
11581 | 1712 win = gtkconv->win; |
1713 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1714 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1715 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1716 /* 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
|
1717 for (i = forward ? index + 1 : index - 1; |
11581 | 1718 !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
|
1719 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1720 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1721 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1722 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1723 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1724 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1725 found = 1; |
8133 | 1726 } |
11252 | 1727 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1728 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1729 /* 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
|
1730 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1731 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1732 (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
|
1733 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1734 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1735 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1736 found = 1; |
8133 | 1737 } |
10827 | 1738 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1739 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1740 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1741 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1742 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1743 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1744 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1745 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1746 } |
11581 | 1747 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1748 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1749 } |
8133 | 1750 } |
1751 | |
10827 | 1752 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1753 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1754 } |
1755 | |
4359 | 1756 static gboolean |
8105 | 1757 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1758 { |
11581 | 1759 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1760 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1761 GaimGtkConversation *gtkconv; |
8105 | 1762 int curconv; |
1763 | |
10810 | 1764 gtkconv = (GaimGtkConversation *)data; |
10849 | 1765 conv = gtkconv->active_conv; |
11581 | 1766 win = gtkconv->win; |
1767 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1768 |
8105 | 1769 /* If CTRL was held down... */ |
1770 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1771 switch (event->keyval) { |
1772 case GDK_Up: | |
1773 if (!conv->send_history) | |
1774 break; | |
1775 | |
1776 if (!conv->send_history->prev) { | |
1777 GtkTextIter start, end; | |
1778 | |
1779 if (conv->send_history->data) | |
1780 g_free(conv->send_history->data); | |
1781 | |
1782 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1783 &start); | |
1784 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1785 | |
1786 conv->send_history->data = | |
8506 | 1787 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1788 } |
8677 | 1789 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1790 if (conv->send_history->next && conv->send_history->next->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)); | |
4359 | 1794 |
1795 conv->send_history = conv->send_history->next; | |
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 |
8061 | 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. */ | |
1814 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1815 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1816 } |
1817 | |
8105 | 1818 return TRUE; |
4359 | 1819 break; |
1820 | |
1821 case GDK_Down: | |
1822 if (!conv->send_history) | |
1823 break; | |
1824 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1825 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1826 GObject *object; |
8677 | 1827 GtkTextIter iter; |
1828 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1829 |
4359 | 1830 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1831 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1832 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1833 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1834 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
|
1835 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1836 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1837 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1838 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1839 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
|
1840 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1841 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1842 |
8105 | 1843 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1844 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1845 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1846 0, NULL); |
8677 | 1847 /* this is mainly just a hack so the formatting at the |
1848 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1849 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1850 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1851 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1852 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1853 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1854 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1855 } |
4359 | 1856 } |
1857 | |
8105 | 1858 return TRUE; |
4359 | 1859 break; |
8105 | 1860 |
13354
da2179c099f0
[gaim-migrate @ 15726]
Richard Laager <rlaager@wiktel.com>
parents:
13352
diff
changeset
|
1861 case GDK_Page_Down: |
8143 | 1862 case ']': |
11581 | 1863 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1864 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1865 else |
11581 | 1866 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1867 return TRUE; |
1868 break; | |
1869 | |
13354
da2179c099f0
[gaim-migrate @ 15726]
Richard Laager <rlaager@wiktel.com>
parents:
13352
diff
changeset
|
1870 case GDK_Page_Up: |
8143 | 1871 case '[': |
11581 | 1872 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1873 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1874 else |
11581 | 1875 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1876 return TRUE; |
1877 break; | |
1878 | |
8108 | 1879 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1880 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1881 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1882 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1883 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1884 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1885 } |
8108 | 1886 |
1887 return TRUE; | |
1888 break; | |
1889 | |
11252 | 1890 case GDK_comma: |
11581 | 1891 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1892 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1893 curconv - 1); |
1894 break; | |
1895 | |
1896 case GDK_period: | |
11581 | 1897 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1898 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1899 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1900 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1901 #else |
1902 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1903 #endif | |
11252 | 1904 break; |
1905 | |
8105 | 1906 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1907 } |
8758 | 1908 |
8105 | 1909 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1910 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1911 { |
10864 | 1912 if (event->keyval > '0' && event->keyval <= '9') |
1913 { | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1914 guint switchto = event->keyval - '1'; |
11581 | 1915 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1916 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1917 |
1918 return TRUE; | |
1919 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1920 } |
8758 | 1921 |
8105 | 1922 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1923 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1924 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1925 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1926 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1927 case GDK_Tab: |
9605 | 1928 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1929 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1930 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1931 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1932 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1933 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1934 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1935 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1936 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1937 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1938 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1939 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1940 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1941 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1942 } |
4359 | 1943 return FALSE; |
1944 } | |
1945 | |
1946 /* | |
1947 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1948 * 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
|
1949 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1950 * 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
|
1951 * going all the way down to the notebook. I suspect a bug in |
4359 | 1952 * GtkTextView, but I'm not ready to point any fingers yet. |
1953 */ | |
1954 static gboolean | |
1955 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1956 { | |
1957 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1958 /* Right single click */ | |
1959 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1960 | |
1961 return TRUE; | |
1962 } | |
1963 | |
1964 return FALSE; | |
1965 } | |
1966 | |
8173 | 1967 /* |
1968 * If someone tries to type into the conversation backlog of a | |
1969 * conversation window then we yank focus from the conversation backlog | |
1970 * and give it to the text entry box so that people can type | |
1971 * all the live long day and it will get entered into the entry box. | |
1972 */ | |
6057 | 1973 static gboolean |
8105 | 1974 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1975 { |
1976 GaimGtkConversation *gtkconv = data; | |
1977 | |
8237 | 1978 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1979 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1980 (event->keyval == GDK_F10) || |
1981 (event->keyval == GDK_Shift_L) || | |
1982 (event->keyval == GDK_Shift_R) || | |
1983 (event->keyval == GDK_Escape) || | |
8177 | 1984 (event->keyval == GDK_Up) || |
1985 (event->keyval == GDK_Down) || | |
1986 (event->keyval == GDK_Left) || | |
8191 | 1987 (event->keyval == GDK_Right) || |
1988 (event->keyval == GDK_Home) || | |
9297 | 1989 (event->keyval == GDK_End) || |
1990 (event->keyval == GDK_Tab) || | |
1991 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1992 return FALSE; |
1993 | |
1994 if (event->type == GDK_KEY_RELEASE) | |
1995 gtk_widget_grab_focus(gtkconv->entry); | |
1996 | |
1997 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1998 | |
1999 return TRUE; | |
6057 | 2000 } |
2001 | |
4359 | 2002 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2003 gaim_gtkconv_set_active_conversation(GaimConversation *conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2004 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2005 GaimGtkConversation *gtkconv; |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2006 GaimConversation *old_conv; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2007 GtkIMHtml *entry; |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2008 const char *protocol_name; |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2009 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2010 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2011 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2012 gtkconv = GAIM_GTK_CONVERSATION(conv); |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2013 old_conv = gtkconv->active_conv; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2014 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2015 if (old_conv == conv) |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2016 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2017 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2018 gaim_conversation_close_logs(old_conv); |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2019 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2020 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2021 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2022 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging))); |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
2023 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2024 entry = GTK_IMHTML(gtkconv->entry); |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2025 protocol_name = gaim_account_get_protocol_name(conv->account); |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2026 gtk_imhtml_set_protocol_name(entry, protocol_name); |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2027 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol_name); |
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2028 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2029 if (!(conv->features & GAIM_CONNECTION_HTML)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2030 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2031 else if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO && |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2032 !(old_conv->features & GAIM_CONNECTION_FORMATTING_WBFO)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2033 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2034 /* The old conversation allowed formatting on parts of the |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2035 * buffer, but the new one only allows it on the whole |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2036 * buffer. This code saves the formatting from the current |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2037 * position of the cursor, clears the formatting, then |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2038 * applies the saved formatting to the entire buffer. */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2039 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2040 gboolean bold; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2041 gboolean italic; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2042 gboolean underline; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2043 char *fontface = gtk_imhtml_get_current_fontface(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2044 char *forecolor = gtk_imhtml_get_current_forecolor(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2045 char *backcolor = gtk_imhtml_get_current_backcolor(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2046 char *background = gtk_imhtml_get_current_background(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2047 gint fontsize = gtk_imhtml_get_current_fontsize(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2048 gboolean bold2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2049 gboolean italic2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2050 gboolean underline2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2051 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2052 gtk_imhtml_get_current_format(entry, &bold, &italic, &underline); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2053 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2054 /* Clear existing formatting */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2055 gtk_imhtml_clear_formatting(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2056 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2057 /* Apply saved formatting to the whole buffer. */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2058 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2059 gtk_imhtml_get_current_format(entry, &bold2, &italic2, &underline2); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2060 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2061 if (bold != bold2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2062 gtk_imhtml_toggle_bold(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2063 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2064 if (italic != italic2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2065 gtk_imhtml_toggle_italic(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2066 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2067 if (underline != underline2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2068 gtk_imhtml_toggle_underline(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2069 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2070 gtk_imhtml_toggle_fontface(entry, fontface); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2071 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2072 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2073 gtk_imhtml_font_set_size(entry, fontsize); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2074 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2075 gtk_imhtml_toggle_forecolor(entry, forecolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2076 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2077 if (!(conv->features & GAIM_CONNECTION_NO_BGCOLOR)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2078 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2079 gtk_imhtml_toggle_backcolor(entry, backcolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2080 gtk_imhtml_toggle_background(entry, background); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2081 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2082 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2083 g_free(fontface); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2084 g_free(forecolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2085 g_free(backcolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2086 g_free(background); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2087 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2088 else |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2089 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2090 /* This is done in default_formatize, which is called from clear_formatting_cb, |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2091 * which is (obviously) a clear_formatting signal handler. However, if we're |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2092 * here, we didn't call gtk_imhtml_clear_formatting() (because we want to |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2093 * preserve the formatting exactly as it is), so we have to do this now. */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2094 gtk_imhtml_set_whole_buffer_formatting_only(entry, |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2095 (conv->features & GAIM_CONNECTION_FORMATTING_WBFO)); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2096 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2097 |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
2098 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-switched", conv); |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2099 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2100 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
2101 void |
11604 | 2102 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
2103 { | |
2104 GaimGtkConversation *gtkconv; | |
2105 | |
2106 g_return_if_fail(conv != NULL); | |
2107 | |
2108 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2109 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2110 gaim_gtkconv_set_active_conversation(conv); |
11604 | 2111 |
2112 gray_stuff_out(gtkconv); | |
2113 update_typing_icon(gtkconv); | |
2114 | |
2115 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
2116 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
2117 } | |
2118 | |
2119 static void | |
4673 | 2120 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 2121 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2122 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 2123 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2124 GaimConversation *conv; |
4359 | 2125 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2126 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2127 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2128 |
11594 | 2129 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 2130 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 2131 } |
2132 | |
2133 static void | |
2134 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
2135 gchar *new_text, gint new_text_length, gpointer user_data) | |
2136 { | |
10810 | 2137 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2138 GaimConversation *conv; | |
2139 | |
2140 g_return_if_fail(gtkconv != NULL); | |
11508 | 2141 |
10810 | 2142 conv = gtkconv->active_conv; |
4359 | 2143 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2144 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2145 return; |
2146 | |
10810 | 2147 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2148 gtk_text_iter_is_end(position))); | |
4359 | 2149 } |
2150 | |
2151 static void | |
2152 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2153 GtkTextIter *end_pos, gpointer user_data) | |
2154 { | |
10810 | 2155 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2156 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2157 GaimConvIm *im; |
4359 | 2158 |
10810 | 2159 g_return_if_fail(gtkconv != NULL); |
11508 | 2160 |
10810 | 2161 conv = gtkconv->active_conv; |
4359 | 2162 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2163 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2164 return; |
2165 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2166 im = GAIM_CONV_IM(conv); |
4359 | 2167 |
2168 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2169 | |
2170 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2171 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2172 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2173 |
2174 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2175 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2176 GAIM_NOT_TYPING); |
4359 | 2177 } |
2178 else { | |
2179 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2180 got_typing_keypress(gtkconv, FALSE); |
4359 | 2181 } |
2182 } | |
2183 | |
8189 | 2184 /************************************************************************** |
2185 * A bunch of buddy icon functions | |
2186 **************************************************************************/ | |
11581 | 2187 GdkPixbuf * |
2188 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2189 { |
10116 | 2190 GaimAccount *account = NULL; |
2191 const char *name = NULL; | |
7143 | 2192 GdkPixbuf *status = NULL; |
2193 | |
10116 | 2194 g_return_val_if_fail(conv != NULL, NULL); |
2195 | |
2196 account = gaim_conversation_get_account(conv); | |
2197 name = gaim_conversation_get_name(conv); | |
2198 | |
2199 g_return_val_if_fail(account != NULL, NULL); | |
2200 g_return_val_if_fail(name != NULL, NULL); | |
2201 | |
13090 | 2202 /* Use the buddy icon, if possible */ |
11338 | 2203 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2204 GaimBuddy *b = gaim_find_buddy(account, name); |
2205 if (b != NULL) { | |
2206 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2207 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2208 } |
2209 } | |
2210 | |
13090 | 2211 /* If they don't have a buddy icon, then use the PRPL icon */ |
2212 if (status == NULL) | |
2213 status = gaim_gtk_create_prpl_icon(account, small_icon ? 0.5 : 1.0); | |
2214 | |
7143 | 2215 return status; |
2216 } | |
2217 | |
8189 | 2218 static void |
2219 update_tab_icon(GaimConversation *conv) | |
2220 { | |
2221 GaimGtkConversation *gtkconv; | |
11581 | 2222 GaimGtkWindow *win; |
8189 | 2223 GaimAccount *account; |
2224 const char *name; | |
2225 GdkPixbuf *status = NULL; | |
2226 | |
10116 | 2227 g_return_if_fail(conv != NULL); |
2228 | |
8189 | 2229 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2230 win = gtkconv->win; |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2231 if (conv != gtkconv->active_conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2232 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2233 |
8189 | 2234 name = gaim_conversation_get_name(conv); |
2235 account = gaim_conversation_get_account(conv); | |
2236 | |
11581 | 2237 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2238 |
10116 | 2239 g_return_if_fail(status != NULL); |
2240 | |
8189 | 2241 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2242 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2243 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2244 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2245 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2246 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2247 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2248 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2249 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2250 { |
11581 | 2251 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2252 | |
2253 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2254 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2255 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2256 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2257 } |
8189 | 2258 } |
2259 | |
2260 static gboolean | |
2261 redraw_icon(gpointer data) | |
2262 { | |
10810 | 2263 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2264 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2265 GaimAccount *account; |
2266 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2267 |
2268 GdkPixbuf *buf; | |
2269 GdkPixbuf *scale; | |
2270 GdkPixmap *pm; | |
2271 GdkBitmap *bm; | |
2272 gint delay; | |
9318 | 2273 int scale_width, scale_height; |
8189 | 2274 |
2275 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2276 account = gaim_conversation_get_account(conv); |
2277 if(account && account->gc) | |
2278 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2279 |
2280 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2281 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2282 | |
10483 | 2283 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2284 NULL, &scale_width, &scale_height); |
2285 | |
2286 /* this code is ugly, and scares me */ | |
8189 | 2287 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2288 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2289 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2290 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2291 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2292 GDK_INTERP_BILINEAR); |
8189 | 2293 |
2294 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2295 g_object_unref(G_OBJECT(scale)); | |
2296 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2297 g_object_unref(G_OBJECT(pm)); | |
2298 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2299 | |
2300 if (bm) | |
2301 g_object_unref(G_OBJECT(bm)); | |
2302 | |
9131 | 2303 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2304 |
2305 if (delay < 100) | |
9131 | 2306 delay = 100; |
2307 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2308 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2309 |
2310 return FALSE; | |
2311 } | |
2312 | |
2313 static void | |
10810 | 2314 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2315 { |
2316 int delay; | |
2317 | |
8228 | 2318 if (gtkconv->u.im->anim == NULL) |
2319 return; | |
2320 | |
8202 | 2321 if (gtkconv->u.im->icon_timer != 0) |
2322 return; | |
2323 | |
8189 | 2324 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2325 return; | |
2326 | |
10639 | 2327 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2328 | |
2329 if (delay < 100) | |
2330 delay = 100; | |
2331 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2332 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2333 } |
2334 | |
2335 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2336 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2337 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2338 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2339 GaimGtkWindow *gtkwin; |
2340 | |
2341 g_return_if_fail(conv != NULL); | |
2342 | |
9887 | 2343 if (gtkconv->u.im->icon_container != NULL) |
2344 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2345 |
2346 if (gtkconv->u.im->anim != NULL) | |
2347 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2348 | |
2349 if (gtkconv->u.im->icon_timer != 0) | |
2350 g_source_remove(gtkconv->u.im->icon_timer); | |
2351 | |
2352 if (gtkconv->u.im->iter != NULL) | |
2353 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2354 | |
2355 gtkconv->u.im->icon_timer = 0; | |
2356 gtkconv->u.im->icon = NULL; | |
2357 gtkconv->u.im->anim = NULL; | |
2358 gtkconv->u.im->iter = NULL; | |
10456 | 2359 gtkconv->u.im->icon_container = NULL; |
9687 | 2360 gtkconv->u.im->show_icon = FALSE; |
10456 | 2361 |
11581 | 2362 gtkwin = gtkconv->win; |
10456 | 2363 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2364 } |
2365 | |
9497 | 2366 static void |
9504 | 2367 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2368 { |
10810 | 2369 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2370 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2371 FILE *fp; |
2372 GaimBuddyIcon *icon; | |
2373 const void *data; | |
2374 size_t len; | |
2375 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2376 if ((fp = g_fopen(filename, "wb")) == NULL) { |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
2377 gaim_notify_error(gtkconv, NULL, _("Unable to open file."), NULL); |
9497 | 2378 return; |
2379 } | |
2380 | |
2381 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2382 data = gaim_buddy_icon_get_data(icon, &len); | |
2383 | |
2384 if ((len <= 0) || (data == NULL)) { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
2385 gaim_notify_error(gtkconv, NULL, _("Unable to save icon file to disk."), NULL); |
13405 | 2386 fclose(fp); |
9497 | 2387 return; |
2388 } | |
2389 | |
2390 fwrite(data, 1, len, fp); | |
2391 fclose(fp); | |
2392 } | |
2393 | |
2394 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2395 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2396 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2397 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2398 const gchar *ext; |
9497 | 2399 gchar *buf; |
2400 | |
2401 g_return_if_fail(conv != NULL); | |
9504 | 2402 |
10953 | 2403 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2404 if (ext == NULL) | |
2405 ext = "icon"; | |
2406 | |
2407 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2408 |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
2409 gaim_request_file(gtkconv, _("Save Icon"), buf, TRUE, |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2410 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2411 |
2412 g_free(buf); | |
2413 } | |
2414 | |
11581 | 2415 static void |
2416 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2417 { | |
2418 if (gtkconv->u.im->icon_timer != 0) | |
2419 g_source_remove(gtkconv->u.im->icon_timer); | |
2420 | |
2421 gtkconv->u.im->icon_timer = 0; | |
2422 } | |
2423 | |
2424 | |
2425 static void | |
2426 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2427 { | |
2428 gtkconv->u.im->animate = | |
2429 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2430 | |
2431 if (gtkconv->u.im->animate) | |
2432 start_anim(NULL, gtkconv); | |
2433 else | |
2434 stop_anim(NULL, gtkconv); | |
2435 } | |
2436 | |
8189 | 2437 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2438 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2439 { |
2440 static GtkWidget *menu = NULL; | |
2441 GtkWidget *button; | |
2442 | |
2443 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2444 return FALSE; | |
2445 | |
2446 /* | |
2447 * If a menu already exists, destroy it before creating a new one, | |
2448 * thus freeing-up the memory it occupied. | |
2449 */ | |
2450 if (menu != NULL) | |
2451 gtk_widget_destroy(menu); | |
2452 | |
2453 menu = gtk_menu_new(); | |
2454 | |
2455 if (gtkconv->u.im->anim && | |
2456 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2457 { | |
2458 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2459 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2460 gtkconv->u.im->icon_timer); |
2461 } | |
2462 | |
2463 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2464 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2465 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2466 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2467 gtk_widget_show(button); | |
2468 | |
2469 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
|
2470 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2471 0, 0, NULL); |
2472 | |
2473 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2474 | |
2475 return TRUE; | |
2476 } | |
10456 | 2477 |
2478 static void | |
2479 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2480 { | |
11581 | 2481 GaimGtkWindow *win = data; |
10456 | 2482 GaimConversation *conv; |
2483 GaimGtkConversation *gtkconv; | |
2484 gboolean active; | |
2485 | |
11581 | 2486 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2487 |
2488 if (!conv) | |
2489 return; | |
2490 | |
11338 | 2491 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2492 |
2493 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2494 | |
2495 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2496 gtkconv->u.im->show_icon = active; | |
2497 if (active) | |
2498 gaim_gtkconv_update_buddy_icon(conv); | |
2499 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2500 remove_icon(gtkconv); |
10456 | 2501 } |
2502 | |
8189 | 2503 /************************************************************************** |
2504 * End of the bunch of buddy icon functions | |
2505 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2506 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2507 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2508 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2509 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2510 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2511 if(gtkconv->win==hidden_convwin) { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
2512 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2513 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2514 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2515 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2516 gaim_gtkconv_set_active_conversation(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2517 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2518 gaim_gtk_conv_window_raise(gtkconv->win); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2519 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2520 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2521 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2522 GList * |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2523 gaim_gtk_conversations_find_unseen_list(GaimConversationType type, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2524 GaimUnseenState min_state, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2525 gboolean hidden_only, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2526 guint max_count) |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2527 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2528 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2529 GList *r = NULL; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2530 guint c = 0; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2531 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2532 if (type == GAIM_CONV_TYPE_IM) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2533 l = gaim_get_ims(); |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2534 } else if (type == GAIM_CONV_TYPE_CHAT) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2535 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2536 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2537 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2538 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2539 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2540 for (; l != NULL && (max_count == 0 || c < max_count); l = l->next) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2541 GaimConversation *conv = (GaimConversation*)l->data; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2542 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2543 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2544 if(gtkconv->active_conv != conv) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2545 continue; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2546 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2547 if (gtkconv->unseen_state >= min_state |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2548 && (!hidden_only || |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2549 (hidden_only && gtkconv->win == hidden_convwin))) { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2550 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2551 r = g_list_prepend(r, conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2552 c++; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2553 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2554 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2555 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2556 return r; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2557 } |
8189 | 2558 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2559 static void |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2560 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2561 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2562 g_return_if_fail(conv != NULL); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2563 gaim_gtkconv_present_conversation(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2564 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2565 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2566 guint |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2567 gaim_gtk_conversations_fill_menu(GtkWidget *menu, GList *convs) |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2568 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2569 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2570 guint ret=0; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2571 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2572 g_return_val_if_fail(menu != NULL, 0); |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2573 g_return_val_if_fail(convs != NULL, 0); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2574 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2575 for (l = convs; l != NULL ; l = l->next) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2576 GaimConversation *conv = (GaimConversation*)l->data; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2577 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2578 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2579 GtkWidget *icon = gtk_image_new(); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2580 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2581 GtkWidget *item; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2582 gchar *text = g_strdup_printf("%s (%d)", |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2583 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2584 gtkconv->unseen_count); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2585 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2586 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2587 g_object_unref(pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2588 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2589 item = gtk_image_menu_item_new_with_label(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2590 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), icon); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2591 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(unseen_conv_menu_cb), conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2592 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2593 g_free(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2594 ret++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2595 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2596 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2597 return ret; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2598 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2599 |
11581 | 2600 GaimGtkWindow * |
2601 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2602 { | |
2603 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2604 return gtkconv->win; | |
2605 } | |
2606 | |
2607 static GtkItemFactoryEntry menu_items[] = | |
2608 { | |
2609 /* Conversation menu */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2610 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>", NULL }, |
11581 | 2611 |
2612 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2613 0, "<StockItem>", GAIM_STOCK_IM }, | |
2614 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2615 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2616 |
2617 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2618 "<StockItem>", GTK_STOCK_FIND }, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2619 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", GAIM_STOCK_LOG }, |
11581 | 2620 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2621 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
12897
e9b0c90ce58a
[gaim-migrate @ 15250]
Richard Laager <rlaager@wiktel.com>
parents:
12867
diff
changeset
|
2622 { N_("/Conversation/Clea_r Scrollback"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
11581 | 2623 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2624 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2625 |
2626 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2627 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2628 0, "<StockItem>", GAIM_STOCK_POUNCE }, |
11581 | 2629 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2630 "<StockItem>", GAIM_STOCK_INFO }, | |
2631 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2632 "<StockItem>", GAIM_STOCK_INVITE }, | |
2633 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2634 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2635 |
2636 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2637 "<StockItem>", GAIM_STOCK_EDIT }, | |
2638 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2639 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2640 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2641 "<StockItem>", GTK_STOCK_ADD }, | |
2642 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2643 "<StockItem>", GTK_STOCK_REMOVE }, | |
2644 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2645 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2646 |
2647 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2648 "<StockItem>", GAIM_STOCK_LINK }, | |
2649 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2650 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2651 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2652 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2653 |
2654 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2655 "<StockItem>", GTK_STOCK_CLOSE }, | |
2656 | |
2657 /* Options */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2658 { N_("/_Options"), NULL, NULL, 0, "<Branch>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2659 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2660 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2661 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2662 { "/Options/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2663 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2664 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>", NULL }, |
11581 | 2665 }; |
2666 | |
2667 static const int menu_item_count = | |
2668 sizeof(menu_items) / sizeof(*menu_items); | |
2669 | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2670 static const char * |
11581 | 2671 item_factory_translate_func (const char *path, gpointer func_data) |
2672 { | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2673 return _(path); |
11581 | 2674 } |
2675 | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2676 static void |
12816 | 2677 sound_method_pref_changed_cb(const char *name, GaimPrefType type, |
2678 gconstpointer value, gpointer data) | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2679 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2680 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2681 const char *method = value; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2682 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2683 if (!strcmp(method, "none")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2684 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2685 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2686 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2687 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2688 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2689 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2690 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2691 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2692 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2693 if (gtkconv != NULL) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2694 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2695 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2696 gtk_widget_set_sensitive(win->menu.sounds, TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2697 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2698 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2699 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2700 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2701 static void |
12816 | 2702 show_buddy_icons_pref_changed_cb(const char *name, GaimPrefType type, |
2703 gconstpointer value, gpointer data) | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2704 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2705 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2706 gboolean show_icons = GPOINTER_TO_INT(value); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2707 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2708 if (!show_icons) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2709 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2710 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2711 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2712 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2713 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2714 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2715 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2716 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2717 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2718 if (gtkconv != NULL) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2719 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2720 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2721 gtk_widget_set_sensitive(win->menu.show_icon, TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2722 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2723 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2724 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2725 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2726 |
11581 | 2727 static GtkWidget * |
2728 setup_menubar(GaimGtkWindow *win) | |
2729 { | |
2730 GtkAccelGroup *accel_group; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2731 const char *method; |
11581 | 2732 |
2733 accel_group = gtk_accel_group_new (); | |
2734 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2735 g_object_unref(accel_group); | |
2736 | |
2737 win->menu.item_factory = | |
2738 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2739 | |
2740 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2741 (GtkTranslateFunc)item_factory_translate_func, |
11581 | 2742 NULL, NULL); |
2743 | |
2744 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2745 menu_items, win); | |
2746 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2747 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2748 | |
2749 | |
2750 win->menu.menubar = | |
2751 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2752 | |
2753 | |
2754 win->menu.view_log = | |
2755 gtk_item_factory_get_widget(win->menu.item_factory, | |
2756 N_("/Conversation/View Log")); | |
2757 | |
2758 /* --- */ | |
2759 | |
2760 win->menu.send_file = | |
2761 gtk_item_factory_get_widget(win->menu.item_factory, | |
2762 N_("/Conversation/Send File...")); | |
2763 | |
2764 win->menu.add_pounce = | |
2765 gtk_item_factory_get_widget(win->menu.item_factory, | |
2766 N_("/Conversation/Add Buddy Pounce...")); | |
2767 | |
2768 /* --- */ | |
2769 | |
2770 win->menu.get_info = | |
2771 gtk_item_factory_get_widget(win->menu.item_factory, | |
2772 N_("/Conversation/Get Info")); | |
2773 | |
2774 win->menu.invite = | |
2775 gtk_item_factory_get_widget(win->menu.item_factory, | |
2776 N_("/Conversation/Invite...")); | |
2777 | |
2778 /* --- */ | |
2779 | |
2780 win->menu.alias = | |
2781 gtk_item_factory_get_widget(win->menu.item_factory, | |
2782 N_("/Conversation/Alias...")); | |
2783 | |
2784 win->menu.block = | |
2785 gtk_item_factory_get_widget(win->menu.item_factory, | |
2786 N_("/Conversation/Block...")); | |
2787 | |
2788 win->menu.add = | |
2789 gtk_item_factory_get_widget(win->menu.item_factory, | |
2790 N_("/Conversation/Add...")); | |
2791 | |
2792 win->menu.remove = | |
2793 gtk_item_factory_get_widget(win->menu.item_factory, | |
2794 N_("/Conversation/Remove...")); | |
2795 | |
2796 /* --- */ | |
2797 | |
2798 win->menu.insert_link = | |
2799 gtk_item_factory_get_widget(win->menu.item_factory, | |
2800 N_("/Conversation/Insert Link...")); | |
2801 | |
2802 win->menu.insert_image = | |
2803 gtk_item_factory_get_widget(win->menu.item_factory, | |
2804 N_("/Conversation/Insert Image...")); | |
2805 | |
2806 /* --- */ | |
2807 | |
2808 win->menu.logging = | |
2809 gtk_item_factory_get_widget(win->menu.item_factory, | |
2810 N_("/Options/Enable Logging")); | |
2811 win->menu.sounds = | |
2812 gtk_item_factory_get_widget(win->menu.item_factory, | |
2813 N_("/Options/Enable Sounds")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2814 method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2815 if (!strcmp(method, "none")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2816 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2817 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2818 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2819 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2820 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2821 gaim_prefs_connect_callback(win, "/gaim/gtk/sound/method", |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2822 sound_method_pref_changed_cb, win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2823 |
11581 | 2824 win->menu.show_formatting_toolbar = |
2825 gtk_item_factory_get_widget(win->menu.item_factory, | |
2826 N_("/Options/Show Formatting Toolbars")); | |
2827 win->menu.show_timestamps = | |
2828 gtk_item_factory_get_widget(win->menu.item_factory, | |
2829 N_("/Options/Show Timestamps")); | |
2830 win->menu.show_icon = | |
2831 gtk_item_factory_get_widget(win->menu.item_factory, | |
2832 N_("/Options/Show Buddy Icon")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2833 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2834 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2835 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2836 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2837 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2838 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2839 gaim_prefs_connect_callback(win, "/gaim/gtk/conversations/im/show_buddy_icons", |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2840 show_buddy_icons_pref_changed_cb, win); |
11581 | 2841 |
2842 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2843 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2844 win->menu.tray); | |
2845 gtk_widget_show(win->menu.tray); | |
2846 | |
2847 gtk_widget_show(win->menu.menubar); | |
2848 | |
2849 return win->menu.menubar; | |
2850 } | |
2851 | |
4359 | 2852 |
2853 /************************************************************************** | |
2854 * Utility functions | |
2855 **************************************************************************/ | |
2856 | |
2857 static void | |
10810 | 2858 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2859 { |
10810 | 2860 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2861 GaimConvIm *im; |
4685 | 2862 |
4359 | 2863 /* |
2864 * 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
|
2865 * send GAIM_TYPED any time soon. |
4359 | 2866 */ |
2867 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2868 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2869 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2870 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2871 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2872 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2873 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2874 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2875 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2876 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2877 |
2878 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2879 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2880 GAIM_TYPING); |
4359 | 2881 |
2882 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2883 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2884 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2885 gaim_conv_im_set_type_again(im, 0); |
4359 | 2886 } |
2887 } | |
2888 | |
4736 | 2889 static void |
10810 | 2890 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2891 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2892 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2893 GaimConvIm *im = NULL; |
10810 | 2894 GaimConversation *conv = gtkconv->active_conv; |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2895 char *stock_id; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2896 const char *tooltip; |
11508 | 2897 |
11581 | 2898 gtkwin = gtkconv->win; |
4736 | 2899 |
12008 | 2900 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2901 im = GAIM_CONV_IM(conv); |
4736 | 2902 |
12008 | 2903 if (gtkwin->menu.typing_icon) { |
2904 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2905 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2906 |
12008 | 2907 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2908 return; | |
2909 | |
2910 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2911 stock_id = GAIM_STOCK_TYPING; | |
2912 tooltip = _("User is typing..."); | |
2913 } else { | |
2914 stock_id = GAIM_STOCK_TYPED; | |
2915 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2916 } |
12008 | 2917 |
2918 if (gtkwin->menu.typing_icon == NULL) | |
2919 { | |
2920 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
|
2921 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
|
2922 gtkwin->menu.typing_icon, |
12008 | 2923 tooltip); |
4736 | 2924 } |
12008 | 2925 else |
2926 { | |
2927 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2928 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2929 gtkwin->menu.typing_icon, | |
2930 tooltip); | |
2931 } | |
2932 | |
2933 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2934 } |
2935 | |
4685 | 2936 static gboolean |
11594 | 2937 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2938 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2939 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2940 GaimConversation *conv; |
4359 | 2941 GtkWidget *menu; |
2942 GList *child; | |
11594 | 2943 GaimBuddy *b; |
11581 | 2944 |
2945 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2946 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2947 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2948 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2949 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2950 account = gaim_conversation_get_account(conv); |
11581 | 2951 |
13131 | 2952 if (account == NULL) |
2953 return FALSE; | |
2954 | |
11594 | 2955 if (win->menu.send_to == NULL) |
4685 | 2956 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2957 |
11594 | 2958 if (!(b = gaim_find_buddy(account, conv->name))) |
2959 return FALSE; | |
2960 | |
2961 | |
2962 gtk_widget_show(win->menu.send_to); | |
4359 | 2963 |
2964 menu = gtk_menu_item_get_submenu( | |
11594 | 2965 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2966 |
2967 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2968 child != NULL; | |
2969 child = child->next) { | |
2970 | |
2971 GtkWidget *item = child->data; | |
11594 | 2972 GaimBuddy *item_buddy; |
2973 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2974 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2975 "gaim_buddy_name"); | |
2976 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2977 | |
2978 if (b == item_buddy) { | |
4359 | 2979 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2980 break; | |
2981 } | |
2982 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2983 |
4685 | 2984 return FALSE; |
4359 | 2985 } |
2986 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2987 static gboolean |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2988 send_to_item_enter_notify_cb(GtkWidget *menuitem, GdkEventCrossing *event, GtkWidget *label) |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2989 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2990 gtk_widget_set_sensitive(GTK_WIDGET(label), TRUE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2991 return FALSE; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2992 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2993 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2994 static gboolean |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2995 send_to_item_leave_notify_cb(GtkWidget *menuitem, GdkEventCrossing *event, GtkWidget *label) |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2996 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2997 gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2998 return FALSE; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2999 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3000 |
4359 | 3001 static void |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3002 create_sendto_item(GtkWidget *menu, GtkSizeGroup *sg, GSList **group, GaimBuddy *buddy, GaimAccount *account, const char *name) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3003 { |
11594 | 3004 GtkWidget *box; |
3005 GtkWidget *label; | |
3006 GtkWidget *image; | |
3007 GtkWidget *menuitem; | |
11625 | 3008 GdkPixbuf *pixbuf; |
11616 | 3009 gchar *text; |
11594 | 3010 |
3011 /* Create a pixmap for the protocol icon. */ | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3012 if (buddy != NULL) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3013 pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)buddy, GAIM_STATUS_ICON_SMALL); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3014 else |
13090 | 3015 pixbuf = gaim_gtk_create_prpl_icon(account, 0.5); |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3016 |
11594 | 3017 /* Now convert it to GtkImage */ |
3018 if (pixbuf == NULL) | |
3019 image = gtk_image_new(); | |
3020 else | |
13090 | 3021 { |
11625 | 3022 image = gtk_image_new_from_pixbuf(pixbuf); |
13090 | 3023 g_object_unref(G_OBJECT(pixbuf)); |
3024 } | |
11594 | 3025 |
3026 gtk_size_group_add_widget(sg, image); | |
3027 | |
3028 /* Make our menu item */ | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3029 text = g_strdup_printf("%s (%s)", name, gaim_account_get_username(account)); |
11616 | 3030 menuitem = gtk_radio_menu_item_new_with_label(*group, text); |
3031 g_free(text); | |
11594 | 3032 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
3033 | |
3034 /* Do some evil, see some evil, speak some evil. */ | |
3035 box = gtk_hbox_new(FALSE, 0); | |
3036 | |
3037 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
3038 g_object_ref(label); | |
3039 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
3040 | |
3041 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
3042 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
3043 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3044 if (buddy != NULL && |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3045 !gaim_presence_is_online(gaim_buddy_get_presence(buddy)) && |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3046 !gaim_account_supports_offline_message(account, buddy)) |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3047 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3048 gtk_widget_set_sensitive(label, FALSE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3049 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3050 /* Set the label sensitive when the menuitem is highlighted and |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3051 * insensitive again when the mouse leaves it. This way, it |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3052 * doesn't appear weird from the highlighting of the embossed |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3053 * (insensitive style) text.*/ |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3054 g_signal_connect(menuitem, "enter-notify-event", |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3055 G_CALLBACK(send_to_item_enter_notify_cb), label); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3056 g_signal_connect(menuitem, "leave-notify-event", |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3057 G_CALLBACK(send_to_item_leave_notify_cb), label); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3058 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3059 |
11594 | 3060 g_object_unref(label); |
3061 | |
3062 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
3063 | |
3064 gtk_widget_show(label); | |
3065 gtk_widget_show(image); | |
3066 gtk_widget_show(box); | |
3067 | |
3068 /* Set our data and callbacks. */ | |
3069 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3070 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(name), g_free); |
11594 | 3071 |
3072 g_signal_connect(G_OBJECT(menuitem), "activate", | |
3073 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
3074 | |
3075 gtk_widget_show(menuitem); | |
3076 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3077 } | |
3078 | |
3079 static void | |
3080 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 3081 { |
4359 | 3082 GtkWidget *menu; |
3083 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3084 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 3085 GaimGtkConversation *gtkconv; |
3086 GSList *l, *buds; | |
3087 | |
3088 g_return_if_fail(win != NULL); | |
3089 | |
3090 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
3091 | |
11604 | 3092 g_return_if_fail(gtkconv != NULL); |
3093 | |
11594 | 3094 if (win->menu.send_to != NULL) |
3095 gtk_widget_destroy(win->menu.send_to); | |
3096 | |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12272
diff
changeset
|
3097 /* Build the Send To menu */ |
11594 | 3098 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
3099 gtk_widget_show(win->menu.send_to); | |
4359 | 3100 |
3101 menu = gtk_menu_new(); | |
11581 | 3102 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 3103 win->menu.send_to, 2); |
3104 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 3105 |
3106 gtk_widget_show(menu); | |
3107 | |
11604 | 3108 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
3109 buds = gaim_find_buddies(gtkconv->active_conv->account, gtkconv->active_conv->name); | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3110 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3111 if (buds == NULL) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3112 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3113 /* The user isn't on the buddy list. */ |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3114 create_sendto_item(menu, sg, &group, NULL, gtkconv->active_conv->account, gtkconv->active_conv->name); |
11604 | 3115 } |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3116 else |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3117 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3118 GList *list = NULL, *iter; |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3119 for (l = buds; l != NULL; l = l->next) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3120 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3121 GaimBlistNode *node; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3122 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3123 node = (GaimBlistNode *) gaim_buddy_get_contact((GaimBuddy *)l->data); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3124 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3125 for (node = node->child; node != NULL; node = node->next) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3126 { |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
3127 GaimBuddy *buddy = (GaimBuddy *)node; |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3128 GaimAccount *account; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3129 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3130 if (!GAIM_BLIST_NODE_IS_BUDDY(node)) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3131 continue; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3132 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3133 account = gaim_buddy_get_account(buddy); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3134 if (gaim_account_is_connected(account)) |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3135 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3136 /* Use the GaimPresence to get unique buddies. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3137 GaimPresence *presence = gaim_buddy_get_presence(buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3138 if (!g_list_find(list, presence)) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3139 list = g_list_prepend(list, presence); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3140 } |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3141 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3142 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3143 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3144 /* Loop over the list backwards so we get the items in the right order, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3145 * since we did a g_list_prepend() earlier. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3146 for (iter = g_list_last(list); iter != NULL; iter = iter->prev) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3147 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3148 GaimPresence *pre = iter->data; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3149 GaimBuddy *buddy = gaim_presence_get_buddies(pre)->data; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3150 create_sendto_item(menu, sg, &group, buddy, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3151 gaim_buddy_get_account(buddy), gaim_buddy_get_name(buddy)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3152 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3153 g_list_free(list); |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3154 g_slist_free(buds); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3155 } |
4359 | 3156 } |
3157 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3158 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3159 |
11594 | 3160 gtk_widget_show(win->menu.send_to); |
12455 | 3161 /* TODO: This should never be insensitive. Possibly hidden or not. */ |
11594 | 3162 if (!group) |
3163 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
3164 update_send_to_selection(win); | |
4359 | 3165 } |
3166 | |
3167 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3168 generate_invite_user_names(GaimConnection *gc) |
4359 | 3169 { |
6695 | 3170 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 3171 static GList *tmp = NULL; |
3172 | |
3173 if (tmp) | |
3174 g_list_free(tmp); | |
3175 | |
3176 tmp = g_list_append(NULL, ""); | |
3177 | |
3178 if (gc != NULL) { | |
4785 | 3179 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
3180 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
3181 continue; | |
6695 | 3182 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3183 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 3184 continue; |
6695 | 3185 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
3186 GaimBuddy *buddy; | |
3187 | |
3188 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
3189 continue; | |
3190 | |
3191 buddy = (GaimBuddy *)bnode; | |
3192 | |
3193 if (buddy->account == gc->account && | |
3194 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 3195 tmp = g_list_insert_sorted(tmp, buddy->name, |
3196 (GCompareFunc)g_utf8_collate); | |
6695 | 3197 } |
4359 | 3198 } |
3199 } | |
3200 } | |
3201 | |
3202 return tmp; | |
3203 } | |
3204 | |
9498 | 3205 static GdkPixbuf * |
9554 | 3206 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 3207 { |
9554 | 3208 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 3209 char *filename; |
10274 | 3210 const char *image = NULL; |
9554 | 3211 |
3212 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 3213 image = "founder.png"; |
9554 | 3214 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 3215 image = "op.png"; |
9554 | 3216 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 3217 image = "halfop.png"; |
9554 | 3218 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 3219 image = "voice.png"; |
9554 | 3220 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 3221 image = "ignored.png"; |
3222 } else { | |
3223 return NULL; | |
9554 | 3224 } |
10274 | 3225 |
3226 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
3227 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
3228 g_free(filename); | |
3229 | |
3230 if (!pixbuf) | |
3231 return NULL; | |
3232 | |
3233 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
3234 g_object_unref(pixbuf); | |
3235 | |
3236 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
3237 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 3238 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
3239 g_free(filename); | |
10274 | 3240 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 3241 g_object_unref(pixbuf); |
10274 | 3242 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
3243 g_object_unref(scale2); | |
9498 | 3244 } |
3245 | |
10274 | 3246 return scale; |
9498 | 3247 } |
3248 | |
4359 | 3249 static void |
11869 | 3250 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 3251 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3252 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3253 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3254 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3255 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3256 GaimPluginProtocolInfo *prpl_info; |
4359 | 3257 GtkListStore *ls; |
9498 | 3258 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3259 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3260 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3261 gboolean is_buddy; |
4359 | 3262 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3263 chat = GAIM_CONV_CHAT(conv); |
4359 | 3264 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3265 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3266 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3267 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3268 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3269 return; |
4359 | 3270 |
3271 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3272 | |
9554 | 3273 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 3274 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3275 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
|
3276 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3277 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3278 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3279 |
4359 | 3280 gtk_list_store_append(ls, &iter); |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3281 |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3282 if (is_me) |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3283 { |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3284 GdkColor send_color; |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3285 gdk_color_parse(SEND_COLOR, &send_color); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3286 |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3287 gtk_list_store_set(ls, &iter, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3288 CHAT_USERS_ICON_COLUMN, pixbuf, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3289 CHAT_USERS_ALIAS_COLUMN, alias, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3290 CHAT_USERS_NAME_COLUMN, name, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3291 CHAT_USERS_FLAGS_COLUMN, flags, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3292 CHAT_USERS_COLOR_COLUMN, &send_color, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3293 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3294 -1); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3295 } |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3296 else |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3297 { |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3298 gtk_list_store_set(ls, &iter, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3299 CHAT_USERS_ICON_COLUMN, pixbuf, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3300 CHAT_USERS_ALIAS_COLUMN, alias, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3301 CHAT_USERS_NAME_COLUMN, name, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3302 CHAT_USERS_FLAGS_COLUMN, flags, |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
3303 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, name), |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3304 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3305 -1); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3306 } |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3307 |
9554 | 3308 if (pixbuf) |
3309 g_object_unref(pixbuf); | |
4359 | 3310 } |
3311 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3312 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3313 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
|
3314 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3315 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3316 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3317 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3318 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3319 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3320 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3321 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3322 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3323 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3324 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3325 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3326 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3327 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3328 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3329 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3330 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3331 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3332 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3333 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3334 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3335 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3336 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 (*most_matched)--; |
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 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3341 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3342 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3343 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3344 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3345 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3346 (GCompareFunc)gaim_utf8_strcasecmp); |
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 |
9605 | 3349 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3350 tab_complete(GaimConversation *conv) |
4359 | 3351 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3352 GaimGtkConversation *gtkconv; |
4359 | 3353 GtkTextIter cursor, word_start, start_buffer; |
3354 int start; | |
3355 int most_matched = -1; | |
3356 char *entered, *partial = NULL; | |
3357 char *text; | |
8021 | 3358 char *nick_partial; |
9605 | 3359 const char *prefix; |
4359 | 3360 GList *matches = NULL; |
9605 | 3361 gboolean command = FALSE; |
4359 | 3362 |
3363 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3364 | |
3365 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3366 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3367 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3368 | |
3369 word_start = cursor; | |
3370 | |
3371 /* if there's nothing there just return */ | |
3372 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3373 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
|
3374 |
4359 | 3375 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3376 &cursor, FALSE); | |
3377 | |
3378 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3379 start = strlen(text) - 1; | |
3380 | |
8021 | 3381 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3382 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3383 start-=2; |
3384 } | |
4359 | 3385 |
3386 /* find the start of the word that we're tabbing */ | |
3387 while (start >= 0 && text[start] != ' ') { | |
3388 gtk_text_iter_backward_char(&word_start); | |
3389 start--; | |
3390 } | |
3391 | |
9605 | 3392 prefix = gaim_gtk_get_cmd_prefix(); |
3393 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3394 command = TRUE; | |
3395 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3396 } | |
3397 | |
4359 | 3398 g_free(text); |
3399 | |
3400 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3401 &cursor, FALSE); | |
3402 | |
8021 | 3403 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3404 g_free(entered); |
11338 | 3405 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3406 } |
3407 | |
8021 | 3408 nick_partial = g_malloc(strlen(entered)+1); |
3409 | |
9605 | 3410 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3411 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3412 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3413 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3414 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3415 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3416 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3417 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3418 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3419 g_list_free(list); |
11338 | 3420 } 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
|
3421 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3422 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3423 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
|
3424 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3425 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3426 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3427 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3428 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3429 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3430 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3431 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3432 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3433 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3434 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3435 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
|
3436 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3437 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3438 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3439 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3440 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3441 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3442 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3443 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3444 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3445 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3446 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3447 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3448 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3449 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3450 g_free(alias); |
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 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3453 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3454 } |
9605 | 3455 } else { |
3456 g_free(nick_partial); | |
3457 g_free(entered); | |
3458 return FALSE; | |
3459 } | |
3460 | |
8021 | 3461 g_free(nick_partial); |
3462 | |
4359 | 3463 /* we're only here if we're doing new style */ |
3464 | |
3465 /* if there weren't any matches, return */ | |
3466 if (!matches) { | |
3467 /* if matches isn't set partials won't be either */ | |
3468 g_free(entered); | |
11338 | 3469 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3470 } |
3471 | |
3472 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3473 | |
3474 if (!matches->next) { | |
3475 /* there was only one match. fill it in. */ | |
3476 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3477 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3478 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3479 | |
3480 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3481 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3482 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3483 g_free(tmp); | |
3484 } | |
3485 else | |
3486 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3487 matches->data, -1); | |
3488 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3489 g_free(matches->data); |
4359 | 3490 matches = g_list_remove(matches, matches->data); |
3491 } | |
3492 else { | |
3493 /* | |
3494 * there were lots of matches, fill in as much as possible | |
3495 * and display all of them | |
3496 */ | |
3497 char *addthis = g_malloc0(1); | |
3498 | |
3499 while (matches) { | |
3500 char *tmp = addthis; | |
3501 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3502 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3503 g_free(matches->data); |
4359 | 3504 matches = g_list_remove(matches, matches->data); |
3505 } | |
3506 | |
6982 | 3507 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3508 time(NULL)); |
3509 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3510 g_free(addthis); | |
3511 } | |
3512 | |
3513 g_free(entered); | |
3514 g_free(partial); | |
9605 | 3515 |
3516 return TRUE; | |
4359 | 3517 } |
3518 | |
10810 | 3519 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3520 { |
3521 GaimPluginProtocolInfo *prpl_info = NULL; | |
3522 GaimConnection *gc; | |
10810 | 3523 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3524 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3525 char *new_topic; |
8858 | 3526 const char *current_topic; |
7971 | 3527 |
3528 gc = gaim_conversation_get_gc(conv); | |
3529 | |
3530 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3531 return; | |
3532 | |
3533 if(prpl_info->set_chat_topic == NULL) | |
3534 return; | |
3535 | |
3536 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3537 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3538 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3539 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3540 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3541 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3542 g_free(new_topic); |
7971 | 3543 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3544 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3545 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3546 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3547 |
8858 | 3548 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3549 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3550 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3551 g_free(new_topic); |
7971 | 3552 } |
3553 | |
9554 | 3554 static gint |
3555 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3556 { | |
3557 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3558 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3559 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3560 gint ret = 0; |
3561 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3562 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3563 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3564 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3565 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3566 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3567 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3568 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3569 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3570 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3571 -1); |
9554 | 3572 |
3573 if (user1 == NULL || user2 == NULL) { | |
3574 if (!(user1 == NULL && user2 == NULL)) | |
3575 ret = (user1 == NULL) ? -1: 1; | |
3576 } else if (f1 != f2) { | |
3577 /* sort more important users first */ | |
3578 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3579 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3580 ret = buddy1 ? -1 : 1; |
9554 | 3581 } else { |
10904 | 3582 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3583 } |
3584 | |
3585 g_free(user1); | |
3586 g_free(user2); | |
3587 | |
3588 return ret; | |
3589 } | |
3590 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3591 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3592 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
|
3593 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3594 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3595 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3596 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3597 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3598 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3599 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3600 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3601 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3602 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3603 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3604 /* 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
|
3605 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
|
3606 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3607 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
|
3608 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3609 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3610 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3611 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3612 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3613 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3614 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3615 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
|
3616 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3617 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3618 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3619 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3620 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3621 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3622 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3623 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3624 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3625 alias = gaim_buddy_get_contact_alias(buddy2); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3626 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3627 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3628 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3629 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3630 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3631 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3632 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3633 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3634 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3635 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3636 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3637 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3638 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3639 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3640 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3641 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3642 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3643 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3644 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
|
3645 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3646 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3647 GaimPluginProtocolInfo *prpl_info; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3648 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3649 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3650 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3651 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3652 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3653 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3654 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3655 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3656 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3657 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3658 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3659 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3660 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3661 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3662 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3663 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3664 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3665 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3666 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3667 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3668 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3669 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3670 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3671 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3672 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3673 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3674 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3675 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3676 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3677 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3678 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3679 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3680 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3681 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3682 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3683 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3684 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3685 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3686 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3687 /* 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
|
3688 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3689 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3690 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3691 /* 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
|
3692 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
|
3693 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3694 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
|
3695 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3696 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3697 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3698 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3699 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3700 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3701 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3702 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
|
3703 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3704 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3705 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
|
3706 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3707 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3708 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3709 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3710 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3711 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3712 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3713 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3714 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3715 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3716 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3717 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3718 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3719 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3720 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3721 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3722 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3723 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3724 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3725 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3726 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3727 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3728 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3729 /* 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
|
3730 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3731 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3732 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3733 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3734 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3735 |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3736 static void send_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3737 { |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3738 g_signal_emit_by_name(gtkconv->entry, "message_send"); |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3739 } |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3740 |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3741 static void |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3742 entry_popup_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3743 { |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3744 GtkWidget *menuitem; |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3745 GaimGtkConversation *gtkconv = data; |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3746 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3747 g_return_if_fail(menu != NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3748 g_return_if_fail(gtkconv != NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3749 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3750 menuitem = gaim_new_item_from_stock(NULL, _("_Send"), GAIM_STOCK_SEND, |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3751 G_CALLBACK(send_menu_cb), gtkconv, |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3752 0, 0, NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3753 if (gtk_text_buffer_get_char_count(imhtml->text_buffer) == 0) |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3754 gtk_widget_set_sensitive(menuitem, FALSE); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3755 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 0); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3756 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3757 menuitem = gtk_separator_menu_item_new(); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3758 gtk_widget_show(menuitem); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3759 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 1); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3760 } |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3761 |
4359 | 3762 static GtkWidget * |
10810 | 3763 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3764 { |
13419
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
3765 GaimPluginProtocolInfo *prpl_info; |
10810 | 3766 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3767 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3768 GaimConnection *gc; |
4359 | 3769 GtkWidget *vpaned, *hpaned; |
10175 | 3770 GtkWidget *vbox, *hbox, *frame; |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3771 GtkWidget *imhtml_sw; |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3772 GtkPolicyType imhtml_sw_hscroll; |
4359 | 3773 GtkWidget *lbox, *bbox; |
3774 GtkWidget *label; | |
3775 GtkWidget *list; | |
3776 GtkWidget *button; | |
7949 | 3777 GtkWidget *sw; |
4359 | 3778 GtkListStore *ls; |
3779 GtkCellRenderer *rend; | |
3780 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3781 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3782 GList *focus_chain = NULL; |
4359 | 3783 |
3784 gtkchat = gtkconv->u.chat; | |
3785 gc = gaim_conversation_get_gc(conv); | |
13419
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
3786 g_return_if_fail(gc != NULL); |
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
3787 g_return_if_fail(gc->prpl != NULL); |
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
3788 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
4359 | 3789 |
3790 /* Setup the outer pane. */ | |
3791 vpaned = gtk_vpaned_new(); | |
3792 gtk_widget_show(vpaned); | |
3793 | |
3794 /* Setup the top part of the pane. */ | |
11243 | 3795 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3796 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3797 gtk_widget_show(vbox); |
3798 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3799 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3800 { |
11243 | 3801 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3802 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3803 gtk_widget_show(hbox); |
3804 | |
3805 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3806 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3807 gtk_widget_show(label); |
3808 | |
3809 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3810 |
7971 | 3811 if(prpl_info->set_chat_topic == NULL) { |
3812 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3813 } else { | |
3814 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3815 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3816 } |
3817 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3818 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3819 gtk_widget_show(gtkchat->topic_text); |
3820 } | |
3821 | |
3822 /* Setup the horizontal pane. */ | |
3823 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3824 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3825 gtk_widget_show(hpaned); |
3826 | |
10175 | 3827 /* Setup gtkihmtml. */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3828 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL, &imhtml_sw); |
10175 | 3829 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); |
10389 | 3830 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3831 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3832 gtk_widget_show(frame); | |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3833 gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3834 &imhtml_sw_hscroll, NULL); |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3835 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3836 imhtml_sw_hscroll, GTK_POLICY_ALWAYS); |
10175 | 3837 |
3838 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3839 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3840 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3841 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3842 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3843 |
4359 | 3844 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3845 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3846 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3847 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3848 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3849 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3850 |
3851 /* Build the right pane. */ | |
11243 | 3852 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3853 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3854 gtk_widget_show(lbox); |
3855 | |
3856 /* Setup the label telling how many people are in the room. */ | |
3857 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3858 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3859 gtk_widget_show(gtkchat->count); | |
3860 | |
3861 /* Setup the list of users. */ | |
7949 | 3862 sw = gtk_scrolled_window_new(NULL, NULL); |
3863 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3864 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3865 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3866 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3867 gtk_widget_show(sw); | |
4359 | 3868 |
9554 | 3869 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
|
3870 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
|
3871 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3872 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3873 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3874 GTK_SORT_ASCENDING); |
3875 | |
3876 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3877 | |
9498 | 3878 rend = gtk_cell_renderer_pixbuf_new(); |
3879 | |
4359 | 3880 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3881 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3882 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3883 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3884 |
3885 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3886 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3887 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3888 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3889 |
9498 | 3890 rend = gtk_cell_renderer_text_new(); |
3891 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3892 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3893 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3894 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3895 NULL); |
4359 | 3896 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3897 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3898 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3899 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3900 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3901 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3902 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3903 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3904 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3905 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3906 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3907 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3908 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3909 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3910 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3911 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3912 #endif |
4359 | 3913 |
3914 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3915 | |
3916 gtk_widget_set_size_request(list, 150, -1); | |
3917 | |
3918 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3919 gtk_widget_show(list); | |
3920 | |
3921 gtkchat->list = list; | |
3922 | |
7949 | 3923 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3924 |
3925 /* Setup the user list toolbar. */ | |
11243 | 3926 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3927 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3928 gtk_widget_show(bbox); | |
3929 | |
3930 /* IM */ | |
10221 | 3931 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3932 GAIM_BUTTON_VERTICAL); |
10500 | 3933 gtkchat->userlist_im = button; |
4359 | 3934 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3935 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
|
3936 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3937 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3938 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3939 |
3940 gtk_widget_show(button); | |
3941 | |
3942 /* Ignore */ | |
3943 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3944 GAIM_BUTTON_VERTICAL); | |
10500 | 3945 gtkchat->userlist_ignore = button; |
4359 | 3946 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3947 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
|
3948 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3949 _("Ignore the user"), NULL); |
4359 | 3950 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3951 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3952 gtk_widget_show(button); |
3953 | |
3954 /* Info */ | |
3955 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3956 GAIM_BUTTON_VERTICAL); | |
10500 | 3957 gtkchat->userlist_info = button; |
4359 | 3958 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3959 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3960 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3961 _("Get the user's information"), NULL); |
4359 | 3962 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3963 G_CALLBACK(info_cb), gtkconv); |
4359 | 3964 |
3965 gtk_widget_show(button); | |
3966 | |
10175 | 3967 /* Setup the bottom half of the conversation window */ |
11243 | 3968 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3969 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3970 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3971 |
11243 | 3972 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3973 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3974 gtk_widget_show(gtkconv->lower_hbox); | |
3975 | |
11243 | 3976 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3977 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3978 gtk_widget_show(vbox); | |
3979 | |
10175 | 3980 /* Setup the toolbar, entry widget and all signals */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3981 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar, NULL); |
10080 | 3982 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3983 gtk_widget_show(frame); |
3984 | |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3985 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3986 G_CALLBACK(entry_popup_menu_cb), gtkconv); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3987 |
9005 | 3988 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3989 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3990 gaim_account_get_protocol_name(conv->account)); |
10175 | 3991 gtk_widget_set_size_request(gtkconv->entry, -1, |
3992 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3993 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3994 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3995 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3996 |
3997 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3998 G_CALLBACK(entry_key_press_cb), gtkconv); |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3999 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4000 G_CALLBACK(send_cb), gtkconv); |
4359 | 4001 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 4002 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 4003 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 4004 G_CALLBACK(size_allocate_cb), gtkconv); |
4005 | |
4006 default_formatize(gtkconv); | |
4359 | 4007 |
9080 | 4008 /* |
4009 * Focus for chat windows should be as follows: | |
4010 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
4011 * user list buttons -> entry -> buttons at bottom | |
4012 */ | |
9332 | 4013 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4014 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
4015 | |
4359 | 4016 return vpaned; |
4017 } | |
4018 | |
4019 static GtkWidget * | |
10810 | 4020 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 4021 { |
10810 | 4022 GaimConversation *conv = gtkconv->active_conv; |
10175 | 4023 GtkWidget *frame; |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4024 GtkWidget *imhtml_sw; |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4025 GtkPolicyType imhtml_sw_hscroll; |
4359 | 4026 GtkWidget *paned; |
10175 | 4027 GtkWidget *vbox; |
4028 GtkWidget *vbox2; | |
9080 | 4029 GList *focus_chain = NULL; |
4359 | 4030 |
10175 | 4031 /* Setup the outer pane */ |
4359 | 4032 paned = gtk_vpaned_new(); |
4033 gtk_widget_show(paned); | |
4034 | |
10175 | 4035 /* Setup the top part of the pane */ |
11243 | 4036 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
4037 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 4038 gtk_widget_show(vbox); |
4039 | |
10175 | 4040 /* Setup the gtkimhtml widget */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4041 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL, &imhtml_sw); |
10175 | 4042 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); |
10389 | 4043 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 4044 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
4045 gtk_widget_show(frame); | |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4046 gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4047 &imhtml_sw_hscroll, NULL); |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4048 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4049 imhtml_sw_hscroll, GTK_POLICY_ALWAYS); |
10175 | 4050 |
4051 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4052 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4053 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 4054 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 4055 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 4056 |
4057 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 4058 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 4059 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 4060 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 4061 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 4062 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 4063 |
10175 | 4064 /* Setup the bottom half of the conversation window */ |
11243 | 4065 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 4066 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4067 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4068 |
11243 | 4069 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 4070 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
4071 gtk_widget_show(gtkconv->lower_hbox); | |
4072 | |
11243 | 4073 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 4074 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
4075 gtk_widget_show(vbox2); | |
8821 | 4076 |
10175 | 4077 /* Setup the toolbar, entry widget and all signals */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4078 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar, NULL); |
10080 | 4079 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 4080 gtk_widget_show(frame); |
4081 | |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4082 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4083 G_CALLBACK(entry_popup_menu_cb), gtkconv); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4084 |
9005 | 4085 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 4086 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 4087 gaim_account_get_protocol_name(conv->account)); |
10175 | 4088 gtk_widget_set_size_request(gtkconv->entry, -1, |
4089 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4090 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4091 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 4092 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
|
4093 |
4359 | 4094 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 4095 G_CALLBACK(entry_key_press_cb), gtkconv); |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4096 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4097 G_CALLBACK(send_cb), gtkconv); |
4359 | 4098 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 4099 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 4100 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 4101 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 4102 |
4103 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 4104 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 4105 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 4106 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 4107 |
8481 | 4108 /* had to move this after the imtoolbar is attached so that the |
4109 * signals get fired to toggle the buttons on the toolbar as well. | |
4110 */ | |
10810 | 4111 default_formatize(gtkconv); |
4359 | 4112 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4113 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4114 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4115 |
8758 | 4116 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 4117 gtkconv->u.im->show_icon = TRUE; |
4359 | 4118 |
9080 | 4119 /* |
4120 * Focus for IM windows should be as follows: | |
10356 | 4121 * Tab title -> conversation scrollback -> entry |
9080 | 4122 */ |
9332 | 4123 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4124 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 4125 |
4359 | 4126 return paned; |
4127 } | |
4128 | |
4129 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4130 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 4131 GtkSelectionData *sd, guint info, guint t, |
4132 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4133 { |
10810 | 4134 GaimConversation *conv = gtkconv->active_conv; |
11581 | 4135 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4136 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4137 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4138 { |
4781 | 4139 GaimBlistNode *n = NULL; |
6695 | 4140 GaimBuddy *b; |
11581 | 4141 GaimGtkConversation *gtkconv = NULL; |
9622 | 4142 |
11812 | 4143 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4144 |
6695 | 4145 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
4146 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
4147 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
4148 b = (GaimBuddy*)n; | |
4149 else | |
4781 | 4150 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4151 |
9622 | 4152 /* |
4153 * If we already have an open conversation with this buddy, then | |
4154 * just move the conv to this window. Otherwise, create a new | |
4155 * conv and add it to this window. | |
4156 */ | |
11338 | 4157 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 4158 if (c != NULL) { |
11581 | 4159 GaimGtkWindow *oldwin; |
4160 gtkconv = GAIM_GTK_CONVERSATION(c); | |
4161 oldwin = gtkconv->win; | |
9622 | 4162 if (oldwin != win) { |
11581 | 4163 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
4164 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 4165 } |
4166 } else { | |
11338 | 4167 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 4168 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 4169 if (gtkconv->win != win) |
4170 { | |
4171 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
4172 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
4173 } | |
9622 | 4174 } |
4175 | |
4176 /* Make this conversation the active conversation */ | |
11581 | 4177 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4178 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4179 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 4180 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4181 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
|
4182 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4183 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4184 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4185 GaimAccount *account; |
11581 | 4186 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4187 |
11137 | 4188 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 4189 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4190 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4191 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4192 { |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
4193 gaim_notify_error(win, NULL, |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4194 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4195 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4196 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4197 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4198 { |
11338 | 4199 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 4200 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 4201 if (gtkconv->win != win) |
4202 { | |
4203 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
4204 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
4205 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4206 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4207 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4208 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4209 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4210 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4211 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4212 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4213 } |
9525 | 4214 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 4215 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 4216 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 4217 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 4218 } |
10145 | 4219 else |
4220 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4221 } |
4359 | 4222 |
4223 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4224 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4225 { |
10145 | 4226 GTK_IMHTML_DND_TARGETS, |
4227 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
4228 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4229 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4230 |
10810 | 4231 static GaimGtkConversation * |
4232 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
4233 { | |
4234 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
4235 GaimContact *c; | |
4236 GaimBlistNode *cn; | |
10935 | 4237 |
10810 | 4238 if (!bud) |
4239 return NULL; | |
10935 | 4240 |
10810 | 4241 if (!(c = gaim_buddy_get_contact(bud))) |
4242 return NULL; | |
10935 | 4243 |
10810 | 4244 cn = (GaimBlistNode *)c; |
4245 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
4246 GaimConversation *conv; | |
11338 | 4247 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 4248 if (conv->ui_data) |
4249 return conv->ui_data; | |
4250 } | |
4251 } | |
10935 | 4252 |
10810 | 4253 return NULL; |
4254 } | |
4255 | |
11855 | 4256 static void |
4257 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
4258 { | |
4259 GList *list; | |
4260 | |
4261 g_return_if_fail(bnode); | |
4262 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
4263 | |
4264 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
4265 { | |
4266 GaimGtkWindow *win = list->data; | |
4267 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4268 | |
4269 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
4270 continue; | |
4271 | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
4272 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_MENU); |
11855 | 4273 } |
4274 } | |
4275 | |
11581 | 4276 /************************************************************************** |
4277 * Conversation UI operations | |
4278 **************************************************************************/ | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4279 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4280 private_gtkconv_new(GaimConversation *conv, gboolean hidden) |
11581 | 4281 { |
4282 GaimGtkConversation *gtkconv; | |
4283 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 4284 GtkWidget *pane = NULL; |
4285 GtkWidget *tab_cont; | |
11581 | 4286 |
4287 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 4288 conv->ui_data = gtkconv; |
4289 if (!g_list_find(gtkconv->convs, conv)) | |
4290 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 4291 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 4292 return; |
4359 | 4293 } |
4294 | |
11581 | 4295 gtkconv = g_new0(GaimGtkConversation, 1); |
4296 conv->ui_data = gtkconv; | |
4297 gtkconv->active_conv = conv; | |
4298 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
4299 | |
4300 /* Setup some initial variables. */ | |
4301 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
4302 gtkconv->tooltips = gtk_tooltips_new(); | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4303 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4304 gtkconv->unseen_count = 0; |
11581 | 4305 |
4306 if (conv_type == GAIM_CONV_TYPE_IM) { | |
4307 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
4308 | |
4309 pane = setup_im_pane(gtkconv); | |
4310 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
4311 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
4312 pane = setup_chat_pane(gtkconv); | |
4313 } | |
4314 | |
12101 | 4315 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
4316 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
4317 | |
11581 | 4318 if (pane == NULL) { |
4319 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
4320 g_free(gtkconv->u.chat); | |
4321 else if (conv_type == GAIM_CONV_TYPE_IM) | |
4322 g_free(gtkconv->u.im); | |
4323 | |
4324 g_free(gtkconv); | |
4325 conv->ui_data = NULL; | |
4326 return; | |
10449 | 4327 } |
11581 | 4328 |
4329 /* Setup drag-and-drop */ | |
4330 gtk_drag_dest_set(pane, | |
4331 GTK_DEST_DEFAULT_MOTION | | |
4332 GTK_DEST_DEFAULT_DROP, | |
4333 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4334 GDK_ACTION_COPY); | |
4335 gtk_drag_dest_set(pane, | |
4336 GTK_DEST_DEFAULT_MOTION | | |
4337 GTK_DEST_DEFAULT_DROP, | |
4338 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4339 GDK_ACTION_COPY); | |
4340 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4341 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4342 GDK_ACTION_COPY); | |
4343 | |
4344 gtk_drag_dest_set(gtkconv->entry, 0, | |
4345 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4346 GDK_ACTION_COPY); | |
4347 | |
4348 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
4349 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4350 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
4351 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4352 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
4353 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4354 | |
4355 /* Setup the container for the tab. */ | |
4356 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
4357 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
4358 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
4359 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
4360 gtk_widget_show(pane); | |
4361 | |
4362 gtkconv->make_sound = TRUE; | |
4363 | |
4364 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
4365 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4366 else |
11581 | 4367 gtk_widget_hide(gtkconv->toolbar); |
4368 | |
12188 | 4369 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), |
4370 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4371 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4372 gaim_account_get_protocol_name(conv->account)); |
11581 | 4373 |
4374 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
4375 G_CALLBACK(gtk_widget_grab_focus), | |
4376 gtkconv->entry); | |
4377 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4378 if (hidden) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4379 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4380 else |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4381 gaim_gtkconv_placement_place(gtkconv); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
4382 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4383 if (nick_colors == NULL) { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4384 nbr_nick_colors = NUM_NICK_COLORS; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4385 nick_colors = generate_nick_colors(&nbr_nick_colors, gtk_widget_get_style(gtkconv->imhtml)->base[GTK_STATE_NORMAL]); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4386 } |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4387 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4388 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4389 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4390 gaim_gtkconv_new_hidden(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4391 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4392 private_gtkconv_new(conv, TRUE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4393 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4394 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4395 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4396 gaim_gtkconv_new(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4397 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4398 private_gtkconv_new(conv, FALSE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4399 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4400 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4401 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4402 received_im_msg_cb(GaimAccount *account, char *sender, char *message, |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4403 GaimConversation *conv, int flags) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4404 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4405 GaimConversationUiOps *ui_ops = gaim_gtk_conversations_get_conv_ui_ops(); |
12719
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4406 if (conv != NULL) |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4407 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4408 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4409 /* create hidden conv if hide_new pref is always */ |
12719
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4410 if (strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "always") == 0) |
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4411 { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4412 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4413 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4414 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4415 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4416 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4417 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4418 /* create hidden conv if hide_new pref is away and account is away */ |
12719
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4419 if (strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away") == 0 && |
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4420 !gaim_status_is_available(gaim_account_get_active_status(account))) |
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4421 { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4422 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4423 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4424 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4425 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4426 } |
11581 | 4427 } |
4428 | |
4359 | 4429 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4430 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4431 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4432 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4433 |
10810 | 4434 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4435 /* Don't destroy ourselves until all our convos are gone */ | |
4436 if (gtkconv->convs) | |
4437 return; | |
11508 | 4438 |
11581 | 4439 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4440 | |
9504 | 4441 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
4442 gaim_request_close_with_handle(gtkconv); |
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
4443 gaim_notify_close_with_handle(gtkconv); |
4359 | 4444 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4445 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4446 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4447 |
11338 | 4448 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4449 if (gtkconv->u.im->icon_timer != 0) |
4450 g_source_remove(gtkconv->u.im->icon_timer); | |
4451 | |
4359 | 4452 if (gtkconv->u.im->anim != NULL) |
4793 | 4453 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4454 |
4455 g_free(gtkconv->u.im); | |
11581 | 4456 } 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
|
4457 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4458 g_free(gtkconv->u.chat); |
4459 } | |
4460 | |
4633 | 4461 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4462 | |
4359 | 4463 g_free(gtkconv); |
4464 } | |
4465 | |
4466 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4467 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4468 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4469 time_t mtime) |
4359 | 4470 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4471 GaimGtkConversation *gtkconv; |
4359 | 4472 |
4473 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4474 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4475 |
6982 | 4476 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4477 } |
4478 | |
4479 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4480 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4481 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4482 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4483 GaimGtkConversation *gtkconv; |
4359 | 4484 |
4485 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4486 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4487 |
10398 | 4488 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4489 |
6982 | 4490 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4491 } |
4492 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4493 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4494 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4495 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4496 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4497 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4498 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4499 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4500 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4501 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4502 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4503 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4504 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4505 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4506 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4507 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4508 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4509 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4510 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4511 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4512 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4513 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4514 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4515 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4516 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4517 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4518 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4519 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4520 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4521 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4522 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4523 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4524 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4525 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4526 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4527 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4528 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4529 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4530 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4531 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4532 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4533 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4534 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4535 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4536 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4537 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4538 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4539 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4540 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4541 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4542 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4543 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4544 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4545 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4546 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4547 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4548 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4549 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4550 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4551 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4552 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4553 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4554 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4555 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4556 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4557 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4558 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4559 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4560 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4561 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4562 buddytag = gtk_text_buffer_create_tag( |
11096 | 4563 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4564 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4565 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4566 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4567 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4568 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4569 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4570 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4571 |
4359 | 4572 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4573 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4574 const char *message, GaimMessageFlags flags, |
4359 | 4575 time_t mtime) |
4576 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4577 GaimGtkConversation *gtkconv; |
11581 | 4578 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4579 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4580 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4581 GaimPluginProtocolInfo *prpl_info; |
4359 | 4582 int gtk_font_options = 0; |
12553 | 4583 int gtk_font_options_all = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4584 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4585 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4586 int line_count; |
4359 | 4587 char buf2[BUF_LONG]; |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4588 char *mdate; |
4359 | 4589 char color[10]; |
4590 char *str; | |
4591 char *with_font_tag; | |
4896 | 4592 char *sml_attrib = NULL; |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4593 size_t length; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4594 GaimConversationType type; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4595 char *displaying; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4596 gboolean plugin_return; |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4597 struct tm tm = *(localtime(&mtime)); |
4895 | 4598 |
4359 | 4599 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4600 |
12553 | 4601 if(gaim_prefs_get_bool("/gaim/gtk/conversations/use_smooth_scrolling")) |
4602 gtk_font_options_all |= GTK_IMHTML_USE_SMOOTHSCROLLING; | |
4603 | |
11581 | 4604 /* Set the active conversation to the one that just messaged us. */ |
4605 /* TODO: consider not doing this if the account is offline or something */ | |
13352
475214c22abf
[gaim-migrate @ 15724]
Richard Laager <rlaager@wiktel.com>
parents:
13350
diff
changeset
|
4606 if (flags & (GAIM_MESSAGE_SEND | GAIM_MESSAGE_RECV)) |
475214c22abf
[gaim-migrate @ 15724]
Richard Laager <rlaager@wiktel.com>
parents:
13350
diff
changeset
|
4607 gaim_gtkconv_set_active_conversation(conv); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4608 type = gaim_conversation_get_type(conv); |
11581 | 4609 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4610 account = gaim_conversation_get_account(conv); |
13419
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
4611 g_return_if_fail(account != NULL); |
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
4612 gc = gaim_account_get_connection(account); |
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
4613 g_return_if_fail(gc != NULL); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4614 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4615 displaying = g_strdup(message); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4616 plugin_return = GPOINTER_TO_INT(gaim_signal_emit_return_1( |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4617 gaim_gtk_conversations_get_handle(), (type == GAIM_CONV_TYPE_IM ? |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4618 "displaying-im-msg" : "displaying-chat-msg"), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
4619 account, name, &displaying, conv, flags)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4620 if (plugin_return) |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4621 { |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4622 g_free(displaying); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4623 return; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4624 } |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4625 message = displaying; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4626 length = strlen(message) + 1; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4627 |
11581 | 4628 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4629 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4630 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4631 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4632 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4633 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4634 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4635 /* 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
|
4636 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4637 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4638 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4639 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4640 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4641 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4642 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4643 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4644 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4645 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4646 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4647 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4648 |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4649 if (type == GAIM_CONV_TYPE_CHAT) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4650 { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4651 /* Create anchor for user */ |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4652 GtkTextIter iter; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4653 char *tmp = g_strconcat("user:", name, NULL); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4654 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4655 gtk_text_buffer_get_end_iter(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)), &iter); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4656 gtk_text_buffer_create_mark(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)), |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4657 tmp, &iter, TRUE); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4658 g_free(tmp); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4659 } |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4660 |
8677 | 4661 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
12553 | 4662 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", gtk_font_options_all); |
8677 | 4663 |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4664 mdate = gaim_signal_emit_return_1(gaim_gtk_conversations_get_handle(), |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4665 "conversation-timestamp", |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4666 conv, &tm); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4667 if (mdate == NULL) |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4668 { |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4669 if (time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
4670 mdate = g_strdup(gaim_date_format_long(&tm)); |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4671 else |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
4672 mdate = g_strdup(gaim_time_format(&tm)); |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4673 } |
4359 | 4674 |
13416
7d1ebac854ba
[gaim-migrate @ 15791]
Richard Laager <rlaager@wiktel.com>
parents:
13405
diff
changeset
|
4675 sml_attrib = g_strdup_printf("sml=\"%s\"", |
7d1ebac854ba
[gaim-migrate @ 15791]
Richard Laager <rlaager@wiktel.com>
parents:
13405
diff
changeset
|
4676 gaim_account_get_protocol_name(account)); |
7440 | 4677 |
10503 | 4678 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4679 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4680 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4681 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4682 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4683 |
7956 | 4684 /* this is gonna crash one day, I can feel it. */ |
4685 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4686 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4687 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4688 } |
4359 | 4689 |
12553 | 4690 |
10737 | 4691 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4692 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4693 g_snprintf(buf2, sizeof(buf2), |
8690 | 4694 "<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
|
4695 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4696 |
12553 | 4697 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
7440 | 4698 |
8722 | 4699 } else if (flags & GAIM_MESSAGE_ERROR) { |
4700 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4701 "<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
|
4702 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4703 |
12553 | 4704 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
8962 | 4705 |
7431 | 4706 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4707 g_snprintf(buf2, BUF_LONG, |
8690 | 4708 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4709 sml_attrib ? sml_attrib : "", message); |
7440 | 4710 |
12553 | 4711 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
10346 | 4712 } else if (flags & GAIM_MESSAGE_RAW) { |
12553 | 4713 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, gtk_font_options_all); |
10346 | 4714 } else { |
4895 | 4715 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4716 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
|
4717 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4718 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4719 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
|
4720 int tag_end_offset = 0; |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4721 GtkSmileyTree *tree = NULL; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4722 GHashTable *smiley_data = NULL; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4723 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4724 if (flags & GAIM_MESSAGE_SEND) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4725 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4726 /* Temporarily revert to the original smiley-data to avoid showing up |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4727 * custom smileys of the buddy when sending message |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4728 */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4729 tree = GTK_IMHTML(gtkconv->imhtml)->default_smilies; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4730 GTK_IMHTML(gtkconv->imhtml)->default_smilies = |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4731 GTK_IMHTML(gtkconv->entry)->default_smilies; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4732 smiley_data = GTK_IMHTML(gtkconv->imhtml)->smiley_data; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4733 GTK_IMHTML(gtkconv->imhtml)->smiley_data = GTK_IMHTML(gtkconv->entry)->smiley_data; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4734 } |
7440 | 4735 |
6621 | 4736 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4737 str = g_malloc(1024); |
7440 | 4738 |
4359 | 4739 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4740 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4741 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4742 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4743 tag_start_offset += 3; |
4359 | 4744 } |
4745 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4746 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4747 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4748 tag_end_offset = 2; |
4359 | 4749 strcpy(color, "#00FF00"); |
4750 } | |
7440 | 4751 } |
4359 | 4752 else { |
10504 | 4753 if (gaim_message_meify(new_message, -1)) { |
4359 | 4754 str = g_malloc(1024); |
7440 | 4755 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4756 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4757 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
|
4758 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4759 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4760 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4761 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4762 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4763 } |
7440 | 4764 |
6621 | 4765 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4766 strcpy(color, HIGHLIGHT_COLOR); |
4359 | 4767 else |
4768 strcpy(color, "#062585"); | |
4769 } | |
4770 else { | |
4771 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4772 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4773 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
|
4774 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4775 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4776 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4777 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4778 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4779 } |
6621 | 4780 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4781 strcpy(color, HIGHLIGHT_COLOR); |
6621 | 4782 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4783 if (flags & GAIM_MESSAGE_COLORIZE) { |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
4784 GdkColor *col = get_nick_color(gtkconv, name); |
10346 | 4785 |
10108 | 4786 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4787 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4788 } else |
7854 | 4789 strcpy(color, RECV_COLOR); |
4359 | 4790 } |
6621 | 4791 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4792 strcpy(color, SEND_COLOR); |
10892 | 4793 else { |
4794 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4795 strcpy(color, "#000000"); | |
4796 } | |
4359 | 4797 } |
4798 } | |
10892 | 4799 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4800 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4801 g_free(alias_escaped); |
11508 | 4802 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4803 /* 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
|
4804 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4805 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4806 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4807 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4808 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4809 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4810 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4811 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4812 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4813 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4814 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4815 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4816 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4817 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4818 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4819 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4820 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4821 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4822 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4823 /* 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
|
4824 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4825 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4826 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4827 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4828 } |
7440 | 4829 |
12553 | 4830 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4831 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4832 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4833 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4834 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4835 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4836 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4837 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4838 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4839 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4840 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4841 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4842 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4843 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4844 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4845 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4846 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4847 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4848 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4849 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4850 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4851 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4852 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4853 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4854 |
4359 | 4855 g_free(str); |
4856 | |
4895 | 4857 if(gc){ |
4896 | 4858 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4859 char *post = "</font>"; |
4860 int pre_len = strlen(pre); | |
4861 int post_len = strlen(post); | |
7440 | 4862 |
4895 | 4863 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4864 |
4895 | 4865 strcpy(with_font_tag, pre); |
4866 memcpy(with_font_tag + pre_len, new_message, length); | |
4867 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4868 |
4895 | 4869 length += pre_len + post_len; |
4870 g_free(pre); | |
4871 } | |
4608 | 4872 else |
4895 | 4873 with_font_tag = g_memdup(new_message, length); |
7440 | 4874 |
8962 | 4875 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
12553 | 4876 with_font_tag, gtk_font_options | gtk_font_options_all); |
7440 | 4877 |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4878 if (flags & GAIM_MESSAGE_SEND) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4879 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4880 /* Restore the smiley-data */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4881 GTK_IMHTML(gtkconv->imhtml)->default_smilies = tree; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4882 GTK_IMHTML(gtkconv->imhtml)->smiley_data = smiley_data; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4883 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4884 |
7440 | 4885 g_free(with_font_tag); |
7447 | 4886 g_free(new_message); |
7440 | 4887 } |
4888 | |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4889 g_free(mdate); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4890 g_free(sml_attrib); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4891 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4892 /* Tab highlighting stuff */ |
13138
277c7a62650b
[gaim-migrate @ 15500]
Richard Laager <rlaager@wiktel.com>
parents:
13131
diff
changeset
|
4893 if (!(flags & GAIM_MESSAGE_SEND) && !gaim_gtkconv_has_focus(conv)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4894 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4895 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4896 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4897 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4898 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4899 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4900 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4901 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4902 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
|
4903 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4904 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4905 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4906 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4907 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4908 } |
12902
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4909 |
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4910 gaim_signal_emit(gaim_gtk_conversations_get_handle(), |
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4911 (type == GAIM_CONV_TYPE_IM ? "displayed-im-msg" : "displayed-chat-msg"), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
4912 account, name, message, conv, flags); |
12902
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4913 g_free(displaying); |
4359 | 4914 } |
4915 | |
4916 static void | |
12463
b1717befbb26
[gaim-migrate @ 14773]
Richard Laager <rlaager@wiktel.com>
parents:
12455
diff
changeset
|
4917 gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users, GList *flags, GList *aliases, gboolean new_arrivals) |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4918 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4919 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4920 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4921 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4922 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4923 GList *ll; |
11869 | 4924 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4925 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4926 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4927 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4928 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4929 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4930 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4931 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4932 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
|
4933 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4934 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4935 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4936 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4937 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4938 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4939 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4940 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4941 l = users; |
11869 | 4942 ll = flags; |
4943 lll = aliases; | |
4944 while (l != NULL && ll != NULL && lll != NULL) { | |
4945 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
|
4946 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4947 ll = ll->next; |
11869 | 4948 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4949 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4950 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4951 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4952 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4953 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
|
4954 const char *new_name, const char *new_alias) |
4359 | 4955 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4956 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4957 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4958 GaimGtkChatPane *gtkchat; |
11869 | 4959 GaimConvChatBuddyFlags flags; |
4359 | 4960 GtkTreeIter iter; |
4961 GtkTreeModel *model; | |
4962 int f = 1; | |
4963 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4964 chat = GAIM_CONV_CHAT(conv); |
4359 | 4965 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4966 gtkchat = gtkconv->u.chat; | |
4967 | |
9554 | 4968 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4969 | |
4970 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4971 return; | |
4972 | |
4973 while (f != 0) { | |
4974 char *val; | |
4975 | |
11869 | 4976 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4977 |
4978 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4979 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4980 g_free(val); | |
4359 | 4981 break; |
4982 } | |
9554 | 4983 |
4984 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4985 | |
4986 g_free(val); | |
4359 | 4987 } |
4988 | |
9554 | 4989 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4990 return; |
4991 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4992 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4993 |
11869 | 4994 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4995 } |
4996 | |
4997 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4998 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4999 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5000 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5001 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5002 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5003 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5004 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5005 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5006 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5007 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5008 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5009 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5010 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5011 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5012 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5013 |
12982 | 5014 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
|
5015 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5016 for (l = users; l != NULL; l = l->next) { |
9554 | 5017 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5018 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
5019 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 5020 continue; |
5021 | |
5022 do { | |
5023 char *val; | |
5024 | |
5025 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
5026 CHAT_USERS_NAME_COLUMN, &val, -1); | |
5027 | |
9696 | 5028 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
5029 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 5030 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 5031 #else |
5032 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5033 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5034 #endif | |
5035 } | |
9554 | 5036 else |
5037 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5038 | |
5039 g_free(val); | |
5040 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5041 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5042 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5043 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5044 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5045 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5046 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5047 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5048 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5049 |
9554 | 5050 static void |
5051 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
5052 { | |
5053 GaimConvChat *chat; | |
11869 | 5054 GaimConvChatBuddyFlags flags; |
9554 | 5055 GaimGtkConversation *gtkconv; |
5056 GaimGtkChatPane *gtkchat; | |
5057 GtkTreeIter iter; | |
5058 GtkTreeModel *model; | |
5059 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5060 char *alias = NULL; |
9554 | 5061 |
5062 chat = GAIM_CONV_CHAT(conv); | |
5063 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5064 gtkchat = gtkconv->u.chat; | |
5065 | |
5066 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
5067 | |
5068 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5069 return; | |
5070 | |
5071 while (f != 0) { | |
5072 char *val; | |
5073 | |
5074 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5075 | |
5076 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
5077 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 5078 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
5079 g_free(val); | |
5080 break; | |
5081 } | |
5082 | |
5083 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5084 | |
5085 g_free(val); | |
5086 } | |
5087 | |
5088 if (!gaim_conv_chat_find_user(chat, user)) | |
12982 | 5089 { |
5090 g_free(alias); | |
9554 | 5091 return; |
12982 | 5092 } |
9554 | 5093 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5094 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5095 |
11869 | 5096 flags = gaim_conv_chat_user_get_flags(chat, user); |
5097 | |
5098 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5099 g_free(alias); |
9554 | 5100 } |
5101 | |
11581 | 5102 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5103 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5104 { |
11581 | 5105 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
5106 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5107 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5108 |
11581 | 5109 win = gtkconv->win; |
5110 | |
5111 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
|
5112 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5113 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5114 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5115 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
5116 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5117 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5118 |
12335 | 5119 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data) |
5120 { | |
5121 GtkIMHtmlSmiley *smiley; | |
12682 | 5122 |
12335 | 5123 smiley = (GtkIMHtmlSmiley *)user_data; |
5124 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
12682 | 5125 |
12335 | 5126 if (smiley->icon) |
5127 g_object_ref(G_OBJECT(smiley->icon)); | |
12682 | 5128 #ifdef DEBUG_CUSTOM_SMILEY |
5129 gaim_debug_info("custom-smiley", "gaim_gtkconv_custom_smiley_allocated(): got GdkPixbufAnimation %p for smiley '%s'\n", smiley->icon, smiley->smile); | |
12335 | 5130 #endif |
5131 } | |
5132 | |
5133 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data) | |
5134 { | |
5135 GtkIMHtmlSmiley *smiley; | |
5136 GtkWidget *icon = NULL; | |
5137 GtkTextChildAnchor *anchor = NULL; | |
5138 GSList *current = NULL; | |
12682 | 5139 |
12335 | 5140 smiley = (GtkIMHtmlSmiley *)user_data; |
5141 if (!smiley->imhtml) { | |
5142 #ifdef DEBUG_CUSTOM_SMILEY | |
12682 | 5143 gaim_debug_error("custom-smiley", "gaim_gtkconv_custom_smiley_closed(): orphan smiley found: %p\n", smiley); |
12335 | 5144 #endif |
5145 g_object_unref(G_OBJECT(loader)); | |
5146 smiley->loader = NULL; | |
5147 return; | |
5148 } | |
5149 | |
5150 for (current = smiley->anchors; current; current = g_slist_next(current)) { | |
5151 | |
5152 icon = gtk_image_new_from_animation(smiley->icon); | |
5153 | |
12682 | 5154 #ifdef DEBUG_CUSTOM_SMILEY |
5155 gaim_debug_info("custom-smiley", "gaim_gtkconv_custom_smiley_closed(): got GtkImage %p from GtkPixbufAnimation %p for smiley '%s'\n", | |
5156 icon, smiley->icon, smiley->smile); | |
12335 | 5157 #endif |
5158 if (icon) { | |
5159 gtk_widget_show(icon); | |
12682 | 5160 |
12335 | 5161 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
5162 | |
5163 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smiley->smile)), g_free); | |
5164 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley->smile), g_free); | |
12682 | 5165 |
12335 | 5166 if (smiley->imhtml) |
5167 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(smiley->imhtml), icon, anchor); | |
5168 } | |
5169 | |
5170 } | |
5171 | |
5172 g_slist_free(smiley->anchors); | |
5173 smiley->anchors = NULL; | |
12682 | 5174 |
12335 | 5175 g_object_unref(G_OBJECT(loader)); |
5176 smiley->loader = NULL; | |
5177 } | |
5178 | |
10526 | 5179 static gboolean |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5180 add_custom_smiley_for_imhtml(GtkIMHtml *imhtml, const char *sml, const char *smile) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5181 { |
10526 | 5182 GtkIMHtmlSmiley *smiley; |
5183 GdkPixbufLoader *loader; | |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5184 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5185 smiley = gtk_imhtml_smiley_get(imhtml, sml, smile); |
10526 | 5186 |
5187 if (smiley) { | |
11525 | 5188 |
5189 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
5190 return FALSE; | |
5191 } | |
5192 | |
5193 /* Close the old GdkPixbufAnimation, then create a new one for | |
5194 * the smiley we are about to receive */ | |
5195 g_object_unref(G_OBJECT(smiley->icon)); | |
5196 | |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5197 /* XXX: Is it necessary to _unref the loader first? */ |
11525 | 5198 smiley->loader = gdk_pixbuf_loader_new(); |
12335 | 5199 smiley->icon = NULL; |
5200 | |
5201 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); | |
5202 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
5203 | |
11525 | 5204 return TRUE; |
10526 | 5205 } |
5206 | |
5207 loader = gdk_pixbuf_loader_new(); | |
5208 | |
5209 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
5210 /* 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
|
5211 GtkIMHtmlSmiley by opaque */ |
10526 | 5212 smiley = g_new0(GtkIMHtmlSmiley, 1); |
5213 smiley->file = NULL; | |
5214 smiley->smile = g_strdup(smile); | |
5215 smiley->loader = loader; | |
11525 | 5216 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 5217 |
12335 | 5218 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); |
5219 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
11525 | 5220 |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5221 gtk_imhtml_associate_smiley(imhtml, sml, smiley); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5222 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5223 return TRUE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5224 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5225 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5226 static gboolean |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5227 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile, gboolean remote) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5228 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5229 GaimGtkConversation *gtkconv; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5230 struct smiley_list *list; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5231 const char *sml = NULL, *conv_sml; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5232 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5233 if (!conv || !smile || !*smile) { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5234 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5235 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5236 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5237 /* If smileys are off, return false */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5238 if (gaim_gtkthemes_smileys_disabled()) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5239 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5240 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5241 /* If possible add this smiley to the current theme. |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5242 * The addition is only temporary: custom smilies aren't saved to disk. */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5243 conv_sml = gaim_account_get_protocol_name(conv->account); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5244 gtkconv = GAIM_GTK_CONVERSATION(conv); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5245 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5246 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5247 if (!strcmp(list->sml, conv_sml)) { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5248 sml = list->sml; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5249 break; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5250 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5251 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5252 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5253 if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->imhtml), sml, smile)) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5254 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5255 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5256 if (!remote) /* If it's a local custom smiley, then add it for the entry */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5257 if (!add_custom_smiley_for_imhtml(GTK_IMHTML(gtkconv->entry), sml, smile)) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5258 return FALSE; |
10537 | 5259 |
10526 | 5260 return TRUE; |
5261 } | |
5262 | |
10537 | 5263 static void |
10526 | 5264 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 5265 const guchar *data, gsize size) |
10526 | 5266 { |
5267 GaimGtkConversation *gtkconv; | |
5268 GtkIMHtmlSmiley *smiley; | |
10537 | 5269 GdkPixbufLoader *loader; |
10526 | 5270 const char *sml; |
5271 | |
5272 sml = gaim_account_get_protocol_name(conv->account); | |
5273 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5274 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5275 | |
10537 | 5276 if (!smiley) |
10526 | 5277 return; |
10537 | 5278 |
10526 | 5279 loader = smiley->loader; |
10537 | 5280 if (!loader) |
10526 | 5281 return; |
5282 | |
5283 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
5284 } | |
5285 | |
5286 static void | |
5287 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
5288 { | |
5289 GaimGtkConversation *gtkconv; | |
5290 GtkIMHtmlSmiley *smiley; | |
5291 GdkPixbufLoader *loader; | |
5292 const char *sml; | |
5293 | |
5294 g_return_if_fail(conv != NULL); | |
5295 g_return_if_fail(smile != NULL); | |
5296 | |
5297 sml = gaim_account_get_protocol_name(conv->account); | |
5298 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5299 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5300 | |
10537 | 5301 if (!smiley) |
10526 | 5302 return; |
5303 | |
5304 loader = smiley->loader; | |
5305 | |
10537 | 5306 if (!loader) |
10526 | 5307 return; |
10537 | 5308 |
12335 | 5309 |
11525 | 5310 |
10526 | 5311 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
5312 | |
5313 gdk_pixbuf_loader_close(loader, NULL); | |
12335 | 5314 |
10526 | 5315 } |
5316 | |
11581 | 5317 /* |
5318 * Makes sure all the menu items and all the buttons are hidden/shown and | |
5319 * sensitive/insensitive. This is called after changing tabs and when an | |
5320 * account signs on or off. | |
5321 */ | |
5322 static void | |
5323 gray_stuff_out(GaimGtkConversation *gtkconv) | |
5324 { | |
5325 GaimGtkWindow *win; | |
5326 GaimConversation *conv = gtkconv->active_conv; | |
5327 GaimConnection *gc; | |
5328 GaimPluginProtocolInfo *prpl_info = NULL; | |
5329 GdkPixbuf *window_icon = NULL; | |
5330 GtkIMHtmlButtons buttons; | |
5331 GaimAccount *account; | |
5332 | |
5333 win = gaim_gtkconv_get_window(gtkconv); | |
5334 gc = gaim_conversation_get_gc(conv); | |
5335 account = gaim_conversation_get_account(conv); | |
5336 | |
5337 if (gc != NULL) | |
5338 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
5339 | |
11594 | 5340 if (win->menu.send_to != NULL) |
11734 | 5341 update_send_to_selection(win); |
11581 | 5342 |
5343 /* | |
5344 * Handle hiding and showing stuff based on what type of conv this is. | |
5345 * Stuff that Gaim IMs support in general should be shown for IM | |
5346 * conversations. Stuff that Gaim chats support in general should be | |
5347 * shown for chat conversations. It doesn't matter whether the PRPL | |
5348 * supports it or not--that only affects if the button or menu item | |
5349 * is sensitive or not. | |
5350 */ | |
5351 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
5352 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
5353 | |
5354 /* Deal with menu items */ | |
5355 gtk_widget_show(win->menu.view_log); | |
5356 gtk_widget_show(win->menu.send_file); | |
5357 gtk_widget_show(win->menu.add_pounce); | |
5358 gtk_widget_show(win->menu.get_info); | |
5359 gtk_widget_hide(win->menu.invite); | |
5360 gtk_widget_show(win->menu.alias); | |
5361 gtk_widget_show(win->menu.block); | |
5362 | |
13131 | 5363 if ((account == NULL) || gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { |
11581 | 5364 gtk_widget_show(win->menu.add); |
5365 gtk_widget_hide(win->menu.remove); | |
5366 } else { | |
5367 gtk_widget_show(win->menu.remove); | |
5368 gtk_widget_hide(win->menu.add); | |
5369 } | |
5370 | |
5371 gtk_widget_show(win->menu.insert_link); | |
5372 gtk_widget_show(win->menu.insert_image); | |
5373 gtk_widget_show(win->menu.show_icon); | |
5374 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
5375 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
5376 | |
5377 /* Deal with menu items */ | |
5378 gtk_widget_show(win->menu.view_log); | |
5379 gtk_widget_hide(win->menu.send_file); | |
5380 gtk_widget_hide(win->menu.add_pounce); | |
5381 gtk_widget_hide(win->menu.get_info); | |
5382 gtk_widget_show(win->menu.invite); | |
5383 gtk_widget_show(win->menu.alias); | |
5384 gtk_widget_hide(win->menu.block); | |
5385 gtk_widget_hide(win->menu.show_icon); | |
5386 | |
13131 | 5387 if ((account == NULL) || gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { |
11581 | 5388 /* If the chat is NOT in the buddy list */ |
5389 gtk_widget_show(win->menu.add); | |
5390 gtk_widget_hide(win->menu.remove); | |
5391 } else { | |
5392 /* If the chat IS in the buddy list */ | |
5393 gtk_widget_hide(win->menu.add); | |
5394 gtk_widget_show(win->menu.remove); | |
5395 } | |
5396 | |
5397 gtk_widget_show(win->menu.insert_link); | |
5398 gtk_widget_hide(win->menu.insert_image); | |
5399 } | |
5400 | |
5401 /* | |
5402 * Handle graying stuff out based on whether an account is connected | |
5403 * and what features that account supports. | |
5404 */ | |
5405 if ((gc != NULL) && | |
12012 | 5406 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
5407 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
5408 { | |
11581 | 5409 /* Account is online */ |
5410 /* Deal with the toolbar */ | |
12012 | 5411 if (conv->features & GAIM_CONNECTION_HTML) |
5412 { | |
5413 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
5414 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
5415 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
5416 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
5417 { | |
5418 buttons &= ~GTK_IMHTML_GROW; | |
5419 buttons &= ~GTK_IMHTML_SHRINK; | |
5420 } | |
5421 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
5422 buttons &= ~GTK_IMHTML_LINKDESC; | |
5423 } else { | |
12216 | 5424 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
12012 | 5425 } |
12216 | 5426 |
5427 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
5428 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
5429 buttons &= ~GTK_IMHTML_IMAGE; | |
5430 | |
12012 | 5431 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); |
13131 | 5432 if (account != NULL) |
5433 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 5434 |
5435 /* Deal with menu items */ | |
12012 | 5436 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5437 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5438 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
5439 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
5440 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
5441 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 5442 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 5443 |
5444 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
5445 { | |
5446 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
5447 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
5448 gtk_widget_set_sensitive(win->menu.send_file, | |
5449 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
5450 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
5451 gtk_widget_set_sensitive(win->menu.alias, | |
13131 | 5452 (account != NULL) && |
12012 | 5453 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); |
5454 } | |
5455 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5456 { | |
5457 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
5458 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
5459 gtk_widget_set_sensitive(win->menu.alias, | |
13131 | 5460 (account != NULL) && |
12012 | 5461 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); |
5462 } | |
11581 | 5463 |
5464 /* Deal with chat userlist buttons */ | |
12012 | 5465 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5466 { | |
5467 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
5468 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
5469 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
5470 } | |
5471 } else { | |
11581 | 5472 /* Account is offline */ |
5473 /* Or it's a chat that we've left. */ | |
5474 | |
5475 /* Then deal with menu items */ | |
12012 | 5476 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5477 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
5478 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5479 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
5480 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
5481 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
5482 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
5483 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
5484 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
5485 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
5486 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 5487 |
5488 /* Deal with chat userlist buttons */ | |
12012 | 5489 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5490 { | |
5491 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5492 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5493 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5494 } | |
5495 } | |
11581 | 5496 |
5497 /* | |
5498 * Update the window's icon | |
5499 */ | |
12171 | 5500 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5501 { |
12171 | 5502 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
5503 (gtkconv->u.im->anim)) | |
5504 { | |
5505 window_icon = | |
5506 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5507 g_object_ref(window_icon); | |
5508 } else { | |
5509 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5510 } | |
5511 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5512 if (window_icon != NULL) | |
5513 g_object_unref(G_OBJECT(window_icon)); | |
5514 } | |
11581 | 5515 } |
5516 | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5517 static void |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5518 gaim_gtkconv_update_fields(GaimConversation *conv, GaimGtkConvFields fields) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5519 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5520 GaimGtkConversation *gtkconv; |
11581 | 5521 GaimGtkWindow *win; |
10116 | 5522 |
4359 | 5523 gtkconv = GAIM_GTK_CONVERSATION(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5524 if (!gtkconv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5525 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5526 win = gaim_gtkconv_get_window(gtkconv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5527 if (!win) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5528 return; |
13090 | 5529 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5530 if (fields & GAIM_GTKCONV_SET_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5531 { |
4359 | 5532 gaim_conversation_autoset_title(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5533 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5534 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5535 if (fields & GAIM_GTKCONV_BUDDY_ICON) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5536 { |
11338 | 5537 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5538 gaim_gtkconv_update_buddy_icon(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5539 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5540 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5541 if (fields & GAIM_GTKCONV_MENU) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5542 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5543 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5544 generate_send_to_items(win); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5545 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5546 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5547 if (fields & GAIM_GTKCONV_TAB_ICON) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5548 { |
6395 | 5549 update_tab_icon(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5550 generate_send_to_items(win); /* To update the icons in SendTo menu */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5551 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5552 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5553 if ((fields & GAIM_GTKCONV_TOPIC) && |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5554 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5555 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5556 const char *topic; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5557 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5558 GaimGtkChatPane *gtkchat = gtkconv->u.chat; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5559 |
13350
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5560 if (gtkchat->topic_text != NULL) |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5561 { |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5562 topic = gaim_conv_chat_get_topic(chat); |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5563 |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5564 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5565 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5566 topic ? topic : "", NULL); |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5567 } |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5568 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5569 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5570 if (fields & GAIM_GTKCONV_SMILEY_THEME) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5571 gaim_gtkthemes_smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5572 |
13131 | 5573 if ((fields & GAIM_GTKCONV_COLORIZE_TITLE) || |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5574 (fields & GAIM_GTKCONV_SET_TITLE)) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5575 { |
9472 | 5576 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5577 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5578 GaimAccount *account = gaim_conversation_get_account(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5579 /* 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
|
5580 char style[51]; |
4736 | 5581 |
11338 | 5582 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5583 im = GAIM_CONV_IM(conv); |
4359 | 5584 |
13131 | 5585 if ((account == NULL) || |
5586 !gaim_account_is_connected(account) || | |
5587 ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5588 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) | |
9472 | 5589 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); |
5590 else | |
5591 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5592 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5593 *style = '\0'; |
4359 | 5594 |
5595 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5596 gtk_widget_realize(gtkconv->tab_label); | |
5597 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5598 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5599 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5600 { |
11759 | 5601 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5602 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5603 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5604 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5605 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5606 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5607 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5608 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5609 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5610 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5611 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5612 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5613 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5614 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5615 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5616 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5617 { |
11758 | 5618 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5619 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5620 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5621 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5622 { |
8536 | 5623 char *html_title,*label; |
5624 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5625 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5626 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5627 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5628 style, html_title); |
8536 | 5629 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5630 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5631 g_free(label); |
4359 | 5632 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5633 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5634 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5635 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5636 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5637 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5638 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5639 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5640 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5641 gtk_window_set_title(GTK_WINDOW(win->window), title); |
9472 | 5642 |
5643 g_free(title); | |
4359 | 5644 } |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5645 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5646 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5647 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5648 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5649 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5650 GaimGtkConvFields flags = 0; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5651 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5652 g_return_if_fail(conv != NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5653 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5654 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5655 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5656 flags = GAIM_GTKCONV_ALL; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5657 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5658 else if (type == GAIM_CONV_UPDATE_TYPING || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5659 type == GAIM_CONV_UPDATE_UNSEEN || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5660 type == GAIM_CONV_UPDATE_TITLE) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5661 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5662 flags = GAIM_GTKCONV_COLORIZE_TITLE; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5663 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5664 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5665 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5666 flags = GAIM_GTKCONV_TOPIC; |
4359 | 5667 } |
5668 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5669 type == GAIM_CONV_ACCOUNT_OFFLINE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5670 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5671 flags = GAIM_GTKCONV_MENU | GAIM_GTKCONV_TAB_ICON | GAIM_GTKCONV_SET_TITLE; |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5672 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5673 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5674 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5675 flags = GAIM_GTKCONV_TAB_ICON; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5676 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5677 else if (type == GAIM_CONV_UPDATE_ADD || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5678 type == GAIM_CONV_UPDATE_REMOVE || |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5679 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5680 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5681 flags = GAIM_GTKCONV_SET_TITLE | GAIM_GTKCONV_MENU; |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5682 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5683 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5684 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5685 flags = GAIM_GTKCONV_BUDDY_ICON; |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5686 } |
10665 | 5687 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5688 { | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5689 flags = GAIM_GTKCONV_MENU; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5690 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5691 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5692 gaim_gtkconv_update_fields(conv, flags); |
4359 | 5693 } |
5694 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5695 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5696 { |
11581 | 5697 gaim_gtkconv_new, |
4359 | 5698 gaim_gtkconv_destroy, /* destroy_conversation */ |
5699 gaim_gtkconv_write_chat, /* write_chat */ | |
5700 gaim_gtkconv_write_im, /* write_im */ | |
5701 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5702 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5703 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5704 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5705 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12618
diff
changeset
|
5706 gaim_gtkconv_present_conversation, /* present */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5707 gaim_gtkconv_has_focus, /* has_focus */ |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12618
diff
changeset
|
5708 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
10526 | 5709 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5710 gaim_gtkconv_custom_smiley_close /* custom_smiley_close */ |
4359 | 5711 }; |
5712 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5713 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5714 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5715 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5716 return &conversation_ui_ops; |
4359 | 5717 } |
5718 | |
5719 /************************************************************************** | |
5720 * Public conversation utility functions | |
5721 **************************************************************************/ | |
5722 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5723 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5724 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5725 GaimGtkConversation *gtkconv; |
11581 | 5726 GaimGtkWindow *win; |
4359 | 5727 |
10381 | 5728 GdkPixbufLoader *loader; |
5729 GdkPixbufAnimation *anim; | |
4359 | 5730 GError *err = NULL; |
5731 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5732 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5733 size_t len; |
4359 | 5734 |
5735 GdkPixbuf *buf; | |
5736 | |
5737 GtkWidget *event; | |
5738 GtkWidget *frame; | |
5739 GdkPixbuf *scale; | |
5740 GdkPixmap *pm; | |
5741 GdkBitmap *bm; | |
9318 | 5742 int scale_width, scale_height; |
5743 | |
5744 GaimAccount *account; | |
5745 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5746 |
9324 | 5747 GaimBuddyIcon *icon; |
5748 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5749 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5750 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5751 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5752 |
5753 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5754 win = gtkconv->win; |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5755 if (conv != gtkconv->active_conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5756 return; |
10175 | 5757 |
9687 | 5758 if (!gtkconv->u.im->show_icon) |
5759 return; | |
5760 | |
9318 | 5761 account = gaim_conversation_get_account(conv); |
5762 if(account && account->gc) | |
5763 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5764 |
9845 | 5765 /* Remove the current icon stuff */ |
9885 | 5766 if (gtkconv->u.im->icon_container != NULL) |
5767 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5768 gtkconv->u.im->icon_container = NULL; | |
9845 | 5769 |
5770 if (gtkconv->u.im->anim != NULL) | |
5771 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5772 | |
9887 | 5773 gtkconv->u.im->anim = NULL; |
5774 | |
9845 | 5775 if (gtkconv->u.im->icon_timer != 0) |
5776 g_source_remove(gtkconv->u.im->icon_timer); | |
5777 | |
5778 gtkconv->u.im->icon_timer = 0; | |
5779 | |
5780 if (gtkconv->u.im->iter != NULL) | |
5781 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5782 |
10116 | 5783 gtkconv->u.im->iter = NULL; |
5784 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5785 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5786 return; |
5787 | |
5788 if (gaim_conversation_get_gc(conv) == NULL) | |
5789 return; | |
5790 | |
9324 | 5791 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5792 | |
5793 if (icon == NULL) | |
5794 return; | |
5795 | |
5796 data = gaim_buddy_icon_get_data(icon, &len); | |
5797 | |
10381 | 5798 loader = gdk_pixbuf_loader_new(); |
5799 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
12601
e63fb8e9f4ac
[gaim-migrate @ 14935]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
5800 gdk_pixbuf_loader_close(loader, &err); |
10381 | 5801 anim = gdk_pixbuf_loader_get_animation(loader); |
5802 if (anim) | |
5803 g_object_ref(G_OBJECT(anim)); | |
5804 g_object_unref(loader); | |
5805 | |
5806 if (!anim) | |
9324 | 5807 return; |
10381 | 5808 gtkconv->u.im->anim = anim; |
9324 | 5809 |
4359 | 5810 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5811 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5812 "Buddy icon error: %s\n", err->message); |
4359 | 5813 g_error_free(err); |
5814 } | |
5815 | |
5816 if (!gtkconv->u.im->anim) | |
5817 return; | |
5818 | |
5819 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5820 gtkconv->u.im->iter = NULL; | |
5821 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5822 } else { | |
5823 gtkconv->u.im->iter = | |
8496 | 5824 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5825 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5826 if (gtkconv->u.im->animate) |
10810 | 5827 start_anim(NULL, gtkconv); |
4359 | 5828 } |
5829 | |
10483 | 5830 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5831 NULL, &scale_width, &scale_height); |
4359 | 5832 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5833 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5834 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5835 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5836 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5837 GDK_INTERP_BILINEAR); |
4359 | 5838 |
5839 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5840 g_object_unref(G_OBJECT(scale)); |
4359 | 5841 |
9885 | 5842 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5843 |
4359 | 5844 frame = gtk_frame_new(NULL); |
5845 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5846 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5847 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5848 FALSE, FALSE, 0); | |
8821 | 5849 |
4359 | 5850 event = gtk_event_box_new(); |
5851 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5852 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5853 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5854 gtk_widget_show(event); |
5855 | |
4635 | 5856 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5857 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5858 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5859 gtk_widget_show(gtkconv->u.im->icon); | |
5860 | |
4793 | 5861 g_object_unref(G_OBJECT(pm)); |
4359 | 5862 |
5863 if (bm) | |
4793 | 5864 g_object_unref(G_OBJECT(bm)); |
7143 | 5865 |
10356 | 5866 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5867 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5868 |
9885 | 5869 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5870 gtk_widget_show(frame); |
5871 | |
7143 | 5872 /* The buddy icon code needs badly to be fixed. */ |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5873 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
5874 { |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
5875 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); |
11581 | 5876 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
5877 } |
4359 | 5878 } |
5879 | |
5880 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5881 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5882 { |
11581 | 5883 GaimGtkWindow *win; |
4359 | 5884 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5885 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5886 return; |
5887 | |
11581 | 5888 win = GAIM_GTK_CONVERSATION(conv)->win; |
5889 | |
5890 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5891 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5892 } |
5893 | |
5894 int | |
11614 | 5895 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5896 { |
4359 | 5897 gint nb_x, nb_y, x_rel, y_rel; |
5898 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5899 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5900 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5901 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5902 gboolean horiz; |
4359 | 5903 |
11614 | 5904 if (to_right) |
5905 *to_right = FALSE; | |
5906 | |
11581 | 5907 notebook = GTK_NOTEBOOK(win->notebook); |
5908 | |
5909 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5910 x_rel = x - nb_x; |
5911 y_rel = y - nb_y; | |
5912 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5913 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5914 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5915 |
11780 | 5916 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5917 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5918 #else |
5919 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5920 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5921 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5922 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5923 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5924 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5925 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5926 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5927 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5928 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5929 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5930 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
|
5931 page_num = i; |
11614 | 5932 |
5933 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5934 *to_right = TRUE; | |
5935 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5936 break; |
4359 | 5937 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5938 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5939 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5940 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
|
5941 page_num = i; |
11614 | 5942 |
5943 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5944 *to_right = TRUE; | |
5945 | |
4359 | 5946 break; |
5947 } | |
5948 } | |
5949 } | |
5950 | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5951 if (page_num == -1) { |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5952 /* Add after the last tab */ |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5953 page_num = count - 1; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5954 } |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5955 |
4359 | 5956 return page_num; |
5957 } | |
5958 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5959 static void |
12816 | 5960 close_on_tabs_pref_cb(const char *name, GaimPrefType type, |
5961 gconstpointer value, gpointer data) | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5962 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5963 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5964 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5965 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5966 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5967 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5968 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5969 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5970 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5971 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5972 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5973 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5974 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5975 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5976 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5977 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5978 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5979 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5980 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5981 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5982 static void |
12816 | 5983 spellcheck_pref_cb(const char *name, GaimPrefType type, |
5984 gconstpointer value, gpointer data) | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5985 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5986 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5987 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5988 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5989 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5990 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5991 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5992 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5993 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5994 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5995 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5996 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5997 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5998 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5999 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6000 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6001 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6002 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6003 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6004 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6005 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6006 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6007 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6008 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6009 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6010 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6011 static void |
12816 | 6012 tab_side_pref_cb(const char *name, GaimPrefType type, |
6013 gconstpointer value, gpointer data) | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6014 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6015 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6016 GtkPositionType pos; |
11581 | 6017 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6018 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6019 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6020 |
11581 | 6021 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
6022 win = l->data; | |
6023 | |
11619 | 6024 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
|
6025 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6026 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6027 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6028 static void |
12188 | 6029 show_timestamps_pref_cb(const char *name, GaimPrefType type, |
12816 | 6030 gconstpointer value, gpointer data) |
12188 | 6031 { |
6032 GList *l; | |
6033 GaimConversation *conv; | |
6034 GaimGtkConversation *gtkconv; | |
6035 GaimGtkWindow *win; | |
6036 | |
6037 for (l = gaim_get_conversations(); l != NULL; l = l->next) | |
6038 { | |
6039 conv = (GaimConversation *)l->data; | |
6040 | |
6041 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
6042 continue; | |
6043 | |
6044 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6045 win = gtkconv->win; | |
6046 | |
6047 gtk_check_menu_item_set_active( | |
6048 GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
6049 (gboolean)GPOINTER_TO_INT(value)); | |
6050 | |
6051 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
6052 (gboolean)GPOINTER_TO_INT(value)); | |
6053 } | |
6054 } | |
6055 | |
6056 static void | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6057 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
12816 | 6058 gconstpointer value, gpointer data) |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6059 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6060 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6061 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6062 GaimGtkConversation *gtkconv; |
11581 | 6063 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6064 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6065 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6066 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6067 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6068 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6069 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6070 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6071 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6072 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 6073 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6074 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6075 gtk_check_menu_item_set_active( |
11581 | 6076 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
6077 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 6078 |
6079 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 6080 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6081 else |
8317 | 6082 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6083 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6084 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6085 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6086 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6087 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
12816 | 6088 gconstpointer value, gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6089 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6090 GList *l; |
8189 | 6091 GaimConversation *conv; |
6092 GaimGtkConversation *gtkconv; | |
11581 | 6093 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6094 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6095 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
|
6096 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6097 |
8189 | 6098 /* Set the "animate" flag for each icon based on the new preference */ |
6099 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
6100 conv = (GaimConversation *)l->data; | |
6101 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 6102 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6103 } |
8189 | 6104 |
6105 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 6106 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
6107 win = l->data; | |
6108 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 6109 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6110 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6111 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6112 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6113 static void |
12816 | 6114 show_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
6115 gconstpointer value, gpointer data) | |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6116 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6117 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6118 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6119 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6120 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6121 |
11338 | 6122 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 6123 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6124 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6125 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6126 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
6127 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6128 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
12816 | 6129 gconstpointer value, gpointer data) |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6130 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6131 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6132 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6133 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6134 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6135 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6136 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6137 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6138 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6139 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6140 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6141 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6142 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
|
6143 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6144 |
12310 | 6145 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
|
6146 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6147 |
13139
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6148 while ((l = hidden_convwin->gtkconvs) != NULL) |
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6149 { |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6150 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6151 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6152 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6153 |
12310 | 6154 if(!gaim_status_is_available( |
6155 gaim_account_get_active_status( | |
6156 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6157 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6158 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6159 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6160 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6161 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6162 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6163 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6164 static void |
12816 | 6165 hide_new_pref_cb(const char *name, GaimPrefType type, |
6166 gconstpointer value, gpointer data) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6167 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6168 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6169 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6170 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6171 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6172 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6173 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6174 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6175 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6176 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
|
6177 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6178 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6179 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
|
6180 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6181 |
13139
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6182 while ((l = hidden_convwin->gtkconvs) != NULL) |
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6183 { |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6184 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6185 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6186 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6187 |
12310 | 6188 if(when_away && !gaim_status_is_available( |
6189 gaim_account_get_active_status( | |
6190 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6191 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6192 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6193 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6194 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6195 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6196 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6197 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6198 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6199 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6200 conv_placement_pref_cb(const char *name, GaimPrefType type, |
12816 | 6201 gconstpointer value, gpointer data) |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6202 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6203 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6204 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6205 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6206 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6207 |
11581 | 6208 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6209 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6210 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6211 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6212 |
11581 | 6213 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6214 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6215 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6216 static GaimGtkConversation * |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6217 get_gtkconv_with_contact(GaimContact *contact) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6218 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6219 GaimBlistNode *node; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6220 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6221 node = ((GaimBlistNode*)contact)->child; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6222 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6223 for (; node; node = node->next) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6224 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6225 GaimBuddy *buddy = (GaimBuddy*)node; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6226 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6227 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, buddy->account); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6228 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6229 return GAIM_GTK_CONVERSATION(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6230 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6231 return NULL; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6232 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6233 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6234 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6235 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6236 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6237 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6238 GaimAccount *account; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6239 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6240 account = gaim_connection_get_account(gc); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6241 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6242 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6243 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6244 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6245 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6246 /* This seems fine in theory, but we also need to cover the |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6247 * case of this account matching one of the other buddies in |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6248 * one of the contacts containing the buddy corresponding to |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6249 * a conversation. It's easier to just update them all. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6250 /* if (gaim_conversation_get_account(conv) == account) */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6251 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON | |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6252 GAIM_GTKCONV_MENU | GAIM_GTKCONV_COLORIZE_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6253 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6254 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6255 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6256 static gboolean |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6257 update_buddy_status_timeout(GaimBuddy *buddy) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6258 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6259 /* To remove the signing-on/off door icon */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6260 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6261 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6262 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, buddy->account); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6263 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6264 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6265 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6266 return FALSE; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6267 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6268 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6269 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6270 update_buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *newstatus) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6271 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6272 GaimGtkConversation *gtkconv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6273 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6274 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6275 gtkconv = get_gtkconv_with_contact(gaim_buddy_get_contact(buddy)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6276 if (gtkconv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6277 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6278 conv = gtkconv->active_conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6279 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON | GAIM_GTKCONV_COLORIZE_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6280 if ((gaim_status_is_online(old) ^ gaim_status_is_online(newstatus)) != 0) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6281 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_MENU); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6282 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6283 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6284 /* In case a conversation is started after the buddy has signed-on/off */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6285 g_timeout_add(11000, (GSourceFunc)update_buddy_status_timeout, buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6286 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6287 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6288 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6289 update_buddy_idle_changed(GaimBuddy *buddy, gboolean old, gboolean newidle) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6290 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6291 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6292 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6293 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, buddy->account); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6294 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6295 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6296 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6297 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6298 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6299 update_buddy_icon(GaimBuddy *buddy) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6300 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6301 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6302 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6303 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, buddy->account); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6304 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6305 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_BUDDY_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6306 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6307 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6308 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6309 update_buddy_sign(GaimBuddy *buddy, const char *which) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6310 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6311 GaimPresence *presence; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6312 GaimStatus *on, *off; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6313 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6314 presence = gaim_buddy_get_presence(buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6315 if (!presence) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6316 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6317 off = gaim_presence_get_status(presence, "offline"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6318 on = gaim_presence_get_status(presence, "available"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6319 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6320 if (*(which+1) == 'f') |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6321 update_buddy_status_changed(buddy, on, off); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6322 else |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6323 update_buddy_status_changed(buddy, off, on); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6324 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6325 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6326 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6327 update_conversation_switched(GaimConversation *conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6328 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6329 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON | GAIM_GTKCONV_SET_TITLE | |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6330 GAIM_GTKCONV_MENU | GAIM_GTKCONV_BUDDY_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6331 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6332 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6333 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6334 update_buddy_typing(GaimAccount *account, const char *who) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6335 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6336 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6337 GaimGtkConversation *gtkconv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6338 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6339 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, who, account); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6340 if (!conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6341 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6342 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6343 gtkconv = GAIM_GTK_CONVERSATION(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6344 if (gtkconv && gtkconv->active_conv == conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6345 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_COLORIZE_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6346 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6347 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6348 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6349 update_chat(GaimConversation *conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6350 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6351 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TOPIC | |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6352 GAIM_GTKCONV_MENU | GAIM_GTKCONV_SET_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6353 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6354 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6355 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6356 update_chat_topic(GaimConversation *conv, const char *old, const char *new) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6357 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6358 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TOPIC); |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6359 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6360 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6361 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6362 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6363 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6364 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6365 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6366 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6367 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6368 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6369 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
6370 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6371 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6372 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6373 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6374 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6375 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6376 gaim_prefs_add_none("/gaim/gtk/conversations"); |
12553 | 6377 gaim_prefs_add_bool("/gaim/gtk/conversations/use_smooth_scrolling", TRUE); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6378 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6379 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6380 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6381 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6382 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
6383 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
6384 |
12264 | 6385 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6386 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 6387 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 6388 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6389 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 6390 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 6391 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
6392 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6393 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6394 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6395 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6396 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
|
6397 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6398 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6399 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6400 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6401 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6402 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6403 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6404 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6405 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6406 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 6407 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6408 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 6409 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6410 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6411 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6412 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 6413 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
|
6414 |
12616
eee2042ad4f4
[gaim-migrate @ 14952]
Richard Laager <rlaager@wiktel.com>
parents:
12604
diff
changeset
|
6415 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "never"); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6416 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6417 /* Connect callbacks. */ |
10087 | 6418 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
|
6419 close_on_tabs_pref_cb, NULL); |
12188 | 6420 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
6421 show_timestamps_pref_cb, NULL); | |
10087 | 6422 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
|
6423 show_formatting_toolbar_pref_cb, NULL); |
10087 | 6424 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6425 spellcheck_pref_cb, NULL); |
10087 | 6426 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6427 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6428 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6429 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6430 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6431 |
10087 | 6432 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6433 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6434 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6435 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6436 /* IM callbacks */ |
10087 | 6437 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
|
6438 animate_buddy_icons_pref_cb, NULL); |
10087 | 6439 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
|
6440 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6441 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6442 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6443 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6444 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6445 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6446 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6447 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6448 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
6449 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6450 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
12837
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6451 gaim_value_new(GAIM_TYPE_BOXED, |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6452 "GaimGtkWindow *"), |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6453 gaim_value_new(GAIM_TYPE_BOXED, |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6454 "GaimGtkWindow *")); |
9167 | 6455 |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6456 gaim_signal_register(handle, "conversation-timestamp", |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6457 gaim_marshal_POINTER__POINTER_POINTER, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6458 gaim_value_new(GAIM_TYPE_POINTER), 2, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6459 gaim_value_new(GAIM_TYPE_SUBTYPE, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6460 GAIM_SUBTYPE_CONVERSATION), |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6461 gaim_value_new(GAIM_TYPE_POINTER)); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6462 |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6463 gaim_signal_register(handle, "displaying-im-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6464 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6465 gaim_value_new(GAIM_TYPE_BOOLEAN), 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6466 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6467 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6468 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6469 gaim_value_new_outgoing(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6470 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6471 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6472 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6473 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6474 gaim_signal_register(handle, "displayed-im-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6475 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6476 NULL, 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6477 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6478 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6479 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6480 gaim_value_new(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6481 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6482 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6483 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6484 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6485 gaim_signal_register(handle, "displaying-chat-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6486 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6487 gaim_value_new(GAIM_TYPE_BOOLEAN), 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6488 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6489 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6490 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6491 gaim_value_new_outgoing(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6492 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6493 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6494 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6495 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6496 gaim_signal_register(handle, "displayed-chat-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6497 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6498 NULL, 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6499 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6500 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6501 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6502 gaim_value_new(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6503 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6504 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6505 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6506 |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6507 gaim_signal_register(handle, "conversation-switched", |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6508 gaim_marshal_VOID__POINTER_POINTER, NULL, 1, |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6509 gaim_value_new(GAIM_TYPE_SUBTYPE, |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6510 GAIM_SUBTYPE_CONVERSATION)); |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6511 |
9167 | 6512 /********************************************************************** |
6513 * Register commands | |
6514 **********************************************************************/ | |
9829 | 6515 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
6516 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
6517 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 6518 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
6519 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6520 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 6521 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
6522 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6523 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
|
6524 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6525 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6526 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 6527 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 6528 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
6529 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 6530 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6531 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6532 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6533 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6534 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6535 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6536 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6537 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6538 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6539 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6540 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6541 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6542 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6543 handle, G_CALLBACK(received_im_msg_cb), NULL); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6544 |
11581 | 6545 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6546 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6547 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6548 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6549 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6550 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6551 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6552 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6553 /* Callbacks to update a conversation */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6554 gaim_signal_connect(blist_handle, "buddy-added", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6555 G_CALLBACK(buddy_update_cb), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6556 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6557 G_CALLBACK(buddy_update_cb), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6558 gaim_signal_connect(blist_handle, "buddy-signed-on", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6559 handle, GAIM_CALLBACK(update_buddy_sign), "on"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6560 gaim_signal_connect(blist_handle, "buddy-signed-off", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6561 handle, GAIM_CALLBACK(update_buddy_sign), "off"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6562 gaim_signal_connect(blist_handle, "buddy-status-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6563 handle, GAIM_CALLBACK(update_buddy_status_changed), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6564 gaim_signal_connect(blist_handle, "buddy-idle-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6565 handle, GAIM_CALLBACK(update_buddy_idle_changed), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6566 gaim_signal_connect(blist_handle, "buddy-icon-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6567 handle, GAIM_CALLBACK(update_buddy_icon), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6568 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6569 handle, GAIM_CALLBACK(update_buddy_typing), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6570 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing-stopped", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6571 handle, GAIM_CALLBACK(update_buddy_typing), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6572 gaim_signal_connect(gaim_gtk_conversations_get_handle(), "conversation-switched", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6573 handle, GAIM_CALLBACK(update_conversation_switched), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6574 gaim_signal_connect(gaim_conversations_get_handle(), "chat-left", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6575 GAIM_CALLBACK(update_chat), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6576 gaim_signal_connect(gaim_conversations_get_handle(), "chat-joined", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6577 GAIM_CALLBACK(update_chat), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6578 gaim_signal_connect(gaim_conversations_get_handle(), "chat-topic-changed", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6579 GAIM_CALLBACK(update_chat_topic), NULL); |
12806
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6580 gaim_signal_connect_priority(gaim_conversations_get_handle(), "conversation-updated", handle, |
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6581 GAIM_CALLBACK(gaim_gtkconv_updated), NULL, |
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6582 GAIM_SIGNAL_PRIORITY_LOWEST); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6583 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6584 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6585 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6586 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6587 { |
10443 | 6588 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 6589 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6590 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6591 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6592 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6593 } |
11581 | 6594 |
6595 | |
6596 | |
6597 | |
6598 | |
6599 | |
6600 | |
6601 | |
6602 | |
6603 | |
6604 | |
6605 | |
6606 | |
6607 | |
6608 | |
6609 | |
6610 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
6611 * and touch each others' private members all day long */ | |
6612 | |
6613 /** | |
6614 * @file gtkconvwin.c GTK+ Conversation Window API | |
6615 * @ingroup gtkui | |
6616 * | |
6617 * gaim | |
6618 * | |
6619 * Gaim is the legal property of its developers, whose names are too numerous | |
6620 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6621 * source distribution. | |
6622 * | |
6623 * This program is free software; you can redistribute it and/or modify | |
6624 * it under the terms of the GNU General Public License as published by | |
6625 * the Free Software Foundation; either version 2 of the License, or | |
6626 * (at your option) any later version. | |
6627 * | |
6628 * This program is distributed in the hope that it will be useful, | |
6629 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
6630 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
6631 * GNU General Public License for more details. | |
6632 * | |
6633 * You should have received a copy of the GNU General Public License | |
6634 * along with this program; if not, write to the Free Software | |
6635 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
6636 * | |
6637 */ | |
6638 #include "internal.h" | |
6639 #include "gtkgaim.h" | |
6640 | |
6641 | |
6642 #include <gdk/gdkkeysyms.h> | |
6643 | |
6644 #include "account.h" | |
6645 #include "cmds.h" | |
6646 #include "debug.h" | |
6647 #include "imgstore.h" | |
6648 #include "log.h" | |
6649 #include "notify.h" | |
6650 #include "prpl.h" | |
6651 #include "request.h" | |
6652 #include "util.h" | |
6653 | |
6654 #include "gtkdnd-hints.h" | |
6655 #include "gtkblist.h" | |
6656 #include "gtkconv.h" | |
6657 #include "gtkdialogs.h" | |
6658 #include "gtkmenutray.h" | |
6659 #include "gtkpounce.h" | |
6660 #include "gtkprefs.h" | |
6661 #include "gtkprivacy.h" | |
6662 #include "gtkutils.h" | |
6663 #include "gtkstock.h" | |
6664 #include "gtkimhtml.h" | |
6665 #include "gtkimhtmltoolbar.h" | |
6666 | |
6667 static void | |
6668 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
6669 { | |
6670 gtk_widget_destroy(warn_close_dialog); | |
6671 warn_close_dialog = NULL; | |
6672 | |
6673 if (resp == GTK_RESPONSE_OK) | |
6674 gaim_gtk_conv_window_destroy(win); | |
6675 } | |
6676 | |
6677 static void | |
6678 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
6679 { | |
6680 GtkWidget *label; | |
6681 GtkWidget *vbox, *hbox; | |
6682 GtkWidget *img; | |
6683 | |
6684 g_return_if_fail(warn_close_dialog == NULL); | |
6685 | |
6686 | |
6687 warn_close_dialog = gtk_dialog_new_with_buttons( | |
12660 | 6688 _("Confirm close"), |
6689 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
6690 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
6691 GAIM_STOCK_CLOSE_TABS, GTK_RESPONSE_OK, NULL); | |
11581 | 6692 |
6693 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
6694 GTK_RESPONSE_OK); | |
6695 | |
6696 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
6697 6); | |
6698 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
6699 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
6700 FALSE); | |
6701 | |
6702 /* Setup the outside spacing. */ | |
6703 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
6704 | |
6705 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
6706 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
6707 | |
6708 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
6709 GTK_ICON_SIZE_DIALOG); | |
6710 /* Setup the inner hbox and put the dialog's icon in it. */ | |
6711 hbox = gtk_hbox_new(FALSE, 12); | |
6712 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
6713 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
6714 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
6715 | |
6716 /* Setup the right vbox. */ | |
6717 vbox = gtk_vbox_new(FALSE, 12); | |
6718 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
6719 | |
6720 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
6721 gtk_widget_set_size_request(label, 350, -1); | |
6722 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
6723 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
6724 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
6725 | |
6726 /* Connect the signals. */ | |
6727 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
6728 G_CALLBACK(do_close), gtkwin); | |
6729 | |
6730 } | |
6731 | |
6732 /************************************************************************** | |
6733 * Callbacks | |
6734 **************************************************************************/ | |
6735 | |
6736 static gboolean | |
6737 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
6738 { | |
6739 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6740 GList *l; |
11581 | 6741 |
6742 /* If there are unread messages then show a warning dialog */ | |
6743 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
6744 l != NULL; l = l->next) | |
6745 { | |
6746 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6747 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
|
6748 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6749 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6750 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6751 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6752 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6753 return TRUE; |
11581 | 6754 } |
6755 } | |
6756 | |
6757 gaim_gtk_conv_window_destroy(win); | |
6758 | |
6759 return TRUE; | |
6760 } | |
6761 | |
11604 | 6762 static void |
6763 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
6764 { | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6765 if (state == GAIM_UNSEEN_NONE) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6766 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6767 gtkconv->unseen_count = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6768 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6769 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6770 else |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6771 { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6772 if (state >= GAIM_UNSEEN_TEXT) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6773 gtkconv->unseen_count++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6774 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6775 if (state > gtkconv->unseen_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6776 gtkconv->unseen_state = state; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6777 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6778 |
12806
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6779 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
|
6780 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6781 |
11581 | 6782 /* |
6783 * When a conversation window is focused, we know the user | |
6784 * has looked at it so we know there are no longer unseen | |
6785 * messages. | |
6786 */ | |
6787 static gint | |
6788 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6789 { | |
6790 GaimGtkWindow *win = d; | |
11604 | 6791 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6792 | |
6793 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6794 |
6795 return FALSE; | |
6796 } | |
6797 | |
11851 | 6798 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6799 /* Courtesy of Galeon! */ |
6800 static void | |
6801 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6802 { | |
6803 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6804 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6805 } | |
11851 | 6806 #endif |
11581 | 6807 |
6808 static void | |
6809 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6810 { | |
6811 static GdkCursor *cursor = NULL; | |
6812 | |
6813 gtkwin->in_drag = TRUE; | |
6814 | |
6815 if (gtkwin->drag_leave_signal) { | |
6816 g_signal_handler_disconnect(G_OBJECT(widget), | |
6817 gtkwin->drag_leave_signal); | |
6818 gtkwin->drag_leave_signal = 0; | |
6819 } | |
6820 | |
6821 if (cursor == NULL) | |
6822 cursor = gdk_cursor_new(GDK_FLEUR); | |
6823 | |
6824 /* Grab the pointer */ | |
6825 gtk_grab_add(gtkwin->notebook); | |
6826 #ifndef _WIN32 | |
6827 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6828 always be true after a button press. */ | |
6829 if (!gdk_pointer_is_grabbed()) | |
6830 #endif | |
6831 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6832 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6833 NULL, cursor, GDK_CURRENT_TIME); | |
6834 } | |
6835 | |
6836 static gboolean | |
6837 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6838 { | |
6839 | |
6840 /* | |
6841 * Make sure the user moved the mouse far enough for the | |
6842 * drag to be initiated. | |
6843 */ | |
6844 if (win->in_predrag) { | |
6845 if (e->x_root < win->drag_min_x || | |
6846 e->x_root >= win->drag_max_x || | |
6847 e->y_root < win->drag_min_y || | |
6848 e->y_root >= win->drag_max_y) { | |
6849 | |
6850 win->in_predrag = FALSE; | |
6851 notebook_init_grab(win, widget); | |
6852 } | |
6853 } | |
6854 else { /* Otherwise, draw the arrows. */ | |
6855 GaimGtkWindow *dest_win; | |
6856 GtkNotebook *dest_notebook; | |
6857 GtkWidget *tab; | |
6858 gint nb_x, nb_y, page_num; | |
6859 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6860 gboolean horiz_tabs = FALSE; | |
11614 | 6861 GaimGtkConversation *gtkconv; |
6862 gboolean to_right = FALSE; | |
11581 | 6863 |
6864 /* Get the window that the cursor is over. */ | |
6865 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6866 | |
6867 if (dest_win == NULL) { | |
6868 dnd_hints_hide_all(); | |
6869 | |
6870 return TRUE; | |
6871 } | |
6872 | |
6873 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6874 | |
6875 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6876 | |
6877 arrow1_x = arrow2_x = nb_x; | |
6878 arrow1_y = arrow2_y = nb_y; | |
6879 | |
6880 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6881 e->x_root, e->y_root, &to_right); |
6882 to_right = to_right && (win != dest_win); | |
11581 | 6883 |
6884 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6885 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6886 | |
6887 horiz_tabs = TRUE; | |
6888 } | |
6889 | |
11614 | 6890 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6891 tab = gtkconv->tabby; | |
11581 | 6892 |
6893 if (horiz_tabs) { | |
6894 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6895 | |
11614 | 6896 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6897 arrow1_x += tab->allocation.width; |
6898 arrow2_x += tab->allocation.width; | |
6899 } | |
6900 | |
6901 arrow1_y = nb_y + tab->allocation.y; | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6902 arrow2_y = nb_y + tab->allocation.y + tab->allocation.height; |
11581 | 6903 } else { |
6904 arrow1_x = nb_x + tab->allocation.x; | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6905 arrow2_x = nb_x + tab->allocation.x + tab->allocation.width; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6906 arrow1_y = arrow2_y = nb_y + tab->allocation.y; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6907 |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6908 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6909 arrow1_y += tab->allocation.height; |
6910 arrow2_y += tab->allocation.height; | |
6911 } | |
6912 } | |
6913 | |
6914 if (horiz_tabs) { | |
6915 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6916 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6917 } else { | |
6918 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6919 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6920 } | |
6921 } | |
6922 | |
6923 return TRUE; | |
6924 } | |
6925 | |
6926 static gboolean | |
6927 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6928 { | |
6929 if (win->in_drag) | |
6930 return FALSE; | |
6931 | |
6932 if (e->x_root < win->drag_min_x || | |
6933 e->x_root >= win->drag_max_x || | |
6934 e->y_root < win->drag_min_y || | |
6935 e->y_root >= win->drag_max_y) { | |
6936 | |
6937 win->in_predrag = FALSE; | |
6938 notebook_init_grab(win, widget); | |
6939 } | |
6940 | |
6941 return TRUE; | |
6942 } | |
6943 | |
6944 /* | |
6945 * THANK YOU GALEON! | |
6946 */ | |
6947 static gboolean | |
6948 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6949 { | |
6950 gint nb_x, nb_y, x_rel, y_rel; | |
6951 int tab_clicked; | |
6952 GtkWidget *page; | |
6953 GtkWidget *tab; | |
6954 | |
6955 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6956 return FALSE; | |
6957 | |
6958 | |
6959 if (win->in_drag) { | |
6960 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6961 "Already in the middle of a window drag at tab_press_cb\n"); | |
6962 return TRUE; | |
6963 } | |
6964 | |
6965 /* | |
6966 * Make sure a tab was actually clicked. The arrow buttons | |
6967 * mess things up. | |
6968 */ | |
11614 | 6969 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6970 |
6971 if (tab_clicked == -1) | |
6972 return FALSE; | |
6973 | |
6974 /* | |
6975 * Get the relative position of the press event, with regards to | |
6976 * the position of the notebook. | |
6977 */ | |
6978 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6979 | |
6980 x_rel = e->x_root - nb_x; | |
6981 y_rel = e->y_root - nb_y; | |
6982 | |
6983 /* Reset the min/max x/y */ | |
6984 win->drag_min_x = 0; | |
6985 win->drag_min_y = 0; | |
6986 win->drag_max_x = 0; | |
6987 win->drag_max_y = 0; | |
6988 | |
6989 /* Find out which tab was dragged. */ | |
6990 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6991 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6992 | |
6993 win->drag_min_x = tab->allocation.x + nb_x; | |
6994 win->drag_min_y = tab->allocation.y + nb_y; | |
6995 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6996 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6997 | |
6998 /* Make sure the click occurred in the tab. */ | |
6999 if (e->x_root < win->drag_min_x || | |
7000 e->x_root >= win->drag_max_x || | |
7001 e->y_root < win->drag_min_y || | |
7002 e->y_root >= win->drag_max_y) { | |
7003 | |
7004 return FALSE; | |
7005 } | |
7006 | |
7007 win->in_predrag = TRUE; | |
7008 win->drag_tab = tab_clicked; | |
7009 | |
7010 /* Connect the new motion signals. */ | |
7011 win->drag_motion_signal = | |
7012 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
7013 G_CALLBACK(notebook_motion_cb), win); | |
7014 | |
7015 win->drag_leave_signal = | |
7016 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
7017 G_CALLBACK(notebook_leave_cb), win); | |
7018 | |
7019 return FALSE; | |
7020 } | |
7021 | |
7022 static gboolean | |
7023 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
7024 { | |
7025 GaimGtkWindow *dest_win; | |
7026 GaimConversation *conv; | |
7027 GaimGtkConversation *gtkconv; | |
7028 gint dest_page_num = 0; | |
7029 gboolean new_window = FALSE; | |
11614 | 7030 gboolean to_right = FALSE; |
11581 | 7031 |
7032 /* | |
7033 * Don't check to make sure that the event's window matches the | |
7034 * widget's, because we may be getting an event passed on from the | |
7035 * close button. | |
7036 */ | |
7037 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
7038 return FALSE; | |
7039 | |
7040 if (gdk_pointer_is_grabbed()) { | |
7041 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
7042 gtk_grab_remove(widget); | |
7043 } | |
7044 | |
7045 if (!win->in_predrag && !win->in_drag) | |
7046 return FALSE; | |
7047 | |
7048 /* Disconnect the motion signal. */ | |
7049 if (win->drag_motion_signal) { | |
7050 g_signal_handler_disconnect(G_OBJECT(widget), | |
7051 win->drag_motion_signal); | |
7052 | |
7053 win->drag_motion_signal = 0; | |
7054 } | |
7055 | |
7056 /* | |
7057 * If we're in a pre-drag, we'll also need to disconnect the leave | |
7058 * signal. | |
7059 */ | |
7060 if (win->in_predrag) { | |
7061 win->in_predrag = FALSE; | |
7062 | |
7063 if (win->drag_leave_signal) { | |
7064 g_signal_handler_disconnect(G_OBJECT(widget), | |
7065 win->drag_leave_signal); | |
7066 | |
7067 win->drag_leave_signal = 0; | |
7068 } | |
7069 } | |
7070 | |
7071 /* If we're not in drag... */ | |
7072 /* We're perfectly normal people! */ | |
7073 if (!win->in_drag) | |
7074 return FALSE; | |
7075 | |
7076 win->in_drag = FALSE; | |
7077 | |
7078 dnd_hints_hide_all(); | |
7079 | |
7080 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
7081 | |
7082 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
7083 | |
7084 if (dest_win == NULL) { | |
7085 /* If the current window doesn't have any other conversations, | |
7086 * there isn't much point transferring the conv to a new window. */ | |
7087 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
7088 /* Make a new window to stick this to. */ | |
7089 dest_win = gaim_gtk_conv_window_new(); | |
7090 new_window = TRUE; | |
7091 } | |
7092 } | |
7093 | |
7094 if (dest_win == NULL) | |
7095 return FALSE; | |
7096 | |
7097 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
7098 "conversation-dragging", win, dest_win); | |
7099 | |
7100 /* Get the destination page number. */ | |
7101 if (!new_window) | |
7102 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 7103 e->x_root, e->y_root, &to_right); |
11581 | 7104 |
7105 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7106 | |
7107 if (win == dest_win) { | |
7108 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
7109 } else { | |
7110 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
7111 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 7112 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 7113 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
7114 if (new_window) { | |
7115 gint win_width, win_height; | |
7116 | |
7117 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
7118 &win_width, &win_height); | |
7119 | |
7120 gtk_window_move(GTK_WINDOW(dest_win->window), | |
7121 e->x_root - (win_width / 2), | |
7122 e->y_root - (win_height / 2)); | |
7123 | |
7124 gaim_gtk_conv_window_show(dest_win); | |
7125 } | |
7126 } | |
7127 | |
7128 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
7129 | |
7130 return TRUE; | |
7131 } | |
7132 | |
7133 | |
7134 static void | |
7135 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
7136 gpointer user_data) | |
7137 { | |
7138 GaimGtkWindow *win; | |
7139 GaimConversation *conv; | |
7140 GaimGtkConversation *gtkconv; | |
7141 | |
7142 win = user_data; | |
7143 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
7144 | |
7145 g_return_if_fail(conv != NULL); | |
7146 | |
7147 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
7148 return; | |
7149 | |
7150 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7151 | |
7152 stop_anim(NULL, gtkconv); | |
7153 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7154 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7155 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7156 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7157 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7158 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7159 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7160 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7161 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7162 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7163 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7164 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7165 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7166 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7167 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7168 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7169 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7170 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7171 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7172 /* 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
|
7173 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7174 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7175 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7176 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7177 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7178 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7179 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7180 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7181 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7182 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7183 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7184 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7185 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7186 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7187 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7188 GaimGtkWindow *win; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7189 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7190 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7191 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7192 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7193 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7194 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7195 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7196 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7197 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7198 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7199 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7200 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7201 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7202 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7203 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7204 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7205 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7206 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7207 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7208 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7209 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7210 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7211 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7212 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7213 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7214 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7215 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7216 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7217 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7218 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7219 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7220 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7221 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7222 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7223 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7224 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7225 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7226 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7227 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7228 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
7229 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
|
7230 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7231 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7232 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7233 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7234 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7235 } |
12188 | 7236 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7237 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7238 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7239 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7240 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7241 |
13326 | 7242 item = gtk_menu_item_new_with_label(_("Close other tabs")); |
12824
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7243 gtk_widget_show(item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7244 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7245 g_signal_connect(G_OBJECT(item), "activate", |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7246 G_CALLBACK(close_others_cb), menu); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7247 |
13326 | 7248 item = gtk_menu_item_new_with_label(_("Close all tabs")); |
12824
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7249 gtk_widget_show(item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7250 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7251 g_signal_connect(G_OBJECT(item), "activate", |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7252 G_CALLBACK(close_window), win); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7253 |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7254 gaim_separator(menu); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7255 |
13326 | 7256 item = gtk_menu_item_new_with_label(_("Detach this tab")); |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7257 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7258 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7259 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7260 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7261 |
13326 | 7262 item = gtk_menu_item_new_with_label(_("Close this tab")); |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7263 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7264 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7265 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7266 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7267 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7268 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7269 } |
11581 | 7270 |
7271 static void | |
7272 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
7273 gpointer user_data) | |
7274 { | |
7275 GaimGtkWindow *win; | |
7276 GaimConversation *conv; | |
7277 GaimGtkConversation *gtkconv; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7278 const char *sound_method; |
11581 | 7279 |
7280 win = user_data; | |
7281 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
7282 conv = gtkconv->active_conv; | |
7283 | |
7284 g_return_if_fail(conv != NULL); | |
7285 | |
7286 /* | |
7287 * Only set "unseen" to "none" if the window has focus | |
7288 */ | |
7289 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 7290 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 7291 |
7292 /* Update the menubar */ | |
7293 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
7294 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
|
7295 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
7296 |
11594 | 7297 generate_send_to_items(win); |
7298 | |
11604 | 7299 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 7300 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7301 sound_method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7302 if (strcmp(sound_method, "none") != 0) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7303 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7304 gtkconv->make_sound); |
11581 | 7305 |
7306 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
7307 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
7308 | |
7309 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
12188 | 7310 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
11581 | 7311 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7312 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM && |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7313 gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7314 { |
11581 | 7315 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
7316 gtkconv->u.im->show_icon); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7317 } |
11604 | 7318 |
11581 | 7319 /* |
7320 * We pause icons when they are not visible. If this icon should | |
7321 * be animated then start it back up again. | |
7322 */ | |
7323 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
7324 (gtkconv->u.im->animate)) | |
7325 start_anim(NULL, gtkconv); | |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
7326 |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
7327 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-switched", conv); |
11581 | 7328 } |
7329 | |
7330 /************************************************************************** | |
7331 * GTK+ window ops | |
7332 **************************************************************************/ | |
7333 | |
7334 GList * | |
7335 gaim_gtk_conv_windows_get_list() | |
7336 { | |
7337 return window_list; | |
7338 } | |
7339 | |
7340 GaimGtkWindow * | |
7341 gaim_gtk_conv_window_new() | |
7342 { | |
7343 GaimGtkWindow *win; | |
7344 GtkPositionType pos; | |
7345 GtkWidget *testidea; | |
7346 GtkWidget *menubar; | |
7347 | |
7348 win = g_malloc0(sizeof(GaimGtkWindow)); | |
7349 | |
7350 window_list = g_list_append(window_list, win); | |
7351 | |
7352 /* Create the window. */ | |
7353 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
7354 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
7355 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
7356 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
7357 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
7358 | |
7359 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
7360 G_CALLBACK(close_win_cb), win); | |
7361 | |
7362 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
7363 G_CALLBACK(focus_win_cb), win); | |
7364 | |
7365 /* Create the notebook. */ | |
7366 win->notebook = gtk_notebook_new(); | |
7367 | |
7368 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
7369 | |
7370 #if 0 | |
7371 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
7372 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
7373 #endif | |
7374 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
7375 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
7376 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
7377 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
7378 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
7379 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7380 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7381 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7382 |
11581 | 7383 gtk_widget_show(win->notebook); |
7384 | |
7385 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
7386 G_CALLBACK(before_switch_conv_cb), win); | |
7387 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
7388 G_CALLBACK(switch_conv_cb), win); | |
7389 | |
7390 /* Setup the tab drag and drop signals. */ | |
7391 gtk_widget_add_events(win->notebook, | |
7392 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
7393 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
7394 G_CALLBACK(notebook_press_cb), win); | |
7395 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
7396 G_CALLBACK(notebook_release_cb), win); | |
7397 | |
7398 testidea = gtk_vbox_new(FALSE, 0); | |
7399 | |
7400 /* Setup the menubar. */ | |
7401 menubar = setup_menubar(win); | |
7402 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
7403 | |
7404 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
7405 | |
7406 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
7407 | |
7408 gtk_widget_show(testidea); | |
7409 | |
7410 return win; | |
7411 } | |
7412 | |
7413 void | |
7414 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
7415 { | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7416 gaim_prefs_disconnect_by_handle(win); |
11581 | 7417 window_list = g_list_remove(window_list, win); |
7418 | |
11611 | 7419 if (win->gtkconvs) { |
7420 while (win->gtkconvs) { | |
7421 GList *nextgtk = win->gtkconvs->next; | |
7422 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
7423 GList *nextcore = gtkconv->convs->next; | |
7424 GaimConversation *conv = gtkconv->convs->data; | |
7425 gaim_conversation_destroy(conv); | |
7426 if (!nextgtk && !nextcore) | |
7427 /* we'll end up invoking ourselves when we destroy our last child */ | |
7428 /* so don't destroy ourselves right now */ | |
7429 return; | |
7430 } | |
7431 return; | |
7432 } | |
11581 | 7433 gtk_widget_destroy(win->window); |
7434 | |
7435 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
7436 | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
7437 gaim_notify_close_with_handle(win); |
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
7438 |
11581 | 7439 g_free(win); |
7440 } | |
7441 | |
7442 void | |
7443 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
7444 { | |
7445 gtk_widget_show(win->window); | |
7446 } | |
7447 | |
7448 void | |
7449 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
7450 { | |
7451 gtk_widget_hide(win->window); | |
7452 } | |
7453 | |
7454 void | |
7455 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
7456 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
7457 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 7458 } |
7459 | |
7460 void | |
7461 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
7462 { | |
7463 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
7464 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
7465 gtkconv->tab_cont)); | |
7466 } | |
7467 | |
7468 void | |
7469 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
7470 { | |
7471 GaimConversation *conv = gtkconv->active_conv; | |
7472 GaimGtkConversation *focus_gtkconv; | |
7473 GtkWidget *tabby, *menu_tabby; | |
7474 GtkWidget *tab_cont = gtkconv->tab_cont; | |
7475 GtkWidget *close_image; | |
7476 GaimConversationType conv_type; | |
7477 const char *name; | |
7478 const gchar *tmp_lab; | |
7479 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 7480 gboolean tabs_side = FALSE; |
7481 gint angle = 0; | |
11581 | 7482 |
7483 name = gaim_conversation_get_name(conv); | |
7484 conv_type = gaim_conversation_get_type(conv); | |
7485 | |
7486 | |
7487 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
7488 gtkconv->win = win; | |
7489 | |
11619 | 7490 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
7491 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
7492 tabs_side = TRUE; | |
7493 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
7494 angle = 90; | |
7495 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
7496 angle = 270; | |
7497 | |
7498 if (angle) | |
7499 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
7500 else | |
7501 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 7502 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
7503 | |
7504 /* Close button. */ | |
7505 gtkconv->close = gtk_button_new(); | |
7506 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
7507 if (gtk_check_version(2, 4, 2) == NULL) { | |
7508 /* Need to account for extra padding around the gtkbutton */ | |
7509 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
7510 "focus-line-width", &focus_width, | |
7511 "focus-padding", &focus_pad, | |
7512 NULL); | |
7513 close_button_width += (focus_width + focus_pad) * 2; | |
7514 close_button_height += (focus_width + focus_pad) * 2; | |
7515 } | |
7516 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
7517 close_button_width, close_button_height); | |
7518 | |
7519 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
7520 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
7521 gtk_widget_show(close_image); | |
7522 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
7523 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
7524 _("Close conversation"), NULL); | |
7525 | |
7526 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
7527 G_CALLBACK(close_conv_cb), gtkconv); | |
7528 | |
11851 | 7529 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 7530 /* |
7531 * I love Galeon. They have a fix for that stupid annoying visible | |
7532 * border bug. I love you guys! -- ChipX86 | |
7533 */ | |
11851 | 7534 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 7535 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
7536 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 7537 #endif |
11581 | 7538 |
7539 /* Status icon. */ | |
7540 gtkconv->icon = gtk_image_new(); | |
7541 gtkconv->menu_icon = gtk_image_new(); | |
7542 update_tab_icon(conv); | |
7543 | |
7544 /* Tab label. */ | |
7545 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 7546 |
11581 | 7547 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 7548 if (!angle) |
7549 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 7550 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 7551 if (tabs_side) { |
7552 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
7553 } | |
7554 if (angle) | |
7555 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 7556 #endif |
7557 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
7558 #if 0 | |
7559 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
7560 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
7561 #endif | |
7562 | |
7563 /* Pack it all together. */ | |
11619 | 7564 if (angle == 90) |
7565 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
7566 else | |
7567 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 7568 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
7569 FALSE, FALSE, 0); | |
7570 | |
7571 gtk_widget_show_all(gtkconv->icon); | |
7572 gtk_widget_show_all(gtkconv->menu_icon); | |
7573 | |
7574 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
7575 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
7576 gtk_widget_show(gtkconv->tab_label); | |
7577 gtk_widget_show(gtkconv->menu_label); | |
7578 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
7579 | |
11619 | 7580 if (angle == 90) |
7581 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
7582 else | |
7583 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 7584 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
7585 gtk_widget_show(gtkconv->close); | |
7586 | |
7587 gtk_widget_show(tabby); | |
7588 gtk_widget_show(menu_tabby); | |
7589 | |
7590 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
7591 gaim_gtkconv_update_buddy_icon(conv); | |
7592 | |
7593 /* Add this pane to the conversation's notebook. */ | |
7594 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 7595 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 7596 |
7597 | |
7598 gtk_widget_show(tab_cont); | |
7599 | |
7600 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
7601 /* Er, bug in notebooks? Switch to the page manually. */ | |
7602 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
7603 | |
7604 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7605 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7606 } else | |
7607 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
7608 | |
7609 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
7610 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
7611 gtk_widget_grab_focus(focus_gtkconv->entry); | |
7612 | |
7613 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 7614 update_send_to_selection(win); |
11581 | 7615 } |
7616 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7617 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7618 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
11581 | 7619 { |
7620 unsigned int index; | |
7621 GaimConversationType conv_type; | |
7622 | |
7623 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
7624 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
7625 | |
7626 g_object_ref(gtkconv->tab_cont); | |
7627 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
7628 | |
7629 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
7630 | |
7631 /* go back to tabless if need be */ | |
7632 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
7633 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7634 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7635 } | |
7636 | |
7637 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 7638 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7639 if (!win->gtkconvs && win != hidden_convwin) |
11582 | 7640 gaim_gtk_conv_window_destroy(win); |
11581 | 7641 } |
7642 | |
7643 GaimGtkConversation * | |
7644 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
7645 { | |
7646 GtkWidget *tab_cont; | |
7647 | |
7648 if (index == -1) | |
7649 index = 0; | |
7650 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 7651 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 7652 } |
7653 | |
7654 GaimGtkConversation * | |
7655 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
7656 { | |
7657 int index; | |
7658 GtkWidget *tab_cont; | |
7659 | |
7660 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
7661 if (index == -1) | |
7662 index = 0; | |
7663 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
7664 if (!tab_cont) | |
7665 return NULL; | |
7666 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
7667 } | |
7668 | |
7669 | |
7670 GaimConversation * | |
7671 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
7672 { | |
7673 GaimGtkConversation *gtkconv; | |
7674 | |
7675 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
7676 return gtkconv ? gtkconv->active_conv : NULL; | |
7677 } | |
7678 | |
7679 gboolean | |
7680 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
7681 { | |
7682 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
7683 } | |
7684 | |
7685 gboolean | |
7686 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
7687 { | |
7688 gboolean has_focus = FALSE; | |
7689 | |
7690 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
7691 | |
7692 return has_focus; | |
7693 } | |
7694 | |
7695 GaimGtkWindow * | |
7696 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
7697 { | |
7698 GaimGtkWindow *win; | |
7699 GdkWindow *gdkwin; | |
7700 GList *l; | |
7701 | |
7702 gdkwin = gdk_window_at_pointer(&x, &y); | |
7703 | |
7704 if (gdkwin) | |
7705 gdkwin = gdk_window_get_toplevel(gdkwin); | |
7706 | |
7707 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
7708 win = l->data; | |
7709 | |
7710 if (gdkwin == win->window->window) | |
7711 return win; | |
7712 } | |
7713 | |
7714 return NULL; | |
7715 } | |
7716 | |
7717 GList * | |
7718 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
7719 { | |
7720 return win->gtkconvs; | |
7721 } | |
7722 | |
7723 guint | |
7724 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
7725 { | |
7726 return g_list_length(win->gtkconvs); | |
7727 } | |
7728 | |
7729 GaimGtkWindow * | |
7730 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
7731 { | |
7732 GList *wins, *convs; | |
7733 GaimGtkWindow *win; | |
7734 GaimGtkConversation *conv; | |
7735 | |
7736 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7737 return NULL; | |
7738 | |
7739 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7740 win = wins->data; | |
7741 | |
7742 for (convs = win->gtkconvs; | |
7743 convs != NULL; | |
7744 convs = convs->next) { | |
7745 | |
7746 conv = convs->data; | |
7747 | |
7748 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7749 return win; | |
7750 } | |
7751 } | |
7752 | |
7753 return NULL; | |
7754 } | |
7755 | |
7756 GaimGtkWindow * | |
7757 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
7758 { | |
7759 GList *wins, *convs; | |
7760 GaimGtkWindow *win; | |
7761 GaimGtkConversation *conv; | |
7762 | |
7763 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7764 return NULL; | |
7765 | |
7766 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7767 wins != NULL; | |
7768 wins = wins->prev) { | |
7769 | |
7770 win = wins->data; | |
7771 | |
7772 for (convs = win->gtkconvs; | |
7773 convs != NULL; | |
7774 convs = convs->next) { | |
7775 | |
7776 conv = convs->data; | |
7777 | |
7778 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7779 return win; | |
7780 } | |
7781 } | |
7782 | |
7783 return NULL; | |
7784 } | |
7785 | |
7786 | |
7787 /************************************************************************** | |
7788 * Conversation placement functions | |
7789 **************************************************************************/ | |
7790 typedef struct | |
7791 { | |
7792 char *id; | |
7793 char *name; | |
7794 GaimConvPlacementFunc fnc; | |
7795 | |
7796 } ConvPlacementData; | |
7797 | |
7798 static GList *conv_placement_fncs = NULL; | |
7799 static GaimConvPlacementFunc place_conv = NULL; | |
7800 | |
7801 /* This one places conversations in the last made window. */ | |
7802 static void | |
7803 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7804 { | |
7805 GaimGtkWindow *win; | |
7806 | |
7807 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7808 win = l ? l->data : NULL;; | |
7809 | |
7810 if (win == NULL) { | |
7811 win = gaim_gtk_conv_window_new(); | |
7812 | |
7813 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7814 gaim_gtk_conv_window_show(win); | |
7815 } else { | |
7816 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7817 } | |
7818 } | |
7819 | |
7820 /* This one places conversations in the last made window of the same type. */ | |
7821 static void | |
7822 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7823 { | |
7824 GaimGtkWindow *win; | |
7825 | |
7826 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7827 | |
7828 if (win == NULL) { | |
7829 win = gaim_gtk_conv_window_new(); | |
7830 | |
7831 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7832 gaim_gtk_conv_window_show(win); | |
7833 } else | |
7834 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7835 } | |
7836 | |
7837 /* This one places each conversation in its own window. */ | |
7838 static void | |
7839 conv_placement_new_window(GaimGtkConversation *conv) | |
7840 { | |
7841 GaimGtkWindow *win; | |
7842 | |
7843 win = gaim_gtk_conv_window_new(); | |
7844 | |
7845 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7846 | |
7847 gaim_gtk_conv_window_show(win); | |
7848 } | |
7849 | |
7850 static GaimGroup * | |
7851 conv_get_group(GaimGtkConversation *conv) | |
7852 { | |
7853 GaimGroup *group = NULL; | |
7854 | |
7855 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7856 GaimBuddy *buddy; | |
7857 | |
7858 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7859 gaim_conversation_get_name(conv->active_conv)); | |
7860 | |
7861 if (buddy != NULL) | |
12088 | 7862 group = gaim_buddy_get_group(buddy); |
11581 | 7863 |
7864 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7865 GaimChat *chat; | |
7866 | |
7867 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7868 gaim_conversation_get_name(conv->active_conv)); | |
7869 | |
7870 if (chat != NULL) | |
7871 group = gaim_chat_get_group(chat); | |
7872 } | |
7873 | |
7874 return group; | |
7875 } | |
7876 | |
7877 /* | |
7878 * This groups things by, well, group. Buddies from groups will always be | |
7879 * grouped together, and a buddy from a group not belonging to any currently | |
7880 * open windows will get a new window. | |
7881 */ | |
7882 static void | |
7883 conv_placement_by_group(GaimGtkConversation *conv) | |
7884 { | |
7885 GaimConversationType type; | |
7886 GaimGroup *group = NULL; | |
7887 GList *wl, *cl; | |
7888 | |
7889 type = gaim_conversation_get_type(conv->active_conv); | |
7890 | |
7891 group = conv_get_group(conv); | |
7892 | |
7893 /* Go through the list of IMs and find one with this group. */ | |
7894 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7895 GaimGtkWindow *win2; | |
7896 GaimGtkConversation *conv2; | |
7897 GaimGroup *group2 = NULL; | |
7898 | |
7899 win2 = wl->data; | |
7900 | |
7901 for (cl = win2->gtkconvs; | |
7902 cl != NULL; | |
7903 cl = cl->next) { | |
7904 conv2 = cl->data; | |
7905 | |
7906 group2 = conv_get_group(conv2); | |
7907 | |
7908 if (group == group2) { | |
7909 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7910 | |
7911 return; | |
7912 } | |
7913 } | |
7914 } | |
7915 | |
7916 /* Make a new window. */ | |
7917 conv_placement_new_window(conv); | |
7918 } | |
7919 | |
7920 /* This groups things by account. Otherwise, the same semantics as above */ | |
7921 static void | |
7922 conv_placement_by_account(GaimGtkConversation *conv) | |
7923 { | |
7924 GaimConversationType type; | |
7925 GList *wins, *convs; | |
7926 GaimAccount *account; | |
7927 | |
7928 account = gaim_conversation_get_account(conv->active_conv); | |
7929 type = gaim_conversation_get_type(conv->active_conv); | |
7930 | |
7931 /* Go through the list of IMs and find one with this group. */ | |
7932 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7933 GaimGtkWindow *win2; | |
7934 GaimGtkConversation *conv2; | |
7935 | |
7936 win2 = wins->data; | |
7937 | |
7938 for (convs = win2->gtkconvs; | |
7939 convs != NULL; | |
7940 convs = convs->next) { | |
7941 conv2 = convs->data; | |
7942 | |
7943 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7944 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7945 return; | |
7946 } | |
7947 } | |
7948 } | |
7949 | |
7950 /* Make a new window. */ | |
7951 conv_placement_new_window(conv); | |
7952 } | |
7953 | |
7954 static ConvPlacementData * | |
7955 get_conv_placement_data(const char *id) | |
7956 { | |
7957 ConvPlacementData *data = NULL; | |
7958 GList *n; | |
7959 | |
7960 for (n = conv_placement_fncs; n; n = n->next) { | |
7961 data = n->data; | |
7962 if (!strcmp(data->id, id)) | |
7963 return data; | |
7964 } | |
7965 | |
7966 return NULL; | |
7967 } | |
7968 | |
7969 static void | |
7970 add_conv_placement_fnc(const char *id, const char *name, | |
7971 GaimConvPlacementFunc fnc) | |
7972 { | |
7973 ConvPlacementData *data; | |
7974 | |
7975 data = g_new(ConvPlacementData, 1); | |
7976 | |
7977 data->id = g_strdup(id); | |
7978 data->name = g_strdup(name); | |
7979 data->fnc = fnc; | |
7980 | |
7981 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7982 } | |
7983 | |
7984 static void | |
7985 ensure_default_funcs(void) | |
7986 { | |
7987 if (conv_placement_fncs == NULL) { | |
7988 add_conv_placement_fnc("last", _("Last created window"), | |
7989 conv_placement_last_created_win); | |
7990 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7991 conv_placement_last_created_win_type); | |
7992 add_conv_placement_fnc("new", _("New window"), | |
7993 conv_placement_new_window); | |
7994 add_conv_placement_fnc("group", _("By group"), | |
7995 conv_placement_by_group); | |
7996 add_conv_placement_fnc("account", _("By account"), | |
7997 conv_placement_by_account); | |
7998 } | |
7999 } | |
8000 | |
8001 GList * | |
8002 gaim_gtkconv_placement_get_options(void) | |
8003 { | |
8004 GList *n, *list = NULL; | |
8005 ConvPlacementData *data; | |
8006 | |
8007 ensure_default_funcs(); | |
8008 | |
8009 for (n = conv_placement_fncs; n; n = n->next) { | |
8010 data = n->data; | |
8011 list = g_list_append(list, data->name); | |
8012 list = g_list_append(list, data->id); | |
8013 } | |
8014 | |
8015 return list; | |
8016 } | |
8017 | |
8018 | |
8019 void | |
8020 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
8021 GaimConvPlacementFunc fnc) | |
8022 { | |
8023 g_return_if_fail(id != NULL); | |
8024 g_return_if_fail(name != NULL); | |
8025 g_return_if_fail(fnc != NULL); | |
8026 | |
8027 ensure_default_funcs(); | |
8028 | |
8029 add_conv_placement_fnc(id, name, fnc); | |
8030 } | |
8031 | |
8032 void | |
8033 gaim_gtkconv_placement_remove_fnc(const char *id) | |
8034 { | |
8035 ConvPlacementData *data = get_conv_placement_data(id); | |
8036 | |
8037 if (data == NULL) | |
8038 return; | |
8039 | |
8040 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
8041 | |
8042 g_free(data->id); | |
8043 g_free(data->name); | |
8044 g_free(data); | |
8045 } | |
8046 | |
8047 const char * | |
8048 gaim_gtkconv_placement_get_name(const char *id) | |
8049 { | |
8050 ConvPlacementData *data; | |
8051 | |
8052 ensure_default_funcs(); | |
8053 | |
8054 data = get_conv_placement_data(id); | |
8055 | |
8056 if (data == NULL) | |
8057 return NULL; | |
8058 | |
8059 return data->name; | |
8060 } | |
8061 | |
8062 GaimConvPlacementFunc | |
8063 gaim_gtkconv_placement_get_fnc(const char *id) | |
8064 { | |
8065 ConvPlacementData *data; | |
8066 | |
8067 ensure_default_funcs(); | |
8068 | |
8069 data = get_conv_placement_data(id); | |
8070 | |
8071 if (data == NULL) | |
8072 return NULL; | |
8073 | |
8074 return data->fnc; | |
8075 } | |
8076 | |
8077 void | |
8078 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
8079 { | |
8080 g_return_if_fail(func != NULL); | |
8081 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8082 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8083 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8084 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8085 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8086 place_conv = NULL; |
11581 | 8087 } |
8088 | |
8089 GaimConvPlacementFunc | |
8090 gaim_gtkconv_placement_get_current_func(void) | |
8091 { | |
8092 return place_conv; | |
8093 } | |
8094 | |
8095 void | |
8096 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
8097 { | |
8098 if (place_conv) | |
8099 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8100 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8101 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8102 } |
12239 | 8103 |
8104 gboolean | |
8105 gaim_gtkconv_is_hidden(GaimGtkConversation *gtkconv) | |
8106 { | |
8107 g_return_val_if_fail(gtkconv != NULL, FALSE); | |
8108 | |
8109 return (gtkconv->win == hidden_convwin); | |
8110 } | |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8111 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8112 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8113 /* Algorithm from http://www.w3.org/TR/AERT#color-contrast */ |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
8114 static gboolean |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8115 color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast) |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8116 { |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8117 gulong fg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8118 gulong bg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8119 gulong br_diff; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8120 gulong col_diff; |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8121 int fred, fgreen, fblue, bred, bgreen, bblue; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8122 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8123 /* this algorithm expects colors between 0 and 255 for each of red green and blue. |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8124 * GTK on the other hand has values between 0 and 65535 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8125 * Err suggested I >> 8, which grabbed the high bits. |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8126 */ |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8127 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8128 fred = foreground.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8129 fgreen = foreground.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8130 fblue = foreground.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8131 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8132 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8133 bred = background.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8134 bgreen = background.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8135 bblue = background.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8136 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8137 fg_brightness = (fred * 299 + fgreen * 587 + fblue * 114) / 1000; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8138 bg_brightness = (bred * 299 + bgreen * 587 + bblue * 114) / 1000; |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8139 br_diff = abs(fg_brightness - bg_brightness); |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8140 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8141 col_diff = abs(fred - bred) + abs(fgreen - bgreen) + abs(fblue - bblue); |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8142 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8143 return ((col_diff > color_contrast) && (br_diff > brightness_contrast)); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8144 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8145 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8146 |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
8147 static GdkColor* |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8148 generate_nick_colors(guint *color_count, GdkColor background) |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8149 { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8150 guint numcolors = *color_count; |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8151 guint i = 0, j = 0; |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8152 GdkColor *colors = g_new(GdkColor, numcolors); |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8153 GdkColor nick_highlight; |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8154 GdkColor send_color; |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8155 time_t breakout_time; |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8156 |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8157 gdk_color_parse(HIGHLIGHT_COLOR, &nick_highlight); |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8158 gdk_color_parse(SEND_COLOR, &send_color); |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8159 |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8160 srand(background.red + background.green + background.blue + 1); |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8161 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8162 breakout_time = time(NULL) + 3; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8163 |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8164 /* first we look through the list of "good" colors: colors that differ from every other color in the |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8165 * list. only some of them will differ from the background color though. lets see if we can find |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8166 * numcolors of them that do |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8167 */ |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8168 while (i < numcolors && j < NUM_NICK_SEED_COLORS && time(NULL) < breakout_time) |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8169 { |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8170 GdkColor color = nick_seed_colors[j]; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8171 |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8172 if (color_is_visible(color, background, MIN_COLOR_CONTRAST, MIN_BRIGHTNESS_CONTRAST) && |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8173 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8174 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8175 { |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8176 colors[i] = color; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8177 i++; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8178 } |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8179 j++; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8180 } |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8181 |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8182 /* we might not have found numcolors in the last loop. if we did, we'll never enter this one. |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8183 * if we did not, lets just find some colors that don't conflict with the background. its |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8184 * expensive to find colors that not only don't conflict with the background, but also do not |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8185 * conflict with each other. |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8186 */ |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8187 while(i < numcolors && time(NULL) < breakout_time) |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8188 { |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8189 GdkColor color = { 0, rand() % 65536, rand() % 65536, rand() % 65536 }; |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8190 |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8191 gaim_debug(GAIM_DEBUG_WARNING, NULL, |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8192 "Looking for random colors to fill the list, I have found %i so far.\n",i); |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8193 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8194 if (color_is_visible(color, background, MIN_COLOR_CONTRAST, MIN_BRIGHTNESS_CONTRAST) && |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8195 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8196 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8197 { |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8198 colors[i] = color; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8199 i++; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8200 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8201 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8202 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8203 if (i < numcolors) { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8204 GdkColor *c = colors; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8205 gaim_debug(GAIM_DEBUG_WARNING, NULL, "Unable to generate enough random colors before timeout. %u colors found.\n", i); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8206 colors = g_memdup(c, i * sizeof(GdkColor)); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8207 g_free(c); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8208 *color_count = i; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8209 |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8210 } |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8211 |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8212 return colors; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8213 } |