Mercurial > pidgin.yaz
annotate src/gtkconv.c @ 12867:cf3540702d21
[gaim-migrate @ 15218]
A patch from Ranma42 in SF Bug #1220557, with lots of changes by me.
This merges gaim_conv_chat_remove_users and gaim_conv_chat_remove_user.
As I did with gaim_conv_chat_add_user and gaim_conv_chat_add_users,
gaim_conv_chat_remove_user is just a simple wrapper. The conversation UI op
chat_remove_user has similarly been removed, in favor of UIs only having to
implement one function to remove users.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sat, 14 Jan 2006 00:06:24 +0000 |
parents | 1096bdfef887 |
children | e9b0c90ce58a |
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); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
163 static char *item_factory_translate_func (const char *path, gpointer func_data); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
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")) { | |
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 { | |
743 gaim_notify_error(NULL, NULL, | |
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 { | |
763 gaim_notify_error(NULL, NULL, | |
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 { | |
769 gaim_notify_error(NULL, NULL, | |
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) { |
9504 | 945 gaim_notify_error(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 |
10849 | 975 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
976 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 977 |
978 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
979 } |
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 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
982 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
983 { |
11581 | 984 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
985 GaimConversation *conv; |
9917 | 986 GaimLogType type; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
987 GaimGtkBuddyList *gtkblist; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
988 GdkCursor *cursor; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
989 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
990 GaimAccount *account; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
991 GSList *buddies; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
992 GSList *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
993 |
11581 | 994 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
995 |
11338 | 996 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 997 type = GAIM_LOG_IM; |
11338 | 998 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 999 type = GAIM_LOG_CHAT; |
1000 else | |
1001 return; | |
1002 | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1003 gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1004 cursor = gdk_cursor_new(GDK_WATCH); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1005 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1006 gdk_window_set_cursor(gtkblist->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1007 gdk_window_set_cursor(win->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1008 gdk_cursor_unref(cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1009 while (gtk_events_pending()) |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1010 gtk_main_iteration(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1011 |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1012 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1013 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1014 |
10845 | 1015 buddies = gaim_find_buddies(account, name); |
1016 for (cur = buddies; cur != NULL; cur = cur->next) | |
1017 { | |
1018 GaimBlistNode *node = cur->data; | |
10846 | 1019 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 1020 { |
1021 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
1022 g_slist_free(buddies); | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1023 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1024 gdk_window_set_cursor(win->window->window, NULL); |
10845 | 1025 return; |
1026 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1027 } |
10845 | 1028 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1029 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1030 gaim_gtk_log_show(type, name, account); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1031 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1032 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1033 gdk_window_set_cursor(win->window->window, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1034 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1035 |
8974 | 1036 static void |
1037 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
1038 { | |
11581 | 1039 GaimGtkWindow *win = data; |
8974 | 1040 GaimConversation *conv; |
1041 GaimGtkConversation *gtkconv; | |
1042 | |
11581 | 1043 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 1044 gtkconv = GAIM_GTK_CONVERSATION(conv); |
1045 | |
1046 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1047 } | |
1048 | |
7295 | 1049 struct _search { |
1050 GaimGtkConversation *gtkconv; | |
1051 GtkWidget *entry; | |
1052 }; | |
1053 | |
7929 | 1054 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 1055 { |
7929 | 1056 switch (resp) { |
1057 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1058 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1059 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1060 break; |
1061 | |
1062 case GTK_RESPONSE_DELETE_EVENT: | |
1063 case GTK_RESPONSE_CLOSE: | |
1064 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1065 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1066 s->gtkconv->dialogs.search = NULL; | |
1067 g_free(s); | |
1068 break; | |
1069 } | |
7295 | 1070 } |
1071 | |
1072 static void | |
7751 | 1073 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1074 { |
11581 | 1075 GaimGtkWindow *gtkwin = data; |
1076 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1077 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1078 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1079 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1080 GTK_ICON_SIZE_DIALOG); |
7929 | 1081 GtkWidget *label; |
7295 | 1082 struct _search *s; |
1083 | |
7798 | 1084 if (gtkconv->dialogs.search) { |
1085 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1086 return; |
7798 | 1087 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1088 |
7295 | 1089 s = g_malloc(sizeof(struct _search)); |
1090 s->gtkconv = gtkconv; | |
7929 | 1091 |
1092 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1093 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1094 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1095 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1096 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1097 GTK_RESPONSE_OK); |
7929 | 1098 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1099 G_CALLBACK(do_search_cb), s); | |
1100 | |
11243 | 1101 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1102 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1103 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1104 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
|
1105 gtk_container_set_border_width( |
11243 | 1106 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1107 | |
1108 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1109 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1110 hbox); |
7929 | 1111 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1112 | |
1113 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1114 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1115 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1116 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1117 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1118 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1119 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1120 | |
1121 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1122 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1123 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1124 g_signal_connect(G_OBJECT(s->entry), "changed", |
1125 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1126 gtkconv->dialogs.search); | |
1127 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
|
1128 |
7295 | 1129 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1130 gtk_widget_grab_focus(s->entry); |
7295 | 1131 } |
1132 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1133 static void |
9468 | 1134 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1135 { | |
11581 | 1136 GaimGtkWindow *win = data; |
1137 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1138 |
11338 | 1139 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1140 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1141 } | |
1142 | |
1143 } | |
1144 | |
1145 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1146 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1147 { |
11581 | 1148 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1149 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1150 |
11581 | 1151 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
|
1152 |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1153 gaim_gtk_pounce_editor_show(gaim_conversation_get_account(conv), |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1154 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1155 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1156 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1157 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1159 { |
11581 | 1160 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1161 GaimGtkConversation *gtkconv; |
8756 | 1162 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1163 |
11581 | 1164 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1165 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1166 | |
1167 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1168 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1169 } |
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 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1172 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1173 { |
11581 | 1174 GaimGtkWindow *win = data; |
8756 | 1175 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1176 GaimGtkConversation *gtkconv; |
8756 | 1177 GtkIMHtmlToolbar *toolbar; |
1178 | |
11581 | 1179 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1180 conv = gtkconv->active_conv; | |
8756 | 1181 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1182 | |
1183 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1184 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1185 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1186 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1187 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1188 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1189 { |
11581 | 1190 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1191 GaimConversation *conv; |
7879 | 1192 GaimAccount *account; |
1193 const char *name; | |
1194 | |
11581 | 1195 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1196 account = gaim_conversation_get_account(conv); |
1197 name = gaim_conversation_get_name(conv); | |
1198 | |
11338 | 1199 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1200 GaimBuddy *b; |
1201 | |
1202 b = gaim_find_buddy(account, name); | |
1203 if (b != NULL) | |
9730 | 1204 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1205 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1206 GaimChat *c; |
1207 | |
1208 c = gaim_blist_find_chat(account, name); | |
1209 if (c != NULL) | |
9730 | 1210 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1212 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1216 { |
11581 | 1217 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1218 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1219 |
11581 | 1220 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1221 |
10810 | 1222 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1223 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1224 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1225 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1226 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1227 { |
11581 | 1228 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1229 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1230 |
11581 | 1231 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1232 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1233 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1234 } |
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 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1237 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1238 { |
11581 | 1239 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1240 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1241 |
11581 | 1242 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1243 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1244 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1245 } |
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 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1248 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1249 { |
11581 | 1250 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1251 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1252 |
11581 | 1253 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1254 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1255 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1256 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1257 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1258 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1259 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1260 { |
11581 | 1261 GaimGtkWindow *win = data; |
1262 | |
1263 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
|
1264 } |
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 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1267 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1268 { |
11581 | 1269 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1270 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1271 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1272 |
11581 | 1273 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1274 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1275 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1276 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1277 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1278 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
|
1279 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1280 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1281 return; |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1282 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1283 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1284 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1285 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1286 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1287 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1288 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1289 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1290 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1291 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1292 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1293 } |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1294 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1295 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1296 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1297 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1298 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1299 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1300 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1301 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1302 /* 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
|
1303 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1304 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1305 } |
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 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1308 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1309 { |
11581 | 1310 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1311 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1312 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1313 |
11581 | 1314 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1315 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1316 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1317 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1318 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1319 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1320 |
10377 | 1321 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1322 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
|
1323 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1324 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1325 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1326 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1327 { |
11581 | 1328 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1329 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1330 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1331 |
11581 | 1332 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1333 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1334 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1335 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1336 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1337 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1338 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1339 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1340 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1341 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1342 |
7961 | 1343 static void |
9188 | 1344 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1345 { | |
11581 | 1346 GaimGtkWindow *win = data; |
9188 | 1347 GaimConversation *conv; |
1348 GaimGtkConversation *gtkconv; | |
1349 | |
11581 | 1350 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1351 |
1352 if (!conv) | |
1353 return; | |
1354 | |
1355 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1356 | |
12188 | 1357 gaim_prefs_set_bool("/gaim/gtk/conversations/show_timestamps", |
9188 | 1358 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
1359 } | |
1360 | |
1361 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1362 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1363 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1364 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1365 GaimAccount *account; |
1366 GaimConnection *gc; | |
7961 | 1367 GaimPluginProtocolInfo *prpl_info = NULL; |
1368 char *real_who; | |
1369 | |
1370 account = gaim_conversation_get_account(conv); | |
10431 | 1371 g_return_if_fail(account != NULL); |
1372 | |
1373 gc = gaim_account_get_connection(account); | |
1374 g_return_if_fail(gc != NULL); | |
1375 | |
1376 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1377 | |
1378 if (prpl_info && prpl_info->get_cb_real_name) | |
1379 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1380 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1381 else | |
1382 real_who = g_strdup(who); | |
1383 | |
1384 if(!real_who) | |
1385 return; | |
1386 | |
10431 | 1387 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1388 |
1389 g_free(real_who); | |
1390 } | |
1391 | |
1392 static void | |
10810 | 1393 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1394 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1395 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1396 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1397 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1398 GtkTreeSelection *sel; |
9554 | 1399 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1401 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1402 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1403 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1404 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1405 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1406 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1407 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
|
1408 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1409 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1410 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1411 chat_do_im(gtkconv, name); |
9554 | 1412 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1413 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1414 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1415 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1416 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1417 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1418 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1419 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1420 GaimConvChat *chat; |
11869 | 1421 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1422 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1423 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1424 GtkTreeSelection *sel; |
10504 | 1425 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1426 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1427 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1428 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1429 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1430 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1431 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1432 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
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 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1435 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1436 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1437 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1438 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1439 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1440 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
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 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1443 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1444 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1445 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1446 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1447 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1448 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1449 |
11869 | 1450 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1451 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1452 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1453 } |
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 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1456 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1457 { |
1458 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1459 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1460 chat_do_im(gtkconv, who); |
5908
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 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1463 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1464 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1465 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1466 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1467 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1468 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1469 | |
1470 serv_send_file(gc, who, NULL); | |
1471 } | |
1472 | |
1473 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1474 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
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 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1477 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1478 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1479 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1480 chat_do_info(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1481 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1482 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1483 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1484 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1485 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1486 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1487 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1488 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1489 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1490 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1491 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1492 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1493 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1494 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1495 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1496 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1497 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1498 * 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
|
1499 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1500 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1501 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1502 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1503 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1504 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1505 } |
5908
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 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1508 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1509 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1510 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1511 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1512 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1513 GaimAccount *account; |
6695 | 1514 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1515 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1516 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1517 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1518 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1519 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1520 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1521 if (b != NULL) |
9730 | 1522 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1523 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1524 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1525 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1526 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1527 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1528 |
8143 | 1529 static GtkWidget * |
10504 | 1530 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1531 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1532 { | |
1533 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1534 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1535 gboolean is_me = FALSE; |
8143 | 1536 GtkWidget *button; |
1537 | |
1538 /* | |
1539 * If a menu already exists, destroy it before creating a new one, | |
1540 * thus freeing-up the memory it occupied. | |
1541 */ | |
1542 if (menu) | |
1543 gtk_widget_destroy(menu); | |
1544 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1545 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1546 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1547 |
8143 | 1548 menu = gtk_menu_new(); |
1549 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1550 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1551 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1552 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
|
1553 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
|
1554 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1555 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1556 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1557 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1558 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1559 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1560 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
|
1561 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1562 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1563 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
|
1564 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
|
1565 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1566 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1567 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1568 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1569 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1570 } |
9498 | 1571 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1572 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1573 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
|
1574 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1575 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1576 } |
1577 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1578 if (prpl_info->get_cb_away) { |
10221 | 1579 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
|
1580 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1581 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1582 } |
1583 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1584 if (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1585 if (gaim_find_buddy(gc->account, who)) |
10221 | 1586 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
|
1587 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1588 else |
10221 | 1589 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
|
1590 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1591 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1592 } |
1593 | |
1594 return menu; | |
1595 } | |
1596 | |
1597 | |
1598 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1599 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1600 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1601 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1602 GaimPluginProtocolInfo *prpl_info = NULL; |
1603 GaimGtkChatPane *gtkchat; | |
1604 GaimConnection *gc; | |
1605 GaimAccount *account; | |
1606 GtkTreeSelection *sel; | |
1607 GtkTreeIter iter; | |
1608 GtkTreeModel *model; | |
1609 GtkWidget *menu; | |
1610 gchar *who; | |
1611 | |
1612 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1613 gtkchat = gtkconv->u.chat; | |
1614 account = gaim_conversation_get_account(conv); | |
1615 gc = account->gc; | |
1616 | |
1617 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1618 | |
1619 if (gc != NULL) | |
1620 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1621 | |
1622 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1623 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1624 return FALSE; | |
1625 | |
9498 | 1626 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1627 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1628 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1629 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1630 0, GDK_CURRENT_TIME); |
10504 | 1631 g_free(who); |
8143 | 1632 |
1633 return TRUE; | |
1634 } | |
1635 | |
1636 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1637 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1638 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1639 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1640 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1641 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1642 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1643 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1644 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1645 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1646 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1647 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1648 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1649 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1650 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1651 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1652 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1653 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1654 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1655 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1656 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1657 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1658 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1659 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
|
1660 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1661 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1662 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1663 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1664 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1665 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1666 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1669 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1670 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1671 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1672 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
|
1673 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1674 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1675 chat_do_im(gtkconv, who); |
7398 | 1676 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1677 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1678 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1679 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1680 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1681 |
10504 | 1682 g_free(who); |
1683 gtk_tree_path_free(path); | |
1684 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1685 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1686 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1687 |
8133 | 1688 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1689 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1690 { |
10827 | 1691 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1692 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1693 int index, i, total, found = 0; |
8133 | 1694 |
11581 | 1695 win = gtkconv->win; |
1696 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1697 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1698 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1699 /* 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
|
1700 for (i = forward ? index + 1 : index - 1; |
11581 | 1701 !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
|
1702 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1703 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1704 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1705 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1706 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1707 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1708 found = 1; |
8133 | 1709 } |
11252 | 1710 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1711 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1712 /* 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
|
1713 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1714 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1715 (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
|
1716 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1717 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1718 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1719 found = 1; |
8133 | 1720 } |
10827 | 1721 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1722 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1723 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1724 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1725 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1726 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1727 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1728 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1729 } |
11581 | 1730 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1731 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1732 } |
8133 | 1733 } |
1734 | |
10827 | 1735 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1736 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1737 } |
1738 | |
4359 | 1739 static gboolean |
8105 | 1740 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1741 { |
11581 | 1742 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1743 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1744 GaimGtkConversation *gtkconv; |
8105 | 1745 int curconv; |
1746 | |
10810 | 1747 gtkconv = (GaimGtkConversation *)data; |
10849 | 1748 conv = gtkconv->active_conv; |
11581 | 1749 win = gtkconv->win; |
1750 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1751 |
8105 | 1752 /* If CTRL was held down... */ |
1753 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1754 switch (event->keyval) { |
1755 case GDK_Up: | |
1756 if (!conv->send_history) | |
1757 break; | |
1758 | |
1759 if (!conv->send_history->prev) { | |
1760 GtkTextIter start, end; | |
1761 | |
1762 if (conv->send_history->data) | |
1763 g_free(conv->send_history->data); | |
1764 | |
1765 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1766 &start); | |
1767 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1768 | |
1769 conv->send_history->data = | |
8506 | 1770 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1771 } |
8677 | 1772 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1773 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1774 GObject *object; |
8677 | 1775 GtkTextIter iter; |
1776 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1777 |
1778 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1779 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1780 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1781 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1782 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
|
1783 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1784 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1785 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1786 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1787 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
|
1788 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1789 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1790 |
8061 | 1791 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1792 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1793 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1794 0, NULL); |
8677 | 1795 /* this is mainly just a hack so the formatting at the |
1796 * cursor gets picked up. */ | |
1797 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1798 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1799 } |
1800 | |
8105 | 1801 return TRUE; |
4359 | 1802 break; |
1803 | |
1804 case GDK_Down: | |
1805 if (!conv->send_history) | |
1806 break; | |
1807 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1808 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1809 GObject *object; |
8677 | 1810 GtkTextIter iter; |
1811 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1812 |
4359 | 1813 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1814 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1815 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1816 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1817 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
|
1818 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1819 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1820 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1821 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1822 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
|
1823 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1824 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1825 |
8105 | 1826 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1827 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1828 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1829 0, NULL); |
8677 | 1830 /* this is mainly just a hack so the formatting at the |
1831 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1832 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1833 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1834 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1835 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1836 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1837 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1838 } |
4359 | 1839 } |
1840 | |
8105 | 1841 return TRUE; |
4359 | 1842 break; |
8105 | 1843 |
8108 | 1844 case GDK_Page_Down: |
8143 | 1845 case ']': |
11581 | 1846 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1847 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1848 else |
11581 | 1849 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1850 return TRUE; |
1851 break; | |
1852 | |
8108 | 1853 case GDK_Page_Up: |
8143 | 1854 case '[': |
11581 | 1855 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1856 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1857 else |
11581 | 1858 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1859 return TRUE; |
1860 break; | |
1861 | |
8108 | 1862 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1863 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1864 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1865 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1866 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1867 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1868 } |
8108 | 1869 |
1870 return TRUE; | |
1871 break; | |
1872 | |
11252 | 1873 case GDK_comma: |
11581 | 1874 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1875 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1876 curconv - 1); |
1877 break; | |
1878 | |
1879 case GDK_period: | |
11581 | 1880 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1881 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1882 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1883 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1884 #else |
1885 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1886 #endif | |
11252 | 1887 break; |
1888 | |
8105 | 1889 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1890 } |
8758 | 1891 |
8105 | 1892 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1893 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1894 { |
10864 | 1895 if (event->keyval > '0' && event->keyval <= '9') |
1896 { | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1897 guint switchto = event->keyval - '1'; |
11581 | 1898 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1899 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1900 |
1901 return TRUE; | |
1902 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1903 } |
8758 | 1904 |
8105 | 1905 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1906 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1907 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1908 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1909 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1910 case GDK_Tab: |
9605 | 1911 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1912 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1913 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1914 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1915 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1916 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1917 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1918 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1919 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1920 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1921 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1922 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1923 |
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 } |
4359 | 1926 return FALSE; |
1927 } | |
1928 | |
1929 /* | |
1930 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1931 * 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
|
1932 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1933 * 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
|
1934 * going all the way down to the notebook. I suspect a bug in |
4359 | 1935 * GtkTextView, but I'm not ready to point any fingers yet. |
1936 */ | |
1937 static gboolean | |
1938 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1939 { | |
1940 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1941 /* Right single click */ | |
1942 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1943 | |
1944 return TRUE; | |
1945 } | |
1946 | |
1947 return FALSE; | |
1948 } | |
1949 | |
8173 | 1950 /* |
1951 * If someone tries to type into the conversation backlog of a | |
1952 * conversation window then we yank focus from the conversation backlog | |
1953 * and give it to the text entry box so that people can type | |
1954 * all the live long day and it will get entered into the entry box. | |
1955 */ | |
6057 | 1956 static gboolean |
8105 | 1957 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1958 { |
1959 GaimGtkConversation *gtkconv = data; | |
1960 | |
8237 | 1961 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1962 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1963 (event->keyval == GDK_F10) || |
1964 (event->keyval == GDK_Shift_L) || | |
1965 (event->keyval == GDK_Shift_R) || | |
1966 (event->keyval == GDK_Escape) || | |
8177 | 1967 (event->keyval == GDK_Up) || |
1968 (event->keyval == GDK_Down) || | |
1969 (event->keyval == GDK_Left) || | |
8191 | 1970 (event->keyval == GDK_Right) || |
1971 (event->keyval == GDK_Home) || | |
9297 | 1972 (event->keyval == GDK_End) || |
1973 (event->keyval == GDK_Tab) || | |
1974 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1975 return FALSE; |
1976 | |
1977 if (event->type == GDK_KEY_RELEASE) | |
1978 gtk_widget_grab_focus(gtkconv->entry); | |
1979 | |
1980 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1981 | |
1982 return TRUE; | |
6057 | 1983 } |
1984 | |
4359 | 1985 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1986 gaim_gtkconv_set_active_conversation(GaimConversation *conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1987 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1988 GaimGtkConversation *gtkconv; |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
1989 const char *protocol_name; |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1990 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1991 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1992 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1993 gtkconv = GAIM_GTK_CONVERSATION(conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1994 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1995 if (gtkconv->active_conv == conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1996 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1997 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1998 gaim_conversation_close_logs(gtkconv->active_conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1999 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2000 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2001 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2002 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2003 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
|
2004 |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2005 protocol_name = gaim_account_get_protocol_name(conv->account); |
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2006 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), protocol_name); |
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2007 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol_name); |
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2008 |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
2009 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
|
2010 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2011 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
2012 void |
11604 | 2013 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
2014 { | |
2015 GaimGtkConversation *gtkconv; | |
2016 | |
2017 g_return_if_fail(conv != NULL); | |
2018 | |
2019 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2020 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2021 gaim_gtkconv_set_active_conversation(conv); |
11604 | 2022 |
2023 gray_stuff_out(gtkconv); | |
2024 update_typing_icon(gtkconv); | |
2025 | |
2026 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
2027 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
2028 } | |
2029 | |
2030 static void | |
4673 | 2031 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 2032 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2033 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 2034 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2035 GaimConversation *conv; |
4359 | 2036 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2037 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2038 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2039 |
11594 | 2040 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 2041 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 2042 } |
2043 | |
2044 static void | |
2045 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
2046 gchar *new_text, gint new_text_length, gpointer user_data) | |
2047 { | |
10810 | 2048 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2049 GaimConversation *conv; | |
2050 | |
2051 g_return_if_fail(gtkconv != NULL); | |
11508 | 2052 |
10810 | 2053 conv = gtkconv->active_conv; |
4359 | 2054 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2055 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2056 return; |
2057 | |
10810 | 2058 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2059 gtk_text_iter_is_end(position))); | |
4359 | 2060 } |
2061 | |
2062 static void | |
2063 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2064 GtkTextIter *end_pos, gpointer user_data) | |
2065 { | |
10810 | 2066 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2067 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2068 GaimConvIm *im; |
4359 | 2069 |
10810 | 2070 g_return_if_fail(gtkconv != NULL); |
11508 | 2071 |
10810 | 2072 conv = gtkconv->active_conv; |
4359 | 2073 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2074 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2075 return; |
2076 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2077 im = GAIM_CONV_IM(conv); |
4359 | 2078 |
2079 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2080 | |
2081 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2082 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2083 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2084 |
2085 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2086 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2087 GAIM_NOT_TYPING); |
4359 | 2088 } |
2089 else { | |
2090 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2091 got_typing_keypress(gtkconv, FALSE); |
4359 | 2092 } |
2093 } | |
2094 | |
8189 | 2095 /************************************************************************** |
2096 * A bunch of buddy icon functions | |
2097 **************************************************************************/ | |
11581 | 2098 GdkPixbuf * |
2099 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2100 { |
10116 | 2101 GaimAccount *account = NULL; |
2102 const char *name = NULL; | |
7143 | 2103 GdkPixbuf *status = NULL; |
2104 | |
10116 | 2105 g_return_val_if_fail(conv != NULL, NULL); |
2106 | |
2107 account = gaim_conversation_get_account(conv); | |
2108 name = gaim_conversation_get_name(conv); | |
2109 | |
2110 g_return_val_if_fail(account != NULL, NULL); | |
2111 g_return_val_if_fail(name != NULL, NULL); | |
2112 | |
11338 | 2113 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2114 GaimBuddy *b = gaim_find_buddy(account, name); |
2115 if (b != NULL) { | |
2116 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2117 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2118 } |
2119 } | |
2120 | |
2121 if (!status) { | |
2122 GdkPixbuf *pixbuf; | |
10884 | 2123 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2124 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2125 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2126 { |
7143 | 2127 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2128 GDK_INTERP_BILINEAR); | |
2129 g_object_unref(pixbuf); | |
2130 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2131 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2132 status = pixbuf; |
7143 | 2133 } |
2134 return status; | |
2135 } | |
2136 | |
8189 | 2137 static void |
2138 update_tab_icon(GaimConversation *conv) | |
2139 { | |
2140 GaimGtkConversation *gtkconv; | |
11581 | 2141 GaimGtkWindow *win; |
8189 | 2142 GaimAccount *account; |
2143 const char *name; | |
2144 GdkPixbuf *status = NULL; | |
2145 | |
10116 | 2146 g_return_if_fail(conv != NULL); |
2147 | |
8189 | 2148 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2149 win = gtkconv->win; |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2150 if (conv != gtkconv->active_conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2151 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2152 |
8189 | 2153 name = gaim_conversation_get_name(conv); |
2154 account = gaim_conversation_get_account(conv); | |
2155 | |
11581 | 2156 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2157 |
10116 | 2158 g_return_if_fail(status != NULL); |
2159 | |
8189 | 2160 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2161 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2162 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2163 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2164 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2165 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2166 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2167 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2168 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2169 { |
11581 | 2170 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2171 | |
2172 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2173 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2174 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2175 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2176 } |
8189 | 2177 } |
2178 | |
2179 static gboolean | |
2180 redraw_icon(gpointer data) | |
2181 { | |
10810 | 2182 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2183 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2184 GaimAccount *account; |
2185 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2186 |
2187 GdkPixbuf *buf; | |
2188 GdkPixbuf *scale; | |
2189 GdkPixmap *pm; | |
2190 GdkBitmap *bm; | |
2191 gint delay; | |
9318 | 2192 int scale_width, scale_height; |
8189 | 2193 |
2194 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2195 account = gaim_conversation_get_account(conv); |
2196 if(account && account->gc) | |
2197 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2198 |
2199 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2200 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2201 | |
10483 | 2202 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2203 NULL, &scale_width, &scale_height); |
2204 | |
2205 /* this code is ugly, and scares me */ | |
8189 | 2206 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2207 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2208 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2209 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2210 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2211 GDK_INTERP_BILINEAR); |
8189 | 2212 |
2213 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2214 g_object_unref(G_OBJECT(scale)); | |
2215 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2216 g_object_unref(G_OBJECT(pm)); | |
2217 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2218 | |
2219 if (bm) | |
2220 g_object_unref(G_OBJECT(bm)); | |
2221 | |
9131 | 2222 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2223 |
2224 if (delay < 100) | |
9131 | 2225 delay = 100; |
2226 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2227 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2228 |
2229 return FALSE; | |
2230 } | |
2231 | |
2232 static void | |
10810 | 2233 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2234 { |
2235 int delay; | |
2236 | |
8228 | 2237 if (gtkconv->u.im->anim == NULL) |
2238 return; | |
2239 | |
8202 | 2240 if (gtkconv->u.im->icon_timer != 0) |
2241 return; | |
2242 | |
8189 | 2243 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2244 return; | |
2245 | |
10639 | 2246 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2247 | |
2248 if (delay < 100) | |
2249 delay = 100; | |
2250 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2251 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2252 } |
2253 | |
2254 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2255 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2256 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2257 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2258 GaimGtkWindow *gtkwin; |
2259 | |
2260 g_return_if_fail(conv != NULL); | |
2261 | |
9887 | 2262 if (gtkconv->u.im->icon_container != NULL) |
2263 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2264 |
2265 if (gtkconv->u.im->anim != NULL) | |
2266 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2267 | |
2268 if (gtkconv->u.im->icon_timer != 0) | |
2269 g_source_remove(gtkconv->u.im->icon_timer); | |
2270 | |
2271 if (gtkconv->u.im->iter != NULL) | |
2272 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2273 | |
2274 gtkconv->u.im->icon_timer = 0; | |
2275 gtkconv->u.im->icon = NULL; | |
2276 gtkconv->u.im->anim = NULL; | |
2277 gtkconv->u.im->iter = NULL; | |
10456 | 2278 gtkconv->u.im->icon_container = NULL; |
9687 | 2279 gtkconv->u.im->show_icon = FALSE; |
10456 | 2280 |
11581 | 2281 gtkwin = gtkconv->win; |
10456 | 2282 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2283 } |
2284 | |
9497 | 2285 static void |
9504 | 2286 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2287 { |
10810 | 2288 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2289 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2290 FILE *fp; |
2291 GaimBuddyIcon *icon; | |
2292 const void *data; | |
2293 size_t len; | |
2294 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2295 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2296 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2297 return; |
2298 } | |
2299 | |
2300 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2301 data = gaim_buddy_icon_get_data(icon, &len); | |
2302 | |
2303 if ((len <= 0) || (data == NULL)) { | |
9504 | 2304 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2305 return; |
2306 } | |
2307 | |
2308 fwrite(data, 1, len, fp); | |
2309 fclose(fp); | |
2310 } | |
2311 | |
2312 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2313 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2314 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2315 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2316 const gchar *ext; |
9497 | 2317 gchar *buf; |
2318 | |
2319 g_return_if_fail(conv != NULL); | |
9504 | 2320 |
10953 | 2321 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2322 if (ext == NULL) | |
2323 ext = "icon"; | |
2324 | |
2325 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2326 |
2327 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2328 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2329 |
2330 g_free(buf); | |
2331 } | |
2332 | |
11581 | 2333 static void |
2334 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2335 { | |
2336 if (gtkconv->u.im->icon_timer != 0) | |
2337 g_source_remove(gtkconv->u.im->icon_timer); | |
2338 | |
2339 gtkconv->u.im->icon_timer = 0; | |
2340 } | |
2341 | |
2342 | |
2343 static void | |
2344 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2345 { | |
2346 gtkconv->u.im->animate = | |
2347 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2348 | |
2349 if (gtkconv->u.im->animate) | |
2350 start_anim(NULL, gtkconv); | |
2351 else | |
2352 stop_anim(NULL, gtkconv); | |
2353 } | |
2354 | |
8189 | 2355 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2356 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2357 { |
2358 static GtkWidget *menu = NULL; | |
2359 GtkWidget *button; | |
2360 | |
2361 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2362 return FALSE; | |
2363 | |
2364 /* | |
2365 * If a menu already exists, destroy it before creating a new one, | |
2366 * thus freeing-up the memory it occupied. | |
2367 */ | |
2368 if (menu != NULL) | |
2369 gtk_widget_destroy(menu); | |
2370 | |
2371 menu = gtk_menu_new(); | |
2372 | |
2373 if (gtkconv->u.im->anim && | |
2374 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2375 { | |
2376 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2377 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2378 gtkconv->u.im->icon_timer); |
2379 } | |
2380 | |
2381 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2382 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2383 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2384 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2385 gtk_widget_show(button); | |
2386 | |
2387 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
|
2388 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2389 0, 0, NULL); |
2390 | |
2391 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2392 | |
2393 return TRUE; | |
2394 } | |
10456 | 2395 |
2396 static void | |
2397 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2398 { | |
11581 | 2399 GaimGtkWindow *win = data; |
10456 | 2400 GaimConversation *conv; |
2401 GaimGtkConversation *gtkconv; | |
2402 gboolean active; | |
2403 | |
11581 | 2404 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2405 |
2406 if (!conv) | |
2407 return; | |
2408 | |
11338 | 2409 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2410 |
2411 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2412 | |
2413 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2414 gtkconv->u.im->show_icon = active; | |
2415 if (active) | |
2416 gaim_gtkconv_update_buddy_icon(conv); | |
2417 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2418 remove_icon(gtkconv); |
10456 | 2419 } |
2420 | |
8189 | 2421 /************************************************************************** |
2422 * End of the bunch of buddy icon functions | |
2423 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2424 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2425 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2426 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2427 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2428 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2429 if(gtkconv->win==hidden_convwin) { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
2430 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2431 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2432 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2433 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2434 gaim_gtkconv_set_active_conversation(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2435 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2436 gaim_gtk_conv_window_raise(gtkconv->win); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2437 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2438 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2439 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2440 GList * |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2441 gaim_gtk_conversations_find_unseen_list(GaimConversationType type, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2442 GaimUnseenState min_state, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2443 gboolean hidden_only, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2444 guint max_count) |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2445 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2446 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2447 GList *r = NULL; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2448 guint c = 0; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2449 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2450 if (type == GAIM_CONV_TYPE_IM) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2451 l = gaim_get_ims(); |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2452 } else if (type == GAIM_CONV_TYPE_CHAT) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2453 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2454 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2455 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2456 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2457 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2458 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
|
2459 GaimConversation *conv = (GaimConversation*)l->data; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2460 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2461 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2462 if(gtkconv->active_conv != conv) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2463 continue; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2464 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2465 if (gtkconv->unseen_state >= min_state |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2466 && (!hidden_only || |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2467 (hidden_only && gtkconv->win == hidden_convwin))) { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2468 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2469 r = g_list_prepend(r, conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2470 c++; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2471 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2472 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2473 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2474 return r; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2475 } |
8189 | 2476 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2477 static void |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2478 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2479 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2480 g_return_if_fail(conv != NULL); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2481 gaim_gtkconv_present_conversation(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2482 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2483 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2484 guint |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2485 gaim_gtk_conversations_fill_menu(GtkWidget *menu, GList *convs) |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2486 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2487 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2488 guint ret=0; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2489 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2490 g_return_val_if_fail(menu != NULL, 0); |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2491 g_return_val_if_fail(convs != NULL, 0); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2492 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2493 for (l = convs; l != NULL ; l = l->next) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2494 GaimConversation *conv = (GaimConversation*)l->data; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2495 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2496 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2497 GtkWidget *icon = gtk_image_new(); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2498 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2499 GtkWidget *item; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2500 gchar *text = g_strdup_printf("%s (%d)", |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2501 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2502 gtkconv->unseen_count); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2503 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2504 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2505 g_object_unref(pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2506 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2507 item = gtk_image_menu_item_new_with_label(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2508 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
|
2509 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
|
2510 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2511 g_free(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2512 ret++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2513 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2514 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2515 return ret; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2516 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2517 |
11581 | 2518 GaimGtkWindow * |
2519 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2520 { | |
2521 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2522 return gtkconv->win; | |
2523 } | |
2524 | |
2525 static GtkItemFactoryEntry menu_items[] = | |
2526 { | |
2527 /* Conversation menu */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2528 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>", NULL }, |
11581 | 2529 |
2530 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2531 0, "<StockItem>", GAIM_STOCK_IM }, | |
2532 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2533 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2534 |
2535 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2536 "<StockItem>", GTK_STOCK_FIND }, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2537 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", GAIM_STOCK_LOG }, |
11581 | 2538 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2539 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
12240 | 2540 { N_("/Conversation/Clea_r"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
11581 | 2541 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2542 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2543 |
2544 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2545 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2546 0, "<StockItem>", GAIM_STOCK_POUNCE }, |
11581 | 2547 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2548 "<StockItem>", GAIM_STOCK_INFO }, | |
2549 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2550 "<StockItem>", GAIM_STOCK_INVITE }, | |
2551 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2552 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2553 |
2554 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2555 "<StockItem>", GAIM_STOCK_EDIT }, | |
2556 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2557 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2558 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2559 "<StockItem>", GTK_STOCK_ADD }, | |
2560 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2561 "<StockItem>", GTK_STOCK_REMOVE }, | |
2562 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2563 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2564 |
2565 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2566 "<StockItem>", GAIM_STOCK_LINK }, | |
2567 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2568 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2569 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2570 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2571 |
2572 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2573 "<StockItem>", GTK_STOCK_CLOSE }, | |
2574 | |
2575 /* Options */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2576 { N_("/_Options"), NULL, NULL, 0, "<Branch>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2577 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2578 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2579 { 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
|
2580 { "/Options/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2581 { 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
|
2582 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>", NULL }, |
11581 | 2583 }; |
2584 | |
2585 static const int menu_item_count = | |
2586 sizeof(menu_items) / sizeof(*menu_items); | |
2587 | |
2588 static char * | |
2589 item_factory_translate_func (const char *path, gpointer func_data) | |
2590 { | |
2591 return _((char *)path); | |
2592 } | |
2593 | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2594 static void |
12816 | 2595 sound_method_pref_changed_cb(const char *name, GaimPrefType type, |
2596 gconstpointer value, gpointer data) | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2597 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2598 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2599 const char *method = value; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2600 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2601 if (!strcmp(method, "none")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2602 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2603 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
|
2604 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2605 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2606 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2607 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2608 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2609 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2610 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2611 if (gtkconv != NULL) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2612 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
|
2613 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2614 gtk_widget_set_sensitive(win->menu.sounds, TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2615 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2616 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2617 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2618 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2619 static void |
12816 | 2620 show_buddy_icons_pref_changed_cb(const char *name, GaimPrefType type, |
2621 gconstpointer value, gpointer data) | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2622 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2623 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2624 gboolean show_icons = GPOINTER_TO_INT(value); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2625 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2626 if (!show_icons) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2627 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2628 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
|
2629 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2630 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2631 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2632 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2633 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2634 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2635 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2636 if (gtkconv != NULL) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2637 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
|
2638 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2639 gtk_widget_set_sensitive(win->menu.show_icon, TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2640 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2641 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2642 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2643 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2644 |
11581 | 2645 static GtkWidget * |
2646 setup_menubar(GaimGtkWindow *win) | |
2647 { | |
2648 GtkAccelGroup *accel_group; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2649 const char *method; |
11581 | 2650 |
2651 accel_group = gtk_accel_group_new (); | |
2652 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2653 g_object_unref(accel_group); | |
2654 | |
2655 win->menu.item_factory = | |
2656 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2657 | |
2658 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2659 item_factory_translate_func, | |
2660 NULL, NULL); | |
2661 | |
2662 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2663 menu_items, win); | |
2664 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2665 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2666 | |
2667 | |
2668 win->menu.menubar = | |
2669 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2670 | |
2671 | |
2672 win->menu.view_log = | |
2673 gtk_item_factory_get_widget(win->menu.item_factory, | |
2674 N_("/Conversation/View Log")); | |
2675 | |
2676 /* --- */ | |
2677 | |
2678 win->menu.send_file = | |
2679 gtk_item_factory_get_widget(win->menu.item_factory, | |
2680 N_("/Conversation/Send File...")); | |
2681 | |
2682 win->menu.add_pounce = | |
2683 gtk_item_factory_get_widget(win->menu.item_factory, | |
2684 N_("/Conversation/Add Buddy Pounce...")); | |
2685 | |
2686 /* --- */ | |
2687 | |
2688 win->menu.get_info = | |
2689 gtk_item_factory_get_widget(win->menu.item_factory, | |
2690 N_("/Conversation/Get Info")); | |
2691 | |
2692 win->menu.invite = | |
2693 gtk_item_factory_get_widget(win->menu.item_factory, | |
2694 N_("/Conversation/Invite...")); | |
2695 | |
2696 /* --- */ | |
2697 | |
2698 win->menu.alias = | |
2699 gtk_item_factory_get_widget(win->menu.item_factory, | |
2700 N_("/Conversation/Alias...")); | |
2701 | |
2702 win->menu.block = | |
2703 gtk_item_factory_get_widget(win->menu.item_factory, | |
2704 N_("/Conversation/Block...")); | |
2705 | |
2706 win->menu.add = | |
2707 gtk_item_factory_get_widget(win->menu.item_factory, | |
2708 N_("/Conversation/Add...")); | |
2709 | |
2710 win->menu.remove = | |
2711 gtk_item_factory_get_widget(win->menu.item_factory, | |
2712 N_("/Conversation/Remove...")); | |
2713 | |
2714 /* --- */ | |
2715 | |
2716 win->menu.insert_link = | |
2717 gtk_item_factory_get_widget(win->menu.item_factory, | |
2718 N_("/Conversation/Insert Link...")); | |
2719 | |
2720 win->menu.insert_image = | |
2721 gtk_item_factory_get_widget(win->menu.item_factory, | |
2722 N_("/Conversation/Insert Image...")); | |
2723 | |
2724 /* --- */ | |
2725 | |
2726 win->menu.logging = | |
2727 gtk_item_factory_get_widget(win->menu.item_factory, | |
2728 N_("/Options/Enable Logging")); | |
2729 win->menu.sounds = | |
2730 gtk_item_factory_get_widget(win->menu.item_factory, | |
2731 N_("/Options/Enable Sounds")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2732 method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2733 if (!strcmp(method, "none")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2734 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2735 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
|
2736 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2737 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2738 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2739 gaim_prefs_connect_callback(win, "/gaim/gtk/sound/method", |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2740 sound_method_pref_changed_cb, win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2741 |
11581 | 2742 win->menu.show_formatting_toolbar = |
2743 gtk_item_factory_get_widget(win->menu.item_factory, | |
2744 N_("/Options/Show Formatting Toolbars")); | |
2745 win->menu.show_timestamps = | |
2746 gtk_item_factory_get_widget(win->menu.item_factory, | |
2747 N_("/Options/Show Timestamps")); | |
2748 win->menu.show_icon = | |
2749 gtk_item_factory_get_widget(win->menu.item_factory, | |
2750 N_("/Options/Show Buddy Icon")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2751 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
|
2752 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2753 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
|
2754 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2755 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2756 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2757 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
|
2758 show_buddy_icons_pref_changed_cb, win); |
11581 | 2759 |
2760 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2761 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2762 win->menu.tray); | |
2763 gtk_widget_show(win->menu.tray); | |
2764 | |
2765 gtk_widget_show(win->menu.menubar); | |
2766 | |
2767 return win->menu.menubar; | |
2768 } | |
2769 | |
4359 | 2770 |
2771 /************************************************************************** | |
2772 * Utility functions | |
2773 **************************************************************************/ | |
2774 | |
2775 static void | |
10810 | 2776 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2777 { |
10810 | 2778 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2779 GaimConvIm *im; |
4685 | 2780 |
4359 | 2781 /* |
2782 * 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
|
2783 * send GAIM_TYPED any time soon. |
4359 | 2784 */ |
2785 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2786 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2787 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2788 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2789 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2790 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2791 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2792 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2793 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2794 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2795 |
2796 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2797 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2798 GAIM_TYPING); |
4359 | 2799 |
2800 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2801 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2802 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2803 gaim_conv_im_set_type_again(im, 0); |
4359 | 2804 } |
2805 } | |
2806 | |
4736 | 2807 static void |
10810 | 2808 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2809 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2810 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2811 GaimConvIm *im = NULL; |
10810 | 2812 GaimConversation *conv = gtkconv->active_conv; |
12008 | 2813 char *stock_id, *tooltip; |
11508 | 2814 |
11581 | 2815 gtkwin = gtkconv->win; |
4736 | 2816 |
12008 | 2817 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2818 im = GAIM_CONV_IM(conv); |
4736 | 2819 |
12008 | 2820 if (gtkwin->menu.typing_icon) { |
2821 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2822 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2823 |
12008 | 2824 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2825 return; | |
2826 | |
2827 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2828 stock_id = GAIM_STOCK_TYPING; | |
2829 tooltip = _("User is typing..."); | |
2830 } else { | |
2831 stock_id = GAIM_STOCK_TYPED; | |
2832 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2833 } |
12008 | 2834 |
2835 if (gtkwin->menu.typing_icon == NULL) | |
2836 { | |
2837 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
|
2838 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
|
2839 gtkwin->menu.typing_icon, |
12008 | 2840 tooltip); |
4736 | 2841 } |
12008 | 2842 else |
2843 { | |
2844 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2845 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2846 gtkwin->menu.typing_icon, | |
2847 tooltip); | |
2848 } | |
2849 | |
2850 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2851 } |
2852 | |
4685 | 2853 static gboolean |
11594 | 2854 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2855 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2856 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2857 GaimConversation *conv; |
4359 | 2858 GtkWidget *menu; |
2859 GList *child; | |
11594 | 2860 GaimBuddy *b; |
11581 | 2861 |
2862 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2863 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2864 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2865 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2866 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2867 account = gaim_conversation_get_account(conv); |
11581 | 2868 |
11594 | 2869 if (win->menu.send_to == NULL) |
4685 | 2870 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2871 |
11594 | 2872 if (!(b = gaim_find_buddy(account, conv->name))) |
2873 return FALSE; | |
2874 | |
2875 | |
2876 gtk_widget_show(win->menu.send_to); | |
4359 | 2877 |
2878 menu = gtk_menu_item_get_submenu( | |
11594 | 2879 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2880 |
2881 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2882 child != NULL; | |
2883 child = child->next) { | |
2884 | |
2885 GtkWidget *item = child->data; | |
11594 | 2886 GaimBuddy *item_buddy; |
2887 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2888 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2889 "gaim_buddy_name"); | |
2890 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2891 | |
2892 if (b == item_buddy) { | |
4359 | 2893 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2894 break; | |
2895 } | |
2896 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2897 |
4685 | 2898 return FALSE; |
4359 | 2899 } |
2900 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2901 static gboolean |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2902 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
|
2903 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2904 gtk_widget_set_sensitive(GTK_WIDGET(label), TRUE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2905 return FALSE; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2906 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2907 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2908 static gboolean |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2909 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
|
2910 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2911 gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2912 return FALSE; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2913 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2914 |
4359 | 2915 static void |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2916 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
|
2917 { |
11594 | 2918 GtkWidget *box; |
2919 GtkWidget *label; | |
2920 GtkWidget *image; | |
2921 GtkWidget *menuitem; | |
11625 | 2922 GdkPixbuf *pixbuf; |
11616 | 2923 gchar *text; |
11594 | 2924 |
2925 /* Create a pixmap for the protocol icon. */ | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2926 if (buddy != NULL) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2927 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
|
2928 else |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2929 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2930 GdkPixbuf *unscaled = gaim_gtk_create_prpl_icon(account); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2931 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2932 /* XXX: 15 is the size for GAIM_STATUS_ICON_SMALL in gtkblist.c */ |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2933 pixbuf = gdk_pixbuf_scale_simple(unscaled, 15, 15, |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2934 GDK_INTERP_BILINEAR); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2935 g_object_unref(G_OBJECT(unscaled)); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2936 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2937 |
11594 | 2938 /* Now convert it to GtkImage */ |
2939 if (pixbuf == NULL) | |
2940 image = gtk_image_new(); | |
2941 else | |
11625 | 2942 image = gtk_image_new_from_pixbuf(pixbuf); |
11594 | 2943 |
2944 gtk_size_group_add_widget(sg, image); | |
2945 | |
2946 g_object_unref(G_OBJECT(pixbuf)); | |
2947 | |
2948 /* Make our menu item */ | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2949 text = g_strdup_printf("%s (%s)", name, gaim_account_get_username(account)); |
11616 | 2950 menuitem = gtk_radio_menu_item_new_with_label(*group, text); |
2951 g_free(text); | |
11594 | 2952 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2953 | |
2954 /* Do some evil, see some evil, speak some evil. */ | |
2955 box = gtk_hbox_new(FALSE, 0); | |
2956 | |
2957 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
2958 g_object_ref(label); | |
2959 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
2960 | |
2961 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
2962 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
2963 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2964 if (buddy != NULL && |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2965 !gaim_presence_is_online(gaim_buddy_get_presence(buddy)) && |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2966 !gaim_account_supports_offline_message(account, buddy)) |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2967 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2968 gtk_widget_set_sensitive(label, FALSE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2969 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2970 /* Set the label sensitive when the menuitem is highlighted and |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2971 * insensitive again when the mouse leaves it. This way, it |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2972 * doesn't appear weird from the highlighting of the embossed |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2973 * (insensitive style) text.*/ |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2974 g_signal_connect(menuitem, "enter-notify-event", |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2975 G_CALLBACK(send_to_item_enter_notify_cb), label); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2976 g_signal_connect(menuitem, "leave-notify-event", |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2977 G_CALLBACK(send_to_item_leave_notify_cb), label); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2978 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2979 |
11594 | 2980 g_object_unref(label); |
2981 | |
2982 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
2983 | |
2984 gtk_widget_show(label); | |
2985 gtk_widget_show(image); | |
2986 gtk_widget_show(box); | |
2987 | |
2988 /* Set our data and callbacks. */ | |
2989 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2990 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(name), g_free); |
11594 | 2991 |
2992 g_signal_connect(G_OBJECT(menuitem), "activate", | |
2993 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2994 | |
2995 gtk_widget_show(menuitem); | |
2996 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2997 } | |
2998 | |
2999 static void | |
3000 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 3001 { |
4359 | 3002 GtkWidget *menu; |
3003 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3004 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 3005 GaimGtkConversation *gtkconv; |
3006 GSList *l, *buds; | |
3007 | |
3008 g_return_if_fail(win != NULL); | |
3009 | |
3010 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
3011 | |
11604 | 3012 g_return_if_fail(gtkconv != NULL); |
3013 | |
11594 | 3014 if (win->menu.send_to != NULL) |
3015 gtk_widget_destroy(win->menu.send_to); | |
3016 | |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12272
diff
changeset
|
3017 /* Build the Send To menu */ |
11594 | 3018 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
3019 gtk_widget_show(win->menu.send_to); | |
4359 | 3020 |
3021 menu = gtk_menu_new(); | |
11581 | 3022 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 3023 win->menu.send_to, 2); |
3024 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 3025 |
3026 gtk_widget_show(menu); | |
3027 | |
11604 | 3028 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
3029 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
|
3030 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3031 if (buds == NULL) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3032 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3033 /* The user isn't on the buddy list. */ |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3034 create_sendto_item(menu, sg, &group, NULL, gtkconv->active_conv->account, gtkconv->active_conv->name); |
11604 | 3035 } |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3036 else |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3037 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3038 GList *list = NULL, *iter; |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3039 for (l = buds; l != NULL; l = l->next) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3040 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3041 GaimBlistNode *node; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3042 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3043 node = (GaimBlistNode *) gaim_buddy_get_contact((GaimBuddy *)l->data); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3044 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3045 for (node = node->child; node != NULL; node = node->next) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3046 { |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
3047 GaimBuddy *buddy = (GaimBuddy *)node; |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3048 GaimAccount *account; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3049 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3050 if (!GAIM_BLIST_NODE_IS_BUDDY(node)) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3051 continue; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3052 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3053 account = gaim_buddy_get_account(buddy); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3054 if (gaim_account_is_connected(account)) |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3055 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3056 /* Use the GaimPresence to get unique buddies. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3057 GaimPresence *presence = gaim_buddy_get_presence(buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3058 if (!g_list_find(list, presence)) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3059 list = g_list_prepend(list, presence); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3060 } |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3061 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3062 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3063 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3064 /* 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
|
3065 * since we did a g_list_prepend() earlier. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3066 for (iter = g_list_last(list); iter != NULL; iter = iter->prev) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3067 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3068 GaimPresence *pre = iter->data; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3069 GaimBuddy *buddy = gaim_presence_get_buddies(pre)->data; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3070 create_sendto_item(menu, sg, &group, buddy, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3071 gaim_buddy_get_account(buddy), gaim_buddy_get_name(buddy)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3072 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3073 g_list_free(list); |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3074 g_slist_free(buds); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3075 } |
4359 | 3076 } |
3077 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3078 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3079 |
11594 | 3080 gtk_widget_show(win->menu.send_to); |
12455 | 3081 /* TODO: This should never be insensitive. Possibly hidden or not. */ |
11594 | 3082 if (!group) |
3083 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
3084 update_send_to_selection(win); | |
4359 | 3085 } |
3086 | |
3087 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3088 generate_invite_user_names(GaimConnection *gc) |
4359 | 3089 { |
6695 | 3090 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 3091 static GList *tmp = NULL; |
3092 | |
3093 if (tmp) | |
3094 g_list_free(tmp); | |
3095 | |
3096 tmp = g_list_append(NULL, ""); | |
3097 | |
3098 if (gc != NULL) { | |
4785 | 3099 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
3100 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
3101 continue; | |
6695 | 3102 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3103 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 3104 continue; |
6695 | 3105 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
3106 GaimBuddy *buddy; | |
3107 | |
3108 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
3109 continue; | |
3110 | |
3111 buddy = (GaimBuddy *)bnode; | |
3112 | |
3113 if (buddy->account == gc->account && | |
3114 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 3115 tmp = g_list_insert_sorted(tmp, buddy->name, |
3116 (GCompareFunc)g_utf8_collate); | |
6695 | 3117 } |
4359 | 3118 } |
3119 } | |
3120 } | |
3121 | |
3122 return tmp; | |
3123 } | |
3124 | |
9498 | 3125 static GdkPixbuf * |
9554 | 3126 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 3127 { |
9554 | 3128 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 3129 char *filename; |
10274 | 3130 const char *image = NULL; |
9554 | 3131 |
3132 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 3133 image = "founder.png"; |
9554 | 3134 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 3135 image = "op.png"; |
9554 | 3136 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 3137 image = "halfop.png"; |
9554 | 3138 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 3139 image = "voice.png"; |
9554 | 3140 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 3141 image = "ignored.png"; |
3142 } else { | |
3143 return NULL; | |
9554 | 3144 } |
10274 | 3145 |
3146 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
3147 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
3148 g_free(filename); | |
3149 | |
3150 if (!pixbuf) | |
3151 return NULL; | |
3152 | |
3153 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
3154 g_object_unref(pixbuf); | |
3155 | |
3156 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
3157 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 3158 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
3159 g_free(filename); | |
10274 | 3160 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 3161 g_object_unref(pixbuf); |
10274 | 3162 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
3163 g_object_unref(scale2); | |
9498 | 3164 } |
3165 | |
10274 | 3166 return scale; |
9498 | 3167 } |
3168 | |
4359 | 3169 static void |
11869 | 3170 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 3171 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3172 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3173 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3174 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3175 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3176 GaimPluginProtocolInfo *prpl_info; |
4359 | 3177 GtkListStore *ls; |
9498 | 3178 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3179 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3180 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3181 gboolean is_buddy; |
4359 | 3182 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3183 chat = GAIM_CONV_CHAT(conv); |
4359 | 3184 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3185 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3186 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3187 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3188 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3189 return; |
4359 | 3190 |
3191 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3192 | |
9554 | 3193 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 3194 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3195 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
|
3196 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3197 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3198 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3199 |
4359 | 3200 gtk_list_store_append(ls, &iter); |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3201 |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3202 if (is_me) |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3203 { |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3204 GdkColor send_color; |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3205 gdk_color_parse(SEND_COLOR, &send_color); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3206 |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3207 gtk_list_store_set(ls, &iter, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3208 CHAT_USERS_ICON_COLUMN, pixbuf, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3209 CHAT_USERS_ALIAS_COLUMN, alias, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3210 CHAT_USERS_NAME_COLUMN, name, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3211 CHAT_USERS_FLAGS_COLUMN, flags, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3212 CHAT_USERS_COLOR_COLUMN, &send_color, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3213 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3214 -1); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3215 } |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3216 else |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3217 { |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3218 gtk_list_store_set(ls, &iter, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3219 CHAT_USERS_ICON_COLUMN, pixbuf, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3220 CHAT_USERS_ALIAS_COLUMN, alias, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3221 CHAT_USERS_NAME_COLUMN, name, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3222 CHAT_USERS_FLAGS_COLUMN, flags, |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
3223 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, name), |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3224 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3225 -1); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3226 } |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3227 |
9554 | 3228 if (pixbuf) |
3229 g_object_unref(pixbuf); | |
4359 | 3230 } |
3231 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3232 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3233 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
|
3234 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3235 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3236 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3237 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3238 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3239 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3240 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3241 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3242 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3243 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3244 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3245 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3246 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3247 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3248 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3249 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3250 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3251 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3252 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3253 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3254 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3255 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3256 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3257 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3258 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3259 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3260 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3261 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3262 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3263 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3264 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3265 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3266 (GCompareFunc)gaim_utf8_strcasecmp); |
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 |
9605 | 3269 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3270 tab_complete(GaimConversation *conv) |
4359 | 3271 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3272 GaimGtkConversation *gtkconv; |
4359 | 3273 GtkTextIter cursor, word_start, start_buffer; |
3274 int start; | |
3275 int most_matched = -1; | |
3276 char *entered, *partial = NULL; | |
3277 char *text; | |
8021 | 3278 char *nick_partial; |
9605 | 3279 const char *prefix; |
4359 | 3280 GList *matches = NULL; |
9605 | 3281 gboolean command = FALSE; |
4359 | 3282 |
3283 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3284 | |
3285 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3286 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3287 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3288 | |
3289 word_start = cursor; | |
3290 | |
3291 /* if there's nothing there just return */ | |
3292 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3293 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
|
3294 |
4359 | 3295 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3296 &cursor, FALSE); | |
3297 | |
3298 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3299 start = strlen(text) - 1; | |
3300 | |
8021 | 3301 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3302 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3303 start-=2; |
3304 } | |
4359 | 3305 |
3306 /* find the start of the word that we're tabbing */ | |
3307 while (start >= 0 && text[start] != ' ') { | |
3308 gtk_text_iter_backward_char(&word_start); | |
3309 start--; | |
3310 } | |
3311 | |
9605 | 3312 prefix = gaim_gtk_get_cmd_prefix(); |
3313 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3314 command = TRUE; | |
3315 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3316 } | |
3317 | |
4359 | 3318 g_free(text); |
3319 | |
3320 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3321 &cursor, FALSE); | |
3322 | |
8021 | 3323 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3324 g_free(entered); |
11338 | 3325 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3326 } |
3327 | |
8021 | 3328 nick_partial = g_malloc(strlen(entered)+1); |
3329 | |
9605 | 3330 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3331 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3332 GList *l; |
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 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3335 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3336 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3339 g_list_free(list); |
11338 | 3340 } 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
|
3341 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3342 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3343 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
|
3344 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3345 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3346 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3347 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3348 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3349 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3350 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3351 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3352 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3353 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3354 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3355 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
|
3356 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3357 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3358 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3359 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3360 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3361 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3362 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3363 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3364 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3365 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3366 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3367 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3368 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3369 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3370 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3371 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3372 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3373 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3374 } |
9605 | 3375 } else { |
3376 g_free(nick_partial); | |
3377 g_free(entered); | |
3378 return FALSE; | |
3379 } | |
3380 | |
8021 | 3381 g_free(nick_partial); |
3382 | |
4359 | 3383 /* we're only here if we're doing new style */ |
3384 | |
3385 /* if there weren't any matches, return */ | |
3386 if (!matches) { | |
3387 /* if matches isn't set partials won't be either */ | |
3388 g_free(entered); | |
11338 | 3389 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3390 } |
3391 | |
3392 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3393 | |
3394 if (!matches->next) { | |
3395 /* there was only one match. fill it in. */ | |
3396 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3397 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3398 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3399 | |
3400 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3401 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3402 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3403 g_free(tmp); | |
3404 } | |
3405 else | |
3406 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3407 matches->data, -1); | |
3408 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3409 g_free(matches->data); |
4359 | 3410 matches = g_list_remove(matches, matches->data); |
3411 } | |
3412 else { | |
3413 /* | |
3414 * there were lots of matches, fill in as much as possible | |
3415 * and display all of them | |
3416 */ | |
3417 char *addthis = g_malloc0(1); | |
3418 | |
3419 while (matches) { | |
3420 char *tmp = addthis; | |
3421 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3422 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3423 g_free(matches->data); |
4359 | 3424 matches = g_list_remove(matches, matches->data); |
3425 } | |
3426 | |
6982 | 3427 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3428 time(NULL)); |
3429 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3430 g_free(addthis); | |
3431 } | |
3432 | |
3433 g_free(entered); | |
3434 g_free(partial); | |
9605 | 3435 |
3436 return TRUE; | |
4359 | 3437 } |
3438 | |
10810 | 3439 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3440 { |
3441 GaimPluginProtocolInfo *prpl_info = NULL; | |
3442 GaimConnection *gc; | |
10810 | 3443 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3444 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3445 char *new_topic; |
8858 | 3446 const char *current_topic; |
7971 | 3447 |
3448 gc = gaim_conversation_get_gc(conv); | |
3449 | |
3450 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3451 return; | |
3452 | |
3453 if(prpl_info->set_chat_topic == NULL) | |
3454 return; | |
3455 | |
3456 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3457 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3458 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3459 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3460 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3461 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3462 g_free(new_topic); |
7971 | 3463 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3464 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3465 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3466 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3467 |
8858 | 3468 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3469 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3470 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3471 g_free(new_topic); |
7971 | 3472 } |
3473 | |
9554 | 3474 static gint |
3475 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3476 { | |
3477 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3478 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3479 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3480 gint ret = 0; |
3481 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3482 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3483 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3484 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3485 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3486 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3487 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3488 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3489 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3490 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3491 -1); |
9554 | 3492 |
3493 if (user1 == NULL || user2 == NULL) { | |
3494 if (!(user1 == NULL && user2 == NULL)) | |
3495 ret = (user1 == NULL) ? -1: 1; | |
3496 } else if (f1 != f2) { | |
3497 /* sort more important users first */ | |
3498 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3499 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3500 ret = buddy1 ? -1 : 1; |
9554 | 3501 } else { |
10904 | 3502 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3503 } |
3504 | |
3505 g_free(user1); | |
3506 g_free(user2); | |
3507 | |
3508 return ret; | |
3509 } | |
3510 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3511 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3512 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
|
3513 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3514 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3515 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3516 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3517 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3518 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3519 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3520 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3521 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3522 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3523 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3524 /* 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
|
3525 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
|
3526 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3527 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
|
3528 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3529 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3530 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3531 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3532 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3533 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3534 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3535 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
|
3536 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3537 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3538 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3539 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3540 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3541 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3542 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3543 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3544 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3545 alias = gaim_buddy_get_contact_alias(buddy2); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3546 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3547 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3548 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3549 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3550 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3551 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3552 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3553 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3554 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3555 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3556 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3557 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3558 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3559 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3560 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3561 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3562 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3563 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3564 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
|
3565 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3566 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3567 GaimPluginProtocolInfo *prpl_info; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3568 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3569 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3570 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3571 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3572 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3573 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3574 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3575 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3576 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3577 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3578 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3579 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3580 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3581 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3582 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3583 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3584 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3585 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3586 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3587 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3588 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3589 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3590 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3591 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3592 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3593 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3594 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3595 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3596 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3597 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3598 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3599 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3600 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3601 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3602 int f; |
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 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3605 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3606 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3607 /* 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
|
3608 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3609 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3610 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3611 /* 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
|
3612 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
|
3613 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3614 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
|
3615 return; |
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 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3618 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3619 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3620 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3621 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3622 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
|
3623 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3624 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3625 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
|
3626 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3627 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3628 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3629 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3630 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3631 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3632 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3633 } while (f != 0); |
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 g_free(normalized_name); |
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 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3638 } |
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 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3641 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
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 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3644 } |
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 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3647 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
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 /* 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
|
3650 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3651 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3652 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3653 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3654 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3655 |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3656 static void send_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3657 { |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3658 g_signal_emit_by_name(gtkconv->entry, "message_send"); |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3659 } |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3660 |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3661 static void |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3662 entry_popup_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3663 { |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3664 GtkWidget *menuitem; |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3665 GaimGtkConversation *gtkconv = data; |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3666 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3667 g_return_if_fail(menu != NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3668 g_return_if_fail(gtkconv != NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3669 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3670 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
|
3671 G_CALLBACK(send_menu_cb), gtkconv, |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3672 0, 0, NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3673 if (gtk_text_buffer_get_char_count(imhtml->text_buffer) == 0) |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3674 gtk_widget_set_sensitive(menuitem, FALSE); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3675 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 0); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3676 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3677 menuitem = gtk_separator_menu_item_new(); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3678 gtk_widget_show(menuitem); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3679 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 1); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3680 } |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3681 |
4359 | 3682 static GtkWidget * |
10810 | 3683 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3684 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3685 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3686 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3687 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3688 GaimConnection *gc; |
4359 | 3689 GtkWidget *vpaned, *hpaned; |
10175 | 3690 GtkWidget *vbox, *hbox, *frame; |
4359 | 3691 GtkWidget *lbox, *bbox; |
3692 GtkWidget *label; | |
3693 GtkWidget *list; | |
3694 GtkWidget *button; | |
7949 | 3695 GtkWidget *sw; |
4359 | 3696 GtkListStore *ls; |
3697 GtkCellRenderer *rend; | |
3698 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3699 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3700 GList *focus_chain = NULL; |
4359 | 3701 |
3702 gtkchat = gtkconv->u.chat; | |
3703 gc = gaim_conversation_get_gc(conv); | |
3704 | |
3705 /* Setup the outer pane. */ | |
3706 vpaned = gtk_vpaned_new(); | |
3707 gtk_widget_show(vpaned); | |
3708 | |
3709 /* Setup the top part of the pane. */ | |
11243 | 3710 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3711 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3712 gtk_widget_show(vbox); |
3713 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3714 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3715 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3716 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3717 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3718 { |
11243 | 3719 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3720 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3721 gtk_widget_show(hbox); |
3722 | |
3723 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3724 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3725 gtk_widget_show(label); |
3726 | |
3727 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3728 |
7971 | 3729 if(prpl_info->set_chat_topic == NULL) { |
3730 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3731 } else { | |
3732 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3733 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3734 } |
3735 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3736 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3737 gtk_widget_show(gtkchat->topic_text); |
3738 } | |
3739 | |
3740 /* Setup the horizontal pane. */ | |
3741 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3742 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3743 gtk_widget_show(hpaned); |
3744 | |
10175 | 3745 /* Setup gtkihmtml. */ |
3746 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3747 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3748 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3749 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3750 gtk_widget_show(frame); | |
3751 | |
3752 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3753 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3754 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3755 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3756 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3757 |
4359 | 3758 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3759 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3760 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3761 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3762 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3763 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3764 |
3765 /* Build the right pane. */ | |
11243 | 3766 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3767 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3768 gtk_widget_show(lbox); |
3769 | |
3770 /* Setup the label telling how many people are in the room. */ | |
3771 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3772 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3773 gtk_widget_show(gtkchat->count); | |
3774 | |
3775 /* Setup the list of users. */ | |
7949 | 3776 sw = gtk_scrolled_window_new(NULL, NULL); |
3777 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3778 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3779 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3780 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3781 gtk_widget_show(sw); | |
4359 | 3782 |
9554 | 3783 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
|
3784 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
|
3785 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3786 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3787 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3788 GTK_SORT_ASCENDING); |
3789 | |
3790 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3791 | |
9498 | 3792 rend = gtk_cell_renderer_pixbuf_new(); |
3793 | |
4359 | 3794 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3795 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3796 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3797 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3798 |
3799 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3800 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3801 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3802 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3803 |
9498 | 3804 rend = gtk_cell_renderer_text_new(); |
3805 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3806 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3807 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3808 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3809 NULL); |
4359 | 3810 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3811 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3812 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3813 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3814 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3815 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3816 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3817 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3818 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3819 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3820 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3821 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3822 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3823 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3824 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3825 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3826 #endif |
4359 | 3827 |
3828 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3829 | |
3830 gtk_widget_set_size_request(list, 150, -1); | |
3831 | |
3832 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3833 gtk_widget_show(list); | |
3834 | |
3835 gtkchat->list = list; | |
3836 | |
7949 | 3837 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3838 |
3839 /* Setup the user list toolbar. */ | |
11243 | 3840 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3841 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3842 gtk_widget_show(bbox); | |
3843 | |
3844 /* IM */ | |
10221 | 3845 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3846 GAIM_BUTTON_VERTICAL); |
10500 | 3847 gtkchat->userlist_im = button; |
4359 | 3848 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3849 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
|
3850 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3851 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3852 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3853 |
3854 gtk_widget_show(button); | |
3855 | |
3856 /* Ignore */ | |
3857 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3858 GAIM_BUTTON_VERTICAL); | |
10500 | 3859 gtkchat->userlist_ignore = button; |
4359 | 3860 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3861 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
|
3862 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3863 _("Ignore the user"), NULL); |
4359 | 3864 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3865 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3866 gtk_widget_show(button); |
3867 | |
3868 /* Info */ | |
3869 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3870 GAIM_BUTTON_VERTICAL); | |
10500 | 3871 gtkchat->userlist_info = button; |
4359 | 3872 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3873 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3874 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3875 _("Get the user's information"), NULL); |
4359 | 3876 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3877 G_CALLBACK(info_cb), gtkconv); |
4359 | 3878 |
3879 gtk_widget_show(button); | |
3880 | |
10175 | 3881 /* Setup the bottom half of the conversation window */ |
11243 | 3882 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3883 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3884 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3885 |
11243 | 3886 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3887 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3888 gtk_widget_show(gtkconv->lower_hbox); | |
3889 | |
11243 | 3890 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3891 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3892 gtk_widget_show(vbox); | |
3893 | |
10175 | 3894 /* Setup the toolbar, entry widget and all signals */ |
3895 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3896 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3897 gtk_widget_show(frame); |
3898 | |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3899 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3900 G_CALLBACK(entry_popup_menu_cb), gtkconv); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3901 |
9005 | 3902 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3903 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3904 gaim_account_get_protocol_name(conv->account)); |
10175 | 3905 gtk_widget_set_size_request(gtkconv->entry, -1, |
3906 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3907 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3908 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3909 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3910 |
3911 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3912 G_CALLBACK(entry_key_press_cb), gtkconv); |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3913 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3914 G_CALLBACK(send_cb), gtkconv); |
4359 | 3915 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3916 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3917 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3918 G_CALLBACK(size_allocate_cb), gtkconv); |
3919 | |
3920 default_formatize(gtkconv); | |
4359 | 3921 |
9080 | 3922 /* |
3923 * Focus for chat windows should be as follows: | |
3924 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3925 * user list buttons -> entry -> buttons at bottom | |
3926 */ | |
9332 | 3927 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3928 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3929 | |
4359 | 3930 return vpaned; |
3931 } | |
3932 | |
3933 static GtkWidget * | |
10810 | 3934 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 3935 { |
10810 | 3936 GaimConversation *conv = gtkconv->active_conv; |
10175 | 3937 GtkWidget *frame; |
4359 | 3938 GtkWidget *paned; |
10175 | 3939 GtkWidget *vbox; |
3940 GtkWidget *vbox2; | |
9080 | 3941 GList *focus_chain = NULL; |
4359 | 3942 |
10175 | 3943 /* Setup the outer pane */ |
4359 | 3944 paned = gtk_vpaned_new(); |
3945 gtk_widget_show(paned); | |
3946 | |
10175 | 3947 /* Setup the top part of the pane */ |
11243 | 3948 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3949 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3950 gtk_widget_show(vbox); |
3951 | |
10175 | 3952 /* Setup the gtkimhtml widget */ |
3953 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3954 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3955 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 3956 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
3957 gtk_widget_show(frame); | |
3958 | |
3959 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3960 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3961 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 3962 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3963 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3964 |
3965 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 3966 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 3967 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 3968 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3969 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 3970 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 3971 |
10175 | 3972 /* Setup the bottom half of the conversation window */ |
11243 | 3973 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3974 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3975 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3976 |
11243 | 3977 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3978 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3979 gtk_widget_show(gtkconv->lower_hbox); | |
3980 | |
11243 | 3981 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3982 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
3983 gtk_widget_show(vbox2); | |
8821 | 3984 |
10175 | 3985 /* Setup the toolbar, entry widget and all signals */ |
3986 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3987 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 3988 gtk_widget_show(frame); |
3989 | |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3990 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3991 G_CALLBACK(entry_popup_menu_cb), gtkconv); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3992 |
9005 | 3993 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3994 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3995 gaim_account_get_protocol_name(conv->account)); |
10175 | 3996 gtk_widget_set_size_request(gtkconv->entry, -1, |
3997 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3998 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3999 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 4000 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
|
4001 |
4359 | 4002 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 4003 G_CALLBACK(entry_key_press_cb), gtkconv); |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4004 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4005 G_CALLBACK(send_cb), gtkconv); |
4359 | 4006 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 4007 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 4008 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 4009 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 4010 |
4011 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 4012 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 4013 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 4014 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 4015 |
8481 | 4016 /* had to move this after the imtoolbar is attached so that the |
4017 * signals get fired to toggle the buttons on the toolbar as well. | |
4018 */ | |
10810 | 4019 default_formatize(gtkconv); |
4359 | 4020 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4021 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4022 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4023 |
8758 | 4024 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 4025 gtkconv->u.im->show_icon = TRUE; |
4359 | 4026 |
9080 | 4027 /* |
4028 * Focus for IM windows should be as follows: | |
10356 | 4029 * Tab title -> conversation scrollback -> entry |
9080 | 4030 */ |
9332 | 4031 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4032 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 4033 |
4359 | 4034 return paned; |
4035 } | |
4036 | |
4037 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4038 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 4039 GtkSelectionData *sd, guint info, guint t, |
4040 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4041 { |
10810 | 4042 GaimConversation *conv = gtkconv->active_conv; |
11581 | 4043 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4044 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4045 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4046 { |
4781 | 4047 GaimBlistNode *n = NULL; |
6695 | 4048 GaimBuddy *b; |
11581 | 4049 GaimGtkConversation *gtkconv = NULL; |
9622 | 4050 |
11812 | 4051 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4052 |
6695 | 4053 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
4054 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
4055 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
4056 b = (GaimBuddy*)n; | |
4057 else | |
4781 | 4058 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4059 |
9622 | 4060 /* |
4061 * If we already have an open conversation with this buddy, then | |
4062 * just move the conv to this window. Otherwise, create a new | |
4063 * conv and add it to this window. | |
4064 */ | |
11338 | 4065 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 4066 if (c != NULL) { |
11581 | 4067 GaimGtkWindow *oldwin; |
4068 gtkconv = GAIM_GTK_CONVERSATION(c); | |
4069 oldwin = gtkconv->win; | |
9622 | 4070 if (oldwin != win) { |
11581 | 4071 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
4072 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 4073 } |
4074 } else { | |
11338 | 4075 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 4076 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 4077 if (gtkconv->win != win) |
4078 { | |
4079 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
4080 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
4081 } | |
9622 | 4082 } |
4083 | |
4084 /* Make this conversation the active conversation */ | |
11581 | 4085 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4086 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4087 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 4088 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4089 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
|
4090 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4091 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4092 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4093 GaimAccount *account; |
11581 | 4094 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4095 |
11137 | 4096 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 4097 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4098 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4099 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4100 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4101 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4102 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4103 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4104 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4105 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4106 { |
11338 | 4107 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 4108 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 4109 if (gtkconv->win != win) |
4110 { | |
4111 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
4112 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
4113 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4114 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4115 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4116 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4117 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4118 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4119 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4120 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4121 } |
9525 | 4122 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 4123 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 4124 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 4125 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 4126 } |
10145 | 4127 else |
4128 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4129 } |
4359 | 4130 |
4131 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4132 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4133 { |
10145 | 4134 GTK_IMHTML_DND_TARGETS, |
4135 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
4136 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4137 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4138 |
10810 | 4139 static GaimGtkConversation * |
4140 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
4141 { | |
4142 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
4143 GaimContact *c; | |
4144 GaimBlistNode *cn; | |
10935 | 4145 |
10810 | 4146 if (!bud) |
4147 return NULL; | |
10935 | 4148 |
10810 | 4149 if (!(c = gaim_buddy_get_contact(bud))) |
4150 return NULL; | |
10935 | 4151 |
10810 | 4152 cn = (GaimBlistNode *)c; |
4153 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
4154 GaimConversation *conv; | |
11338 | 4155 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 4156 if (conv->ui_data) |
4157 return conv->ui_data; | |
4158 } | |
4159 } | |
10935 | 4160 |
10810 | 4161 return NULL; |
4162 } | |
4163 | |
11855 | 4164 static void |
4165 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
4166 { | |
4167 GList *list; | |
4168 | |
4169 g_return_if_fail(bnode); | |
4170 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
4171 | |
4172 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
4173 { | |
4174 GaimGtkWindow *win = list->data; | |
4175 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4176 | |
4177 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
4178 continue; | |
4179 | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
4180 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_MENU); |
11855 | 4181 } |
4182 } | |
4183 | |
11581 | 4184 /************************************************************************** |
4185 * Conversation UI operations | |
4186 **************************************************************************/ | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4187 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4188 private_gtkconv_new(GaimConversation *conv, gboolean hidden) |
11581 | 4189 { |
4190 GaimGtkConversation *gtkconv; | |
4191 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 4192 GtkWidget *pane = NULL; |
4193 GtkWidget *tab_cont; | |
11581 | 4194 |
4195 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 4196 conv->ui_data = gtkconv; |
4197 if (!g_list_find(gtkconv->convs, conv)) | |
4198 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 4199 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 4200 return; |
4359 | 4201 } |
4202 | |
11581 | 4203 gtkconv = g_new0(GaimGtkConversation, 1); |
4204 conv->ui_data = gtkconv; | |
4205 gtkconv->active_conv = conv; | |
4206 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
4207 | |
4208 /* Setup some initial variables. */ | |
4209 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
4210 gtkconv->tooltips = gtk_tooltips_new(); | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4211 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4212 gtkconv->unseen_count = 0; |
11581 | 4213 |
4214 if (conv_type == GAIM_CONV_TYPE_IM) { | |
4215 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
4216 | |
4217 pane = setup_im_pane(gtkconv); | |
4218 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
4219 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
4220 pane = setup_chat_pane(gtkconv); | |
4221 } | |
4222 | |
12101 | 4223 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
4224 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
4225 | |
11581 | 4226 if (pane == NULL) { |
4227 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
4228 g_free(gtkconv->u.chat); | |
4229 else if (conv_type == GAIM_CONV_TYPE_IM) | |
4230 g_free(gtkconv->u.im); | |
4231 | |
4232 g_free(gtkconv); | |
4233 conv->ui_data = NULL; | |
4234 return; | |
10449 | 4235 } |
11581 | 4236 |
4237 /* Setup drag-and-drop */ | |
4238 gtk_drag_dest_set(pane, | |
4239 GTK_DEST_DEFAULT_MOTION | | |
4240 GTK_DEST_DEFAULT_DROP, | |
4241 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4242 GDK_ACTION_COPY); | |
4243 gtk_drag_dest_set(pane, | |
4244 GTK_DEST_DEFAULT_MOTION | | |
4245 GTK_DEST_DEFAULT_DROP, | |
4246 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4247 GDK_ACTION_COPY); | |
4248 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4249 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4250 GDK_ACTION_COPY); | |
4251 | |
4252 gtk_drag_dest_set(gtkconv->entry, 0, | |
4253 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4254 GDK_ACTION_COPY); | |
4255 | |
4256 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
4257 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4258 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
4259 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4260 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
4261 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4262 | |
4263 /* Setup the container for the tab. */ | |
4264 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
4265 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
4266 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
4267 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
4268 gtk_widget_show(pane); | |
4269 | |
4270 gtkconv->make_sound = TRUE; | |
4271 | |
4272 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
4273 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4274 else |
11581 | 4275 gtk_widget_hide(gtkconv->toolbar); |
4276 | |
12188 | 4277 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), |
4278 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4279 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4280 gaim_account_get_protocol_name(conv->account)); |
11581 | 4281 |
4282 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
4283 G_CALLBACK(gtk_widget_grab_focus), | |
4284 gtkconv->entry); | |
4285 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4286 if (hidden) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4287 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4288 else |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4289 gaim_gtkconv_placement_place(gtkconv); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
4290 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4291 if (nick_colors == NULL) { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4292 nbr_nick_colors = NUM_NICK_COLORS; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4293 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
|
4294 } |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4295 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4296 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4297 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4298 gaim_gtkconv_new_hidden(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4299 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4300 private_gtkconv_new(conv, TRUE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4301 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4302 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4303 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4304 gaim_gtkconv_new(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4305 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4306 private_gtkconv_new(conv, FALSE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4307 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4308 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4309 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4310 received_im_msg_cb(GaimAccount *account, char *sender, char *message, |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4311 GaimConversation *conv, int flags) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4312 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4313 GaimConversationUiOps *ui_ops = gaim_gtk_conversations_get_conv_ui_ops(); |
12719
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4314 if (conv != NULL) |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4315 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4316 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4317 /* create hidden conv if hide_new pref is always */ |
12719
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4318 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
|
4319 { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4320 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4321 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4322 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4323 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4324 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4325 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4326 /* 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
|
4327 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
|
4328 !gaim_status_is_available(gaim_account_get_active_status(account))) |
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4329 { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4330 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4331 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4332 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4333 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4334 } |
11581 | 4335 } |
4336 | |
4359 | 4337 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4338 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4339 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4340 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4341 |
10810 | 4342 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4343 /* Don't destroy ourselves until all our convos are gone */ | |
4344 if (gtkconv->convs) | |
4345 return; | |
11508 | 4346 |
11581 | 4347 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4348 | |
9504 | 4349 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4350 gaim_request_close_with_handle(conv); | |
4359 | 4351 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4352 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4353 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4354 |
11338 | 4355 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4356 if (gtkconv->u.im->icon_timer != 0) |
4357 g_source_remove(gtkconv->u.im->icon_timer); | |
4358 | |
4359 | 4359 if (gtkconv->u.im->anim != NULL) |
4793 | 4360 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4361 |
4362 g_free(gtkconv->u.im); | |
11581 | 4363 } 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
|
4364 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4365 g_free(gtkconv->u.chat); |
4366 } | |
4367 | |
4633 | 4368 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4369 | |
4359 | 4370 g_free(gtkconv); |
4371 } | |
4372 | |
4373 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4374 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4375 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4376 time_t mtime) |
4359 | 4377 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4378 GaimGtkConversation *gtkconv; |
4359 | 4379 |
4380 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4381 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4382 |
6982 | 4383 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4384 } |
4385 | |
4386 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4387 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4388 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4389 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4390 GaimGtkConversation *gtkconv; |
4359 | 4391 |
4392 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4393 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4394 |
10398 | 4395 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4396 |
6982 | 4397 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4398 } |
4399 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4400 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4401 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4402 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4403 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4404 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4405 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4406 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4407 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4408 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4409 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4410 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4411 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4412 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4413 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4414 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4415 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4416 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4417 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4418 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4419 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4420 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4421 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4422 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4423 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4424 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4425 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4426 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4427 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4428 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4429 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4430 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4431 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4432 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4433 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4434 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4435 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4436 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4437 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4438 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4439 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4440 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4441 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4442 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4443 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4444 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4445 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4446 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4447 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4448 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4449 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4450 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4451 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4452 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4453 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4454 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4455 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4456 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4457 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4458 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4459 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4460 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4461 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4462 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4463 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4464 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4465 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4466 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4467 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4468 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4469 buddytag = gtk_text_buffer_create_tag( |
11096 | 4470 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4471 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4472 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4473 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4474 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4475 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4476 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4477 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4478 |
4359 | 4479 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4480 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4481 const char *message, GaimMessageFlags flags, |
4359 | 4482 time_t mtime) |
4483 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4484 GaimGtkConversation *gtkconv; |
11581 | 4485 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4486 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4487 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4488 GaimPluginProtocolInfo *prpl_info; |
4359 | 4489 int gtk_font_options = 0; |
12553 | 4490 int gtk_font_options_all = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4491 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4492 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4493 int line_count; |
4359 | 4494 char buf2[BUF_LONG]; |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4495 char *mdate; |
4359 | 4496 char color[10]; |
4497 char *str; | |
4498 char *with_font_tag; | |
4896 | 4499 char *sml_attrib = NULL; |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4500 size_t length; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4501 GaimConversationType type; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4502 char *displaying; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4503 gboolean plugin_return; |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4504 struct tm tm = *(localtime(&mtime)); |
4895 | 4505 |
4359 | 4506 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4507 |
12553 | 4508 if(gaim_prefs_get_bool("/gaim/gtk/conversations/use_smooth_scrolling")) |
4509 gtk_font_options_all |= GTK_IMHTML_USE_SMOOTHSCROLLING; | |
4510 | |
11581 | 4511 /* Set the active conversation to the one that just messaged us. */ |
4512 /* TODO: consider not doing this if the account is offline or something */ | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4513 gaim_gtkconv_set_active_conversation(conv); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4514 type = gaim_conversation_get_type(conv); |
11581 | 4515 |
4359 | 4516 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4517 account = gaim_conversation_get_account(conv); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4518 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4519 displaying = g_strdup(message); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4520 plugin_return = GPOINTER_TO_INT(gaim_signal_emit_return_1( |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4521 gaim_gtk_conversations_get_handle(), (type == GAIM_CONV_TYPE_IM ? |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4522 "displaying-im-msg" : "displaying-chat-msg"), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4523 account, conv, &displaying, flags)); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4524 if (plugin_return) |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4525 { |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4526 g_free(displaying); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4527 return; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4528 } |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4529 message = displaying; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4530 length = strlen(message) + 1; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4531 |
11581 | 4532 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4533 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4534 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4535 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4536 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4537 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4538 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4539 /* 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
|
4540 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4541 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4542 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4543 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4544 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4545 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4546 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4547 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4548 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4549 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4550 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4551 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4552 |
8677 | 4553 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
12553 | 4554 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", gtk_font_options_all); |
8677 | 4555 |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4556 mdate = gaim_signal_emit_return_1(gaim_gtk_conversations_get_handle(), |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4557 "conversation-timestamp", |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4558 conv, &tm); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4559 if (mdate == NULL) |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4560 { |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4561 char buf[64]; |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4562 |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4563 if (time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4564 strftime(buf, sizeof(buf), "%x %X", &tm); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4565 else |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4566 strftime(buf, sizeof(buf), "%X", &tm); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4567 |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4568 mdate = g_strdup(buf); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4569 } |
4359 | 4570 |
4896 | 4571 if(gc) |
9699 | 4572 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4573 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4574 |
10503 | 4575 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4576 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4577 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4578 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4579 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4580 |
7956 | 4581 /* this is gonna crash one day, I can feel it. */ |
4582 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4583 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4584 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4585 } |
4359 | 4586 |
12553 | 4587 |
10737 | 4588 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4589 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4590 g_snprintf(buf2, sizeof(buf2), |
8690 | 4591 "<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
|
4592 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4593 |
12553 | 4594 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
7440 | 4595 |
8722 | 4596 } else if (flags & GAIM_MESSAGE_ERROR) { |
4597 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4598 "<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
|
4599 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4600 |
12553 | 4601 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
8962 | 4602 |
7431 | 4603 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4604 g_snprintf(buf2, BUF_LONG, |
8690 | 4605 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4606 sml_attrib ? sml_attrib : "", message); |
7440 | 4607 |
12553 | 4608 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
10346 | 4609 } else if (flags & GAIM_MESSAGE_RAW) { |
12553 | 4610 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, gtk_font_options_all); |
10346 | 4611 } else { |
4895 | 4612 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4613 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
|
4614 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4615 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4616 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
|
4617 int tag_end_offset = 0; |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4618 GtkSmileyTree *tree = NULL; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4619 GHashTable *smiley_data = NULL; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4620 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4621 if (flags & GAIM_MESSAGE_SEND) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4622 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4623 /* Temporarily revert to the original smiley-data to avoid showing up |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4624 * custom smileys of the buddy when sending message |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4625 */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4626 tree = GTK_IMHTML(gtkconv->imhtml)->default_smilies; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4627 GTK_IMHTML(gtkconv->imhtml)->default_smilies = |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4628 GTK_IMHTML(gtkconv->entry)->default_smilies; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4629 smiley_data = GTK_IMHTML(gtkconv->imhtml)->smiley_data; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4630 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
|
4631 } |
7440 | 4632 |
6621 | 4633 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4634 str = g_malloc(1024); |
7440 | 4635 |
4359 | 4636 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4637 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4638 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4639 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4640 tag_start_offset += 3; |
4359 | 4641 } |
4642 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4643 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4644 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4645 tag_end_offset = 2; |
4359 | 4646 strcpy(color, "#00FF00"); |
4647 } | |
7440 | 4648 } |
4359 | 4649 else { |
10504 | 4650 if (gaim_message_meify(new_message, -1)) { |
4359 | 4651 str = g_malloc(1024); |
7440 | 4652 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4653 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4654 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
|
4655 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4656 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4657 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4658 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4659 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4660 } |
7440 | 4661 |
6621 | 4662 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4663 strcpy(color, HIGHLIGHT_COLOR); |
4359 | 4664 else |
4665 strcpy(color, "#062585"); | |
4666 } | |
4667 else { | |
4668 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4669 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4670 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
|
4671 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4672 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4673 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4674 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4675 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4676 } |
6621 | 4677 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4678 strcpy(color, HIGHLIGHT_COLOR); |
6621 | 4679 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4680 if (flags & GAIM_MESSAGE_COLORIZE) { |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
4681 GdkColor *col = get_nick_color(gtkconv, name); |
10346 | 4682 |
10108 | 4683 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4684 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4685 } else |
7854 | 4686 strcpy(color, RECV_COLOR); |
4359 | 4687 } |
6621 | 4688 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4689 strcpy(color, SEND_COLOR); |
10892 | 4690 else { |
4691 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4692 strcpy(color, "#000000"); | |
4693 } | |
4359 | 4694 } |
4695 } | |
10892 | 4696 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4697 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4698 g_free(alias_escaped); |
11508 | 4699 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4700 /* 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
|
4701 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4702 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4703 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4704 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4705 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4706 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4707 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4708 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4709 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4710 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4711 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4712 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4713 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4714 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4715 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4716 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4717 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4718 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4719 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4720 /* 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
|
4721 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4722 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4723 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4724 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4725 } |
7440 | 4726 |
12553 | 4727 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
|
4728 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4729 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4730 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4731 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4732 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4733 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4734 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4735 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4736 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4737 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4738 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4739 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4740 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4741 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4742 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4743 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4744 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4745 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4746 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4747 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4748 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4749 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4750 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4751 |
4359 | 4752 g_free(str); |
4753 | |
4895 | 4754 if(gc){ |
4896 | 4755 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4756 char *post = "</font>"; |
4757 int pre_len = strlen(pre); | |
4758 int post_len = strlen(post); | |
7440 | 4759 |
4895 | 4760 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4761 |
4895 | 4762 strcpy(with_font_tag, pre); |
4763 memcpy(with_font_tag + pre_len, new_message, length); | |
4764 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4765 |
4895 | 4766 length += pre_len + post_len; |
4767 g_free(pre); | |
4768 } | |
4608 | 4769 else |
4895 | 4770 with_font_tag = g_memdup(new_message, length); |
7440 | 4771 |
8962 | 4772 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
12553 | 4773 with_font_tag, gtk_font_options | gtk_font_options_all); |
7440 | 4774 |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4775 if (flags & GAIM_MESSAGE_SEND) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4776 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4777 /* Restore the smiley-data */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4778 GTK_IMHTML(gtkconv->imhtml)->default_smilies = tree; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4779 GTK_IMHTML(gtkconv->imhtml)->smiley_data = smiley_data; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4780 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4781 |
7440 | 4782 g_free(with_font_tag); |
7447 | 4783 g_free(new_message); |
7440 | 4784 } |
4785 | |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4786 g_free(mdate); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4787 g_free(sml_attrib); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4788 |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4789 gaim_signal_emit(gaim_gtk_conversations_get_handle(), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4790 (type == GAIM_CONV_TYPE_IM ? "displayed-im-msg" : "displayed-chat-msg"), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4791 account, conv, message, flags); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4792 g_free(displaying); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4793 |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4794 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4795 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4796 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4797 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4798 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4799 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4800 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4801 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4802 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4803 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4804 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
|
4805 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4806 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4807 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4808 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4809 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4810 } |
4359 | 4811 } |
4812 | |
4813 static void | |
12463
b1717befbb26
[gaim-migrate @ 14773]
Richard Laager <rlaager@wiktel.com>
parents:
12455
diff
changeset
|
4814 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
|
4815 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4816 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4817 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4818 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4819 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4820 GList *ll; |
11869 | 4821 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4822 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4823 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4824 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4825 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4826 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4827 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4828 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4829 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
|
4830 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4831 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4832 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4833 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4834 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4835 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4836 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4837 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4838 l = users; |
11869 | 4839 ll = flags; |
4840 lll = aliases; | |
4841 while (l != NULL && ll != NULL && lll != NULL) { | |
4842 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
|
4843 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4844 ll = ll->next; |
11869 | 4845 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4846 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4847 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4848 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4849 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4850 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
|
4851 const char *new_name, const char *new_alias) |
4359 | 4852 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4853 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4854 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4855 GaimGtkChatPane *gtkchat; |
11869 | 4856 GaimConvChatBuddyFlags flags; |
4359 | 4857 GtkTreeIter iter; |
4858 GtkTreeModel *model; | |
4859 int f = 1; | |
4860 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4861 chat = GAIM_CONV_CHAT(conv); |
4359 | 4862 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4863 gtkchat = gtkconv->u.chat; | |
4864 | |
9554 | 4865 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4866 | |
4867 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4868 return; | |
4869 | |
4870 while (f != 0) { | |
4871 char *val; | |
4872 | |
11869 | 4873 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4874 |
4875 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4876 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4877 g_free(val); | |
4359 | 4878 break; |
4879 } | |
9554 | 4880 |
4881 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4882 | |
4883 g_free(val); | |
4359 | 4884 } |
4885 | |
9554 | 4886 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4887 return; |
4888 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4889 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4890 |
11869 | 4891 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4892 } |
4893 | |
4894 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4895 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4896 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4897 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4898 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4899 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4900 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4901 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4902 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4903 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4904 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4905 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4906 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4907 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4908 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4909 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4910 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4911 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
|
4912 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4913 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4914 for (l = users; l != NULL; l = l->next) { |
9554 | 4915 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4916 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4917 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4918 continue; |
4919 | |
4920 do { | |
4921 char *val; | |
4922 | |
4923 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4924 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4925 | |
9696 | 4926 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4927 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4928 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4929 #else |
4930 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4931 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4932 #endif | |
4933 } | |
9554 | 4934 else |
4935 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4936 | |
4937 g_free(val); | |
4938 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4939 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4940 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4941 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4942 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4943 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4944 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4945 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4946 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4947 |
9554 | 4948 static void |
4949 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4950 { | |
4951 GaimConvChat *chat; | |
11869 | 4952 GaimConvChatBuddyFlags flags; |
9554 | 4953 GaimGtkConversation *gtkconv; |
4954 GaimGtkChatPane *gtkchat; | |
4955 GtkTreeIter iter; | |
4956 GtkTreeModel *model; | |
4957 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4958 char *alias = NULL; |
9554 | 4959 |
4960 chat = GAIM_CONV_CHAT(conv); | |
4961 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4962 gtkchat = gtkconv->u.chat; | |
4963 | |
4964 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4965 | |
4966 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4967 return; | |
4968 | |
4969 while (f != 0) { | |
4970 char *val; | |
4971 | |
4972 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4973 | |
4974 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4975 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4976 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4977 g_free(val); | |
4978 break; | |
4979 } | |
4980 | |
4981 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4982 | |
4983 g_free(val); | |
4984 } | |
4985 | |
4986 if (!gaim_conv_chat_find_user(chat, user)) | |
4987 return; | |
4988 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4989 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4990 |
11869 | 4991 flags = gaim_conv_chat_user_get_flags(chat, user); |
4992 | |
4993 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4994 g_free(alias); |
9554 | 4995 } |
4996 | |
11581 | 4997 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4998 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4999 { |
11581 | 5000 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
5001 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5002 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5003 |
11581 | 5004 win = gtkconv->win; |
5005 | |
5006 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
|
5007 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5008 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5009 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5010 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
5011 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5012 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5013 |
12335 | 5014 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data) |
5015 { | |
5016 GtkIMHtmlSmiley *smiley; | |
12682 | 5017 |
12335 | 5018 smiley = (GtkIMHtmlSmiley *)user_data; |
5019 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
12682 | 5020 |
12335 | 5021 if (smiley->icon) |
5022 g_object_ref(G_OBJECT(smiley->icon)); | |
12682 | 5023 #ifdef DEBUG_CUSTOM_SMILEY |
5024 gaim_debug_info("custom-smiley", "gaim_gtkconv_custom_smiley_allocated(): got GdkPixbufAnimation %p for smiley '%s'\n", smiley->icon, smiley->smile); | |
12335 | 5025 #endif |
5026 } | |
5027 | |
5028 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data) | |
5029 { | |
5030 GtkIMHtmlSmiley *smiley; | |
5031 GtkWidget *icon = NULL; | |
5032 GtkTextChildAnchor *anchor = NULL; | |
5033 GSList *current = NULL; | |
12682 | 5034 |
12335 | 5035 smiley = (GtkIMHtmlSmiley *)user_data; |
5036 if (!smiley->imhtml) { | |
5037 #ifdef DEBUG_CUSTOM_SMILEY | |
12682 | 5038 gaim_debug_error("custom-smiley", "gaim_gtkconv_custom_smiley_closed(): orphan smiley found: %p\n", smiley); |
12335 | 5039 #endif |
5040 g_object_unref(G_OBJECT(loader)); | |
5041 smiley->loader = NULL; | |
5042 return; | |
5043 } | |
5044 | |
5045 for (current = smiley->anchors; current; current = g_slist_next(current)) { | |
5046 | |
5047 icon = gtk_image_new_from_animation(smiley->icon); | |
5048 | |
12682 | 5049 #ifdef DEBUG_CUSTOM_SMILEY |
5050 gaim_debug_info("custom-smiley", "gaim_gtkconv_custom_smiley_closed(): got GtkImage %p from GtkPixbufAnimation %p for smiley '%s'\n", | |
5051 icon, smiley->icon, smiley->smile); | |
12335 | 5052 #endif |
5053 if (icon) { | |
5054 gtk_widget_show(icon); | |
12682 | 5055 |
12335 | 5056 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
5057 | |
5058 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smiley->smile)), g_free); | |
5059 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley->smile), g_free); | |
12682 | 5060 |
12335 | 5061 if (smiley->imhtml) |
5062 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(smiley->imhtml), icon, anchor); | |
5063 } | |
5064 | |
5065 } | |
5066 | |
5067 g_slist_free(smiley->anchors); | |
5068 smiley->anchors = NULL; | |
12682 | 5069 |
12335 | 5070 g_object_unref(G_OBJECT(loader)); |
5071 smiley->loader = NULL; | |
5072 } | |
5073 | |
10526 | 5074 static gboolean |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5075 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
|
5076 { |
10526 | 5077 GtkIMHtmlSmiley *smiley; |
5078 GdkPixbufLoader *loader; | |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5079 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5080 smiley = gtk_imhtml_smiley_get(imhtml, sml, smile); |
10526 | 5081 |
5082 if (smiley) { | |
11525 | 5083 |
5084 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
5085 return FALSE; | |
5086 } | |
5087 | |
5088 /* Close the old GdkPixbufAnimation, then create a new one for | |
5089 * the smiley we are about to receive */ | |
5090 g_object_unref(G_OBJECT(smiley->icon)); | |
5091 | |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5092 /* XXX: Is it necessary to _unref the loader first? */ |
11525 | 5093 smiley->loader = gdk_pixbuf_loader_new(); |
12335 | 5094 smiley->icon = NULL; |
5095 | |
5096 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); | |
5097 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
5098 | |
11525 | 5099 return TRUE; |
10526 | 5100 } |
5101 | |
5102 loader = gdk_pixbuf_loader_new(); | |
5103 | |
5104 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
5105 /* 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
|
5106 GtkIMHtmlSmiley by opaque */ |
10526 | 5107 smiley = g_new0(GtkIMHtmlSmiley, 1); |
5108 smiley->file = NULL; | |
5109 smiley->smile = g_strdup(smile); | |
5110 smiley->loader = loader; | |
11525 | 5111 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 5112 |
12335 | 5113 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); |
5114 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
11525 | 5115 |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5116 gtk_imhtml_associate_smiley(imhtml, sml, smiley); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5117 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5118 return TRUE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5119 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5120 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5121 static gboolean |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5122 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
|
5123 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5124 GaimGtkConversation *gtkconv; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5125 struct smiley_list *list; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5126 const char *sml = NULL, *conv_sml; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5127 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5128 if (!conv || !smile || !*smile) { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5129 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5130 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5131 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5132 /* If smileys are off, return false */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5133 if (gaim_gtkthemes_smileys_disabled()) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5134 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5135 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5136 /* If possible add this smiley to the current theme. |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5137 * 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
|
5138 conv_sml = gaim_account_get_protocol_name(conv->account); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5139 gtkconv = GAIM_GTK_CONVERSATION(conv); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5140 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5141 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
|
5142 if (!strcmp(list->sml, conv_sml)) { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5143 sml = list->sml; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5144 break; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5145 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5146 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5147 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5148 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
|
5149 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5150 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5151 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
|
5152 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
|
5153 return FALSE; |
10537 | 5154 |
10526 | 5155 return TRUE; |
5156 } | |
5157 | |
10537 | 5158 static void |
10526 | 5159 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 5160 const guchar *data, gsize size) |
10526 | 5161 { |
5162 GaimGtkConversation *gtkconv; | |
5163 GtkIMHtmlSmiley *smiley; | |
10537 | 5164 GdkPixbufLoader *loader; |
10526 | 5165 const char *sml; |
5166 | |
5167 sml = gaim_account_get_protocol_name(conv->account); | |
5168 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5169 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5170 | |
10537 | 5171 if (!smiley) |
10526 | 5172 return; |
10537 | 5173 |
10526 | 5174 loader = smiley->loader; |
10537 | 5175 if (!loader) |
10526 | 5176 return; |
5177 | |
5178 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
5179 } | |
5180 | |
5181 static void | |
5182 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
5183 { | |
5184 GaimGtkConversation *gtkconv; | |
5185 GtkIMHtmlSmiley *smiley; | |
5186 GdkPixbufLoader *loader; | |
5187 const char *sml; | |
5188 | |
5189 g_return_if_fail(conv != NULL); | |
5190 g_return_if_fail(smile != NULL); | |
5191 | |
5192 sml = gaim_account_get_protocol_name(conv->account); | |
5193 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5194 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5195 | |
10537 | 5196 if (!smiley) |
10526 | 5197 return; |
5198 | |
5199 loader = smiley->loader; | |
5200 | |
10537 | 5201 if (!loader) |
10526 | 5202 return; |
10537 | 5203 |
12335 | 5204 |
11525 | 5205 |
10526 | 5206 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
5207 | |
5208 gdk_pixbuf_loader_close(loader, NULL); | |
12335 | 5209 |
10526 | 5210 } |
5211 | |
11581 | 5212 /* |
5213 * Makes sure all the menu items and all the buttons are hidden/shown and | |
5214 * sensitive/insensitive. This is called after changing tabs and when an | |
5215 * account signs on or off. | |
5216 */ | |
5217 static void | |
5218 gray_stuff_out(GaimGtkConversation *gtkconv) | |
5219 { | |
5220 GaimGtkWindow *win; | |
5221 GaimConversation *conv = gtkconv->active_conv; | |
5222 GaimConnection *gc; | |
5223 GaimPluginProtocolInfo *prpl_info = NULL; | |
5224 GdkPixbuf *window_icon = NULL; | |
5225 GtkIMHtmlButtons buttons; | |
5226 GaimAccount *account; | |
5227 | |
5228 win = gaim_gtkconv_get_window(gtkconv); | |
5229 gc = gaim_conversation_get_gc(conv); | |
5230 account = gaim_conversation_get_account(conv); | |
5231 | |
5232 if (gc != NULL) | |
5233 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
5234 | |
11594 | 5235 if (win->menu.send_to != NULL) |
11734 | 5236 update_send_to_selection(win); |
11581 | 5237 |
5238 /* | |
5239 * Handle hiding and showing stuff based on what type of conv this is. | |
5240 * Stuff that Gaim IMs support in general should be shown for IM | |
5241 * conversations. Stuff that Gaim chats support in general should be | |
5242 * shown for chat conversations. It doesn't matter whether the PRPL | |
5243 * supports it or not--that only affects if the button or menu item | |
5244 * is sensitive or not. | |
5245 */ | |
5246 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
5247 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
5248 | |
5249 /* Deal with menu items */ | |
5250 gtk_widget_show(win->menu.view_log); | |
5251 gtk_widget_show(win->menu.send_file); | |
5252 gtk_widget_show(win->menu.add_pounce); | |
5253 gtk_widget_show(win->menu.get_info); | |
5254 gtk_widget_hide(win->menu.invite); | |
5255 gtk_widget_show(win->menu.alias); | |
5256 gtk_widget_show(win->menu.block); | |
5257 | |
5258 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
5259 gtk_widget_show(win->menu.add); | |
5260 gtk_widget_hide(win->menu.remove); | |
5261 } else { | |
5262 gtk_widget_show(win->menu.remove); | |
5263 gtk_widget_hide(win->menu.add); | |
5264 } | |
5265 | |
5266 gtk_widget_show(win->menu.insert_link); | |
5267 gtk_widget_show(win->menu.insert_image); | |
5268 gtk_widget_show(win->menu.show_icon); | |
5269 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
5270 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
5271 | |
5272 /* Deal with menu items */ | |
5273 gtk_widget_show(win->menu.view_log); | |
5274 gtk_widget_hide(win->menu.send_file); | |
5275 gtk_widget_hide(win->menu.add_pounce); | |
5276 gtk_widget_hide(win->menu.get_info); | |
5277 gtk_widget_show(win->menu.invite); | |
5278 gtk_widget_show(win->menu.alias); | |
5279 gtk_widget_hide(win->menu.block); | |
5280 gtk_widget_hide(win->menu.show_icon); | |
5281 | |
5282 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
5283 /* If the chat is NOT in the buddy list */ | |
5284 gtk_widget_show(win->menu.add); | |
5285 gtk_widget_hide(win->menu.remove); | |
5286 } else { | |
5287 /* If the chat IS in the buddy list */ | |
5288 gtk_widget_hide(win->menu.add); | |
5289 gtk_widget_show(win->menu.remove); | |
5290 } | |
5291 | |
5292 gtk_widget_show(win->menu.insert_link); | |
5293 gtk_widget_hide(win->menu.insert_image); | |
5294 } | |
5295 | |
5296 /* | |
5297 * Handle graying stuff out based on whether an account is connected | |
5298 * and what features that account supports. | |
5299 */ | |
5300 if ((gc != NULL) && | |
12012 | 5301 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
5302 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
5303 { | |
11581 | 5304 /* Account is online */ |
5305 /* Deal with the toolbar */ | |
12012 | 5306 if (conv->features & GAIM_CONNECTION_HTML) |
5307 { | |
5308 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
5309 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
5310 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
5311 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
5312 { | |
5313 buttons &= ~GTK_IMHTML_GROW; | |
5314 buttons &= ~GTK_IMHTML_SHRINK; | |
5315 } | |
5316 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
5317 buttons &= ~GTK_IMHTML_LINKDESC; | |
5318 } else { | |
12216 | 5319 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
12012 | 5320 } |
12216 | 5321 |
5322 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
5323 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
5324 buttons &= ~GTK_IMHTML_IMAGE; | |
5325 | |
12012 | 5326 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); |
5327 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 5328 |
5329 /* Deal with menu items */ | |
12012 | 5330 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5331 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5332 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
5333 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
5334 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
5335 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 5336 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 5337 |
5338 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
5339 { | |
5340 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
5341 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
5342 gtk_widget_set_sensitive(win->menu.send_file, | |
5343 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
5344 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
5345 gtk_widget_set_sensitive(win->menu.alias, | |
5346 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
5347 } | |
5348 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5349 { | |
5350 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
5351 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
5352 gtk_widget_set_sensitive(win->menu.alias, | |
5353 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
5354 } | |
11581 | 5355 |
5356 /* Deal with chat userlist buttons */ | |
12012 | 5357 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5358 { | |
5359 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
5360 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
5361 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
5362 } | |
5363 } else { | |
11581 | 5364 /* Account is offline */ |
5365 /* Or it's a chat that we've left. */ | |
5366 | |
5367 /* Then deal with menu items */ | |
12012 | 5368 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5369 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
5370 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5371 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
5372 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
5373 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
5374 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
5375 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
5376 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
5377 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
5378 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 5379 |
5380 /* Deal with chat userlist buttons */ | |
12012 | 5381 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5382 { | |
5383 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5384 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5385 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5386 } | |
5387 } | |
11581 | 5388 |
5389 /* | |
5390 * Update the window's icon | |
5391 */ | |
12171 | 5392 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5393 { |
12171 | 5394 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
5395 (gtkconv->u.im->anim)) | |
5396 { | |
5397 window_icon = | |
5398 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5399 g_object_ref(window_icon); | |
5400 } else { | |
5401 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5402 } | |
5403 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5404 if (window_icon != NULL) | |
5405 g_object_unref(G_OBJECT(window_icon)); | |
5406 } | |
11581 | 5407 } |
5408 | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5409 static void |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5410 gaim_gtkconv_update_fields(GaimConversation *conv, GaimGtkConvFields fields) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5411 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5412 GaimGtkConversation *gtkconv; |
11581 | 5413 GaimGtkWindow *win; |
10116 | 5414 |
4359 | 5415 gtkconv = GAIM_GTK_CONVERSATION(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5416 if (!gtkconv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5417 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5418 win = gaim_gtkconv_get_window(gtkconv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5419 if (!win) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5420 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5421 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5422 if (fields & GAIM_GTKCONV_SET_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5423 { |
4359 | 5424 gaim_conversation_autoset_title(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5425 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5426 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5427 if (fields & GAIM_GTKCONV_BUDDY_ICON) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5428 { |
11338 | 5429 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5430 gaim_gtkconv_update_buddy_icon(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5431 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5432 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5433 if (fields & GAIM_GTKCONV_MENU) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5434 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5435 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5436 generate_send_to_items(win); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5437 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5438 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5439 if (fields & GAIM_GTKCONV_TAB_ICON) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5440 { |
6395 | 5441 update_tab_icon(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5442 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
|
5443 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5444 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5445 if ((fields & GAIM_GTKCONV_TOPIC) && |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5446 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5447 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5448 const char *topic; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5449 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5450 GaimGtkChatPane *gtkchat = gtkconv->u.chat; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5451 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5452 topic = gaim_conv_chat_get_topic(chat); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5453 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5454 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5455 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5456 topic ? topic : "", NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5457 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5458 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5459 if (fields & GAIM_GTKCONV_SMILEY_THEME) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5460 gaim_gtkthemes_smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5461 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5462 if ((fields & GAIM_GTKCONV_COLORIZE_TITLE) || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5463 (fields & GAIM_GTKCONV_SET_TITLE)) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5464 { |
9472 | 5465 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5466 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5467 GaimAccount *account = gaim_conversation_get_account(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5468 /* 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
|
5469 char style[51]; |
4736 | 5470 |
11338 | 5471 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5472 im = GAIM_CONV_IM(conv); |
4359 | 5473 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5474 if (!gaim_account_is_connected(account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5475 || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5476 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5477 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5478 else | |
5479 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5480 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5481 *style = '\0'; |
4359 | 5482 |
5483 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5484 gtk_widget_realize(gtkconv->tab_label); | |
5485 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5486 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5487 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5488 { |
11759 | 5489 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5490 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5491 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5492 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5493 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5494 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5495 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5496 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5497 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5498 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5499 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5500 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5501 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5502 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5503 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5504 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5505 { |
11758 | 5506 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5507 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5508 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5509 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5510 { |
8536 | 5511 char *html_title,*label; |
5512 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5513 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5514 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5515 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5516 style, html_title); |
8536 | 5517 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5518 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5519 g_free(label); |
4359 | 5520 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5521 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5522 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5523 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5524 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5525 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5526 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5527 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5528 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5529 gtk_window_set_title(GTK_WINDOW(win->window), title); |
9472 | 5530 |
5531 g_free(title); | |
4359 | 5532 } |
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 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5536 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5537 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5538 GaimGtkConvFields flags = 0; |
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 g_return_if_fail(conv != NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5541 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5542 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5543 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5544 flags = GAIM_GTKCONV_ALL; |
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 else if (type == GAIM_CONV_UPDATE_TYPING || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5547 type == GAIM_CONV_UPDATE_UNSEEN || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5548 type == GAIM_CONV_UPDATE_TITLE) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5549 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5550 flags = GAIM_GTKCONV_COLORIZE_TITLE; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5551 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5552 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5553 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5554 flags = GAIM_GTKCONV_TOPIC; |
4359 | 5555 } |
5556 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5557 type == GAIM_CONV_ACCOUNT_OFFLINE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5558 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5559 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
|
5560 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5561 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5562 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5563 flags = GAIM_GTKCONV_TAB_ICON; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5564 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5565 else if (type == GAIM_CONV_UPDATE_ADD || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5566 type == GAIM_CONV_UPDATE_REMOVE || |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5567 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5568 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5569 flags = GAIM_GTKCONV_SET_TITLE | GAIM_GTKCONV_MENU; |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5570 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5571 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5572 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5573 flags = GAIM_GTKCONV_BUDDY_ICON; |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5574 } |
10665 | 5575 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5576 { | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5577 flags = GAIM_GTKCONV_MENU; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5578 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5579 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5580 gaim_gtkconv_update_fields(conv, flags); |
4359 | 5581 } |
5582 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5583 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5584 { |
11581 | 5585 gaim_gtkconv_new, |
4359 | 5586 gaim_gtkconv_destroy, /* destroy_conversation */ |
5587 gaim_gtkconv_write_chat, /* write_chat */ | |
5588 gaim_gtkconv_write_im, /* write_im */ | |
5589 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5590 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5591 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5592 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5593 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12618
diff
changeset
|
5594 gaim_gtkconv_present_conversation, /* present */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5595 gaim_gtkconv_has_focus, /* has_focus */ |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12618
diff
changeset
|
5596 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
10526 | 5597 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5598 gaim_gtkconv_custom_smiley_close /* custom_smiley_close */ |
4359 | 5599 }; |
5600 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5601 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5602 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5603 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5604 return &conversation_ui_ops; |
4359 | 5605 } |
5606 | |
5607 /************************************************************************** | |
5608 * Public conversation utility functions | |
5609 **************************************************************************/ | |
5610 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5611 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5612 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5613 GaimGtkConversation *gtkconv; |
11581 | 5614 GaimGtkWindow *win; |
4359 | 5615 |
10381 | 5616 GdkPixbufLoader *loader; |
5617 GdkPixbufAnimation *anim; | |
4359 | 5618 GError *err = NULL; |
5619 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5620 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5621 size_t len; |
4359 | 5622 |
5623 GdkPixbuf *buf; | |
5624 | |
5625 GtkWidget *event; | |
5626 GtkWidget *frame; | |
5627 GdkPixbuf *scale; | |
5628 GdkPixmap *pm; | |
5629 GdkBitmap *bm; | |
9318 | 5630 int scale_width, scale_height; |
5631 | |
5632 GaimAccount *account; | |
5633 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5634 |
9324 | 5635 GaimBuddyIcon *icon; |
5636 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5637 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5638 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5639 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5640 |
5641 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5642 win = gtkconv->win; |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5643 if (conv != gtkconv->active_conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5644 return; |
10175 | 5645 |
9687 | 5646 if (!gtkconv->u.im->show_icon) |
5647 return; | |
5648 | |
9318 | 5649 account = gaim_conversation_get_account(conv); |
5650 if(account && account->gc) | |
5651 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5652 |
9845 | 5653 /* Remove the current icon stuff */ |
9885 | 5654 if (gtkconv->u.im->icon_container != NULL) |
5655 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5656 gtkconv->u.im->icon_container = NULL; | |
9845 | 5657 |
5658 if (gtkconv->u.im->anim != NULL) | |
5659 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5660 | |
9887 | 5661 gtkconv->u.im->anim = NULL; |
5662 | |
9845 | 5663 if (gtkconv->u.im->icon_timer != 0) |
5664 g_source_remove(gtkconv->u.im->icon_timer); | |
5665 | |
5666 gtkconv->u.im->icon_timer = 0; | |
5667 | |
5668 if (gtkconv->u.im->iter != NULL) | |
5669 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5670 |
10116 | 5671 gtkconv->u.im->iter = NULL; |
5672 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5673 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5674 return; |
5675 | |
5676 if (gaim_conversation_get_gc(conv) == NULL) | |
5677 return; | |
5678 | |
9324 | 5679 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5680 | |
5681 if (icon == NULL) | |
5682 return; | |
5683 | |
5684 data = gaim_buddy_icon_get_data(icon, &len); | |
5685 | |
10381 | 5686 loader = gdk_pixbuf_loader_new(); |
5687 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
12601
e63fb8e9f4ac
[gaim-migrate @ 14935]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
5688 gdk_pixbuf_loader_close(loader, &err); |
10381 | 5689 anim = gdk_pixbuf_loader_get_animation(loader); |
5690 if (anim) | |
5691 g_object_ref(G_OBJECT(anim)); | |
5692 g_object_unref(loader); | |
5693 | |
5694 if (!anim) | |
9324 | 5695 return; |
10381 | 5696 gtkconv->u.im->anim = anim; |
9324 | 5697 |
4359 | 5698 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5699 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5700 "Buddy icon error: %s\n", err->message); |
4359 | 5701 g_error_free(err); |
5702 } | |
5703 | |
5704 if (!gtkconv->u.im->anim) | |
5705 return; | |
5706 | |
5707 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5708 gtkconv->u.im->iter = NULL; | |
5709 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5710 } else { | |
5711 gtkconv->u.im->iter = | |
8496 | 5712 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5713 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5714 if (gtkconv->u.im->animate) |
10810 | 5715 start_anim(NULL, gtkconv); |
4359 | 5716 } |
5717 | |
10483 | 5718 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5719 NULL, &scale_width, &scale_height); |
4359 | 5720 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5721 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5722 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5723 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5724 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5725 GDK_INTERP_BILINEAR); |
4359 | 5726 |
5727 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5728 g_object_unref(G_OBJECT(scale)); |
4359 | 5729 |
8821 | 5730 |
9885 | 5731 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5732 |
4359 | 5733 frame = gtk_frame_new(NULL); |
5734 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5735 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5736 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5737 FALSE, FALSE, 0); | |
8821 | 5738 |
4359 | 5739 event = gtk_event_box_new(); |
5740 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5741 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5742 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5743 gtk_widget_show(event); |
5744 | |
4635 | 5745 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5746 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5747 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5748 gtk_widget_show(gtkconv->u.im->icon); | |
5749 | |
4793 | 5750 g_object_unref(G_OBJECT(pm)); |
4359 | 5751 |
5752 if (bm) | |
4793 | 5753 g_object_unref(G_OBJECT(bm)); |
7143 | 5754 |
10356 | 5755 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5756 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5757 |
9885 | 5758 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5759 gtk_widget_show(frame); |
5760 | |
7143 | 5761 /* The buddy icon code needs badly to be fixed. */ |
5762 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5763 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5764 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
4359 | 5765 } |
5766 | |
5767 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5768 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5769 { |
11581 | 5770 GaimGtkWindow *win; |
4359 | 5771 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5772 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5773 return; |
5774 | |
11581 | 5775 win = GAIM_GTK_CONVERSATION(conv)->win; |
5776 | |
5777 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5778 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5779 } |
5780 | |
5781 int | |
11614 | 5782 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5783 { |
4359 | 5784 gint nb_x, nb_y, x_rel, y_rel; |
5785 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5786 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5787 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5788 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5789 gboolean horiz; |
4359 | 5790 |
11614 | 5791 if (to_right) |
5792 *to_right = FALSE; | |
5793 | |
11581 | 5794 notebook = GTK_NOTEBOOK(win->notebook); |
5795 | |
5796 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5797 x_rel = x - nb_x; |
5798 y_rel = y - nb_y; | |
5799 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5800 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5801 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5802 |
11780 | 5803 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5804 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5805 #else |
5806 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5807 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5808 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5809 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5810 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5811 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5812 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5813 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5814 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5815 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5816 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5817 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
|
5818 page_num = i; |
11614 | 5819 |
5820 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5821 *to_right = TRUE; | |
5822 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5823 break; |
4359 | 5824 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5825 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5826 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5827 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
|
5828 page_num = i; |
11614 | 5829 |
5830 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5831 *to_right = TRUE; | |
5832 | |
4359 | 5833 break; |
5834 } | |
5835 } | |
5836 } | |
5837 | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5838 if (page_num == -1) { |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5839 /* Add after the last tab */ |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5840 page_num = count - 1; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5841 } |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5842 |
4359 | 5843 return page_num; |
5844 } | |
5845 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5846 static void |
12816 | 5847 close_on_tabs_pref_cb(const char *name, GaimPrefType type, |
5848 gconstpointer value, gpointer data) | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5849 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5850 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5851 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5852 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5853 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5854 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5855 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5856 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5857 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5858 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5859 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5860 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5861 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5862 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5863 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5864 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5865 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5866 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5867 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5868 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5869 static void |
12816 | 5870 spellcheck_pref_cb(const char *name, GaimPrefType type, |
5871 gconstpointer value, gpointer data) | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5872 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5873 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5874 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5875 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5876 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5877 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5878 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5879 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5880 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5881 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5882 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5883 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5884 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5885 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5886 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5887 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5888 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5889 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5890 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5891 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5892 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5893 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5894 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5895 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5896 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5897 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5898 static void |
12816 | 5899 tab_side_pref_cb(const char *name, GaimPrefType type, |
5900 gconstpointer value, gpointer data) | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5901 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5902 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5903 GtkPositionType pos; |
11581 | 5904 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5905 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5906 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5907 |
11581 | 5908 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5909 win = l->data; | |
5910 | |
11619 | 5911 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
|
5912 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5913 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5914 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5915 static void |
12188 | 5916 show_timestamps_pref_cb(const char *name, GaimPrefType type, |
12816 | 5917 gconstpointer value, gpointer data) |
12188 | 5918 { |
5919 GList *l; | |
5920 GaimConversation *conv; | |
5921 GaimGtkConversation *gtkconv; | |
5922 GaimGtkWindow *win; | |
5923 | |
5924 for (l = gaim_get_conversations(); l != NULL; l = l->next) | |
5925 { | |
5926 conv = (GaimConversation *)l->data; | |
5927 | |
5928 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
5929 continue; | |
5930 | |
5931 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5932 win = gtkconv->win; | |
5933 | |
5934 gtk_check_menu_item_set_active( | |
5935 GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
5936 (gboolean)GPOINTER_TO_INT(value)); | |
5937 | |
5938 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
5939 (gboolean)GPOINTER_TO_INT(value)); | |
5940 } | |
5941 } | |
5942 | |
5943 static void | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5944 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
12816 | 5945 gconstpointer value, gpointer data) |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5946 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5947 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5948 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5949 GaimGtkConversation *gtkconv; |
11581 | 5950 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5951 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5952 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5953 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5954 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5955 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5956 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5957 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5958 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5959 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5960 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5961 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5962 gtk_check_menu_item_set_active( |
11581 | 5963 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5964 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5965 |
5966 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5967 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5968 else |
8317 | 5969 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5970 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5971 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5972 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5973 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5974 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
12816 | 5975 gconstpointer value, gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5976 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5977 GList *l; |
8189 | 5978 GaimConversation *conv; |
5979 GaimGtkConversation *gtkconv; | |
11581 | 5980 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5981 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5982 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
|
5983 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5984 |
8189 | 5985 /* Set the "animate" flag for each icon based on the new preference */ |
5986 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5987 conv = (GaimConversation *)l->data; | |
5988 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5989 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5990 } |
8189 | 5991 |
5992 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5993 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5994 win = l->data; | |
5995 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5996 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5997 } |
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 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6000 static void |
12816 | 6001 show_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
6002 gconstpointer value, gpointer data) | |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6003 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6004 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6005 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6006 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6007 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6008 |
11338 | 6009 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 6010 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6011 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6012 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6013 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
6014 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6015 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
12816 | 6016 gconstpointer value, gpointer data) |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6017 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6018 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6019 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6020 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6021 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6022 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6023 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6024 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6025 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6026 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6027 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6028 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6029 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
|
6030 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6031 |
12310 | 6032 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
|
6033 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6034 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6035 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6036 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6037 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6038 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6039 |
12310 | 6040 if(!gaim_status_is_available( |
6041 gaim_account_get_active_status( | |
6042 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6043 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6044 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6045 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6046 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6047 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6048 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6049 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6050 static void |
12816 | 6051 hide_new_pref_cb(const char *name, GaimPrefType type, |
6052 gconstpointer value, gpointer data) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6053 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6054 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6055 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6056 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6057 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6058 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6059 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6060 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6061 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6062 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
|
6063 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6064 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6065 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
|
6066 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6067 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6068 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6069 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6070 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6071 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6072 |
12310 | 6073 if(when_away && !gaim_status_is_available( |
6074 gaim_account_get_active_status( | |
6075 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6076 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6077 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6078 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6079 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6080 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6081 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6082 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6083 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6084 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6085 conv_placement_pref_cb(const char *name, GaimPrefType type, |
12816 | 6086 gconstpointer value, gpointer data) |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6087 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6088 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6089 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6090 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6091 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6092 |
11581 | 6093 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6094 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6095 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6096 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6097 |
11581 | 6098 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6099 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6100 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6101 static GaimGtkConversation * |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6102 get_gtkconv_with_contact(GaimContact *contact) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6103 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6104 GaimBlistNode *node; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6105 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6106 node = ((GaimBlistNode*)contact)->child; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6107 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6108 for (; node; node = node->next) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6109 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6110 GaimBuddy *buddy = (GaimBuddy*)node; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6111 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6112 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
|
6113 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6114 return GAIM_GTK_CONVERSATION(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6115 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6116 return NULL; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6117 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6118 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6119 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6120 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6121 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6122 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6123 GaimAccount *account; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6124 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6125 account = gaim_connection_get_account(gc); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6126 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6127 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6128 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6129 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6130 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6131 /* 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
|
6132 * case of this account matching one of the other buddies in |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6133 * one of the contacts containing the buddy corresponding to |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6134 * a conversation. It's easier to just update them all. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6135 /* if (gaim_conversation_get_account(conv) == account) */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6136 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON | |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6137 GAIM_GTKCONV_MENU | GAIM_GTKCONV_COLORIZE_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6138 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6139 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6140 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6141 static gboolean |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6142 update_buddy_status_timeout(GaimBuddy *buddy) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6143 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6144 /* To remove the signing-on/off door icon */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6145 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6146 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6147 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
|
6148 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6149 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6150 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6151 return FALSE; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6152 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6153 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6154 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6155 update_buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *newstatus) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6156 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6157 GaimGtkConversation *gtkconv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6158 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6159 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6160 gtkconv = get_gtkconv_with_contact(gaim_buddy_get_contact(buddy)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6161 if (gtkconv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6162 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6163 conv = gtkconv->active_conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6164 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
|
6165 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
|
6166 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_MENU); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6167 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6168 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6169 /* 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
|
6170 g_timeout_add(11000, (GSourceFunc)update_buddy_status_timeout, buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6171 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6172 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6173 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6174 update_buddy_idle_changed(GaimBuddy *buddy, gboolean old, gboolean newidle) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6175 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6176 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6177 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6178 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
|
6179 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6180 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6181 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6182 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6183 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6184 update_buddy_icon(GaimBuddy *buddy) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6185 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6186 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6187 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6188 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
|
6189 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6190 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_BUDDY_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6191 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6192 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6193 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6194 update_buddy_sign(GaimBuddy *buddy, const char *which) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6195 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6196 GaimPresence *presence; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6197 GaimStatus *on, *off; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6198 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6199 presence = gaim_buddy_get_presence(buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6200 if (!presence) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6201 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6202 off = gaim_presence_get_status(presence, "offline"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6203 on = gaim_presence_get_status(presence, "available"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6204 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6205 if (*(which+1) == 'f') |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6206 update_buddy_status_changed(buddy, on, off); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6207 else |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6208 update_buddy_status_changed(buddy, off, on); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6209 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6210 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6211 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6212 update_conversation_switched(GaimConversation *conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6213 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6214 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
|
6215 GAIM_GTKCONV_MENU | GAIM_GTKCONV_BUDDY_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6216 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6217 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6218 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6219 update_buddy_typing(GaimAccount *account, const char *who) |
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 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6222 GaimGtkConversation *gtkconv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6223 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6224 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
|
6225 if (!conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6226 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6227 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6228 gtkconv = GAIM_GTK_CONVERSATION(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6229 if (gtkconv && gtkconv->active_conv == conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6230 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_COLORIZE_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6231 } |
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 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6234 update_chat(GaimConversation *conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6235 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6236 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TOPIC | |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6237 GAIM_GTKCONV_MENU | GAIM_GTKCONV_SET_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6238 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6239 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6240 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6241 update_chat_topic(GaimConversation *conv, const char *old, const char *new) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6242 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6243 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TOPIC); |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6244 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6245 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6246 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6247 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6248 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6249 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6250 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6251 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6252 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6253 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6254 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
6255 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6256 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6257 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6258 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6259 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6260 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6261 gaim_prefs_add_none("/gaim/gtk/conversations"); |
12553 | 6262 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
|
6263 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6264 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6265 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6266 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6267 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
6268 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
6269 |
12264 | 6270 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6271 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 6272 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 6273 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6274 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 6275 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 6276 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
6277 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6278 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6279 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6280 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6281 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
|
6282 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6283 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6284 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6285 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6286 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6287 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6288 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6289 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6290 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6291 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 6292 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6293 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 6294 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6295 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6296 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6297 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 6298 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
|
6299 |
12616
eee2042ad4f4
[gaim-migrate @ 14952]
Richard Laager <rlaager@wiktel.com>
parents:
12604
diff
changeset
|
6300 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
|
6301 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6302 /* Connect callbacks. */ |
10087 | 6303 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
|
6304 close_on_tabs_pref_cb, NULL); |
12188 | 6305 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
6306 show_timestamps_pref_cb, NULL); | |
10087 | 6307 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
|
6308 show_formatting_toolbar_pref_cb, NULL); |
10087 | 6309 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6310 spellcheck_pref_cb, NULL); |
10087 | 6311 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6312 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6313 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6314 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6315 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6316 |
10087 | 6317 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6318 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6319 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6320 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6321 /* IM callbacks */ |
10087 | 6322 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
|
6323 animate_buddy_icons_pref_cb, NULL); |
10087 | 6324 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
|
6325 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6326 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6327 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6328 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6329 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6330 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6331 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6332 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6333 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
6334 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6335 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
12837
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6336 gaim_value_new(GAIM_TYPE_BOXED, |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6337 "GaimGtkWindow *"), |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6338 gaim_value_new(GAIM_TYPE_BOXED, |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6339 "GaimGtkWindow *")); |
9167 | 6340 |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6341 gaim_signal_register(handle, "conversation-timestamp", |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6342 gaim_marshal_POINTER__POINTER_POINTER, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6343 gaim_value_new(GAIM_TYPE_POINTER), 2, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6344 gaim_value_new(GAIM_TYPE_SUBTYPE, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6345 GAIM_SUBTYPE_CONVERSATION), |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6346 gaim_value_new(GAIM_TYPE_POINTER)); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6347 |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6348 gaim_signal_register(handle, "displaying-im-msg", |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6349 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6350 gaim_value_new(GAIM_TYPE_BOOLEAN), 4, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6351 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6352 GAIM_SUBTYPE_ACCOUNT), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6353 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6354 GAIM_SUBTYPE_CONVERSATION), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6355 gaim_value_new_outgoing(GAIM_TYPE_STRING), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6356 gaim_value_new(G_TYPE_INT)); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6357 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6358 gaim_signal_register(handle, "displayed-im-msg", |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6359 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6360 NULL, 4, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6361 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6362 GAIM_SUBTYPE_ACCOUNT), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6363 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6364 GAIM_SUBTYPE_CONVERSATION), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6365 gaim_value_new(GAIM_TYPE_STRING), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6366 gaim_value_new(G_TYPE_INT)); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6367 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6368 gaim_signal_register(handle, "displaying-chat-msg", |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6369 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6370 gaim_value_new(GAIM_TYPE_BOOLEAN), 4, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6371 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6372 GAIM_SUBTYPE_ACCOUNT), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6373 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6374 GAIM_SUBTYPE_CONVERSATION), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6375 gaim_value_new_outgoing(GAIM_TYPE_STRING), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6376 gaim_value_new(G_TYPE_INT)); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6377 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6378 gaim_signal_register(handle, "displayed-chat-msg", |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6379 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6380 NULL, 4, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6381 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6382 GAIM_SUBTYPE_ACCOUNT), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6383 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6384 GAIM_SUBTYPE_CONVERSATION), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6385 gaim_value_new(GAIM_TYPE_STRING), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6386 gaim_value_new(G_TYPE_INT)); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6387 |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6388 gaim_signal_register(handle, "conversation-switched", |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6389 gaim_marshal_VOID__POINTER_POINTER, NULL, 1, |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6390 gaim_value_new(GAIM_TYPE_SUBTYPE, |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6391 GAIM_SUBTYPE_CONVERSATION)); |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6392 |
9167 | 6393 /********************************************************************** |
6394 * Register commands | |
6395 **********************************************************************/ | |
9829 | 6396 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
6397 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
6398 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 6399 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
6400 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6401 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 6402 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
6403 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6404 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
|
6405 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6406 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6407 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 6408 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 6409 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
6410 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 6411 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6412 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6413 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6414 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6415 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6416 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6417 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6418 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6419 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6420 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6421 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6422 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6423 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6424 handle, G_CALLBACK(received_im_msg_cb), NULL); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6425 |
11581 | 6426 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6427 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6428 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6429 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6430 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6431 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6432 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6433 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6434 /* Callbacks to update a conversation */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6435 gaim_signal_connect(blist_handle, "buddy-added", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6436 G_CALLBACK(buddy_update_cb), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6437 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6438 G_CALLBACK(buddy_update_cb), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6439 gaim_signal_connect(blist_handle, "buddy-signed-on", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6440 handle, GAIM_CALLBACK(update_buddy_sign), "on"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6441 gaim_signal_connect(blist_handle, "buddy-signed-off", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6442 handle, GAIM_CALLBACK(update_buddy_sign), "off"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6443 gaim_signal_connect(blist_handle, "buddy-status-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6444 handle, GAIM_CALLBACK(update_buddy_status_changed), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6445 gaim_signal_connect(blist_handle, "buddy-idle-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6446 handle, GAIM_CALLBACK(update_buddy_idle_changed), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6447 gaim_signal_connect(blist_handle, "buddy-icon-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6448 handle, GAIM_CALLBACK(update_buddy_icon), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6449 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6450 handle, GAIM_CALLBACK(update_buddy_typing), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6451 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing-stopped", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6452 handle, GAIM_CALLBACK(update_buddy_typing), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6453 gaim_signal_connect(gaim_gtk_conversations_get_handle(), "conversation-switched", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6454 handle, GAIM_CALLBACK(update_conversation_switched), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6455 gaim_signal_connect(gaim_conversations_get_handle(), "chat-left", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6456 GAIM_CALLBACK(update_chat), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6457 gaim_signal_connect(gaim_conversations_get_handle(), "chat-joined", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6458 GAIM_CALLBACK(update_chat), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6459 gaim_signal_connect(gaim_conversations_get_handle(), "chat-topic-changed", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6460 GAIM_CALLBACK(update_chat_topic), NULL); |
12806
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6461 gaim_signal_connect_priority(gaim_conversations_get_handle(), "conversation-updated", handle, |
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6462 GAIM_CALLBACK(gaim_gtkconv_updated), NULL, |
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6463 GAIM_SIGNAL_PRIORITY_LOWEST); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6464 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6465 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6466 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6467 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6468 { |
10443 | 6469 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 6470 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6471 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6472 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6473 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6474 } |
11581 | 6475 |
6476 | |
6477 | |
6478 | |
6479 | |
6480 | |
6481 | |
6482 | |
6483 | |
6484 | |
6485 | |
6486 | |
6487 | |
6488 | |
6489 | |
6490 | |
6491 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
6492 * and touch each others' private members all day long */ | |
6493 | |
6494 /** | |
6495 * @file gtkconvwin.c GTK+ Conversation Window API | |
6496 * @ingroup gtkui | |
6497 * | |
6498 * gaim | |
6499 * | |
6500 * Gaim is the legal property of its developers, whose names are too numerous | |
6501 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6502 * source distribution. | |
6503 * | |
6504 * This program is free software; you can redistribute it and/or modify | |
6505 * it under the terms of the GNU General Public License as published by | |
6506 * the Free Software Foundation; either version 2 of the License, or | |
6507 * (at your option) any later version. | |
6508 * | |
6509 * This program is distributed in the hope that it will be useful, | |
6510 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
6511 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
6512 * GNU General Public License for more details. | |
6513 * | |
6514 * You should have received a copy of the GNU General Public License | |
6515 * along with this program; if not, write to the Free Software | |
6516 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
6517 * | |
6518 */ | |
6519 #include "internal.h" | |
6520 #include "gtkgaim.h" | |
6521 | |
6522 | |
6523 #include <gdk/gdkkeysyms.h> | |
6524 | |
6525 #include "account.h" | |
6526 #include "cmds.h" | |
6527 #include "debug.h" | |
6528 #include "imgstore.h" | |
6529 #include "log.h" | |
6530 #include "notify.h" | |
6531 #include "prpl.h" | |
6532 #include "request.h" | |
6533 #include "util.h" | |
6534 | |
6535 #include "gtkdnd-hints.h" | |
6536 #include "gtkblist.h" | |
6537 #include "gtkconv.h" | |
6538 #include "gtkdialogs.h" | |
6539 #include "gtkmenutray.h" | |
6540 #include "gtkpounce.h" | |
6541 #include "gtkprefs.h" | |
6542 #include "gtkprivacy.h" | |
6543 #include "gtkutils.h" | |
6544 #include "gtkstock.h" | |
6545 #include "gtkimhtml.h" | |
6546 #include "gtkimhtmltoolbar.h" | |
6547 | |
6548 static void | |
6549 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
6550 { | |
6551 gtk_widget_destroy(warn_close_dialog); | |
6552 warn_close_dialog = NULL; | |
6553 | |
6554 if (resp == GTK_RESPONSE_OK) | |
6555 gaim_gtk_conv_window_destroy(win); | |
6556 } | |
6557 | |
6558 static void | |
6559 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
6560 { | |
6561 GtkWidget *label; | |
6562 GtkWidget *vbox, *hbox; | |
6563 GtkWidget *img; | |
6564 | |
6565 g_return_if_fail(warn_close_dialog == NULL); | |
6566 | |
6567 | |
6568 warn_close_dialog = gtk_dialog_new_with_buttons( | |
12660 | 6569 _("Confirm close"), |
6570 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
6571 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
6572 GAIM_STOCK_CLOSE_TABS, GTK_RESPONSE_OK, NULL); | |
11581 | 6573 |
6574 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
6575 GTK_RESPONSE_OK); | |
6576 | |
6577 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
6578 6); | |
6579 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
6580 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
6581 FALSE); | |
6582 | |
6583 /* Setup the outside spacing. */ | |
6584 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
6585 | |
6586 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
6587 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
6588 | |
6589 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
6590 GTK_ICON_SIZE_DIALOG); | |
6591 /* Setup the inner hbox and put the dialog's icon in it. */ | |
6592 hbox = gtk_hbox_new(FALSE, 12); | |
6593 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
6594 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
6595 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
6596 | |
6597 /* Setup the right vbox. */ | |
6598 vbox = gtk_vbox_new(FALSE, 12); | |
6599 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
6600 | |
6601 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
6602 gtk_widget_set_size_request(label, 350, -1); | |
6603 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
6604 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
6605 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
6606 | |
6607 /* Connect the signals. */ | |
6608 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
6609 G_CALLBACK(do_close), gtkwin); | |
6610 | |
6611 } | |
6612 | |
6613 /************************************************************************** | |
6614 * Callbacks | |
6615 **************************************************************************/ | |
6616 | |
6617 static gboolean | |
6618 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
6619 { | |
6620 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6621 GList *l; |
11581 | 6622 |
6623 /* If there are unread messages then show a warning dialog */ | |
6624 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
6625 l != NULL; l = l->next) | |
6626 { | |
6627 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6628 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
|
6629 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6630 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6631 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6632 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6633 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6634 return TRUE; |
11581 | 6635 } |
6636 } | |
6637 | |
6638 gaim_gtk_conv_window_destroy(win); | |
6639 | |
6640 return TRUE; | |
6641 } | |
6642 | |
11604 | 6643 static void |
6644 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
6645 { | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6646 if (state == GAIM_UNSEEN_NONE) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6647 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6648 gtkconv->unseen_count = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6649 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6650 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6651 else |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6652 { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6653 if (state >= GAIM_UNSEEN_TEXT) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6654 gtkconv->unseen_count++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6655 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6656 if (state > gtkconv->unseen_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6657 gtkconv->unseen_state = state; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6658 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6659 |
12806
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6660 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
|
6661 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6662 |
11581 | 6663 /* |
6664 * When a conversation window is focused, we know the user | |
6665 * has looked at it so we know there are no longer unseen | |
6666 * messages. | |
6667 */ | |
6668 static gint | |
6669 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6670 { | |
6671 GaimGtkWindow *win = d; | |
11604 | 6672 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6673 | |
6674 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6675 |
6676 return FALSE; | |
6677 } | |
6678 | |
11851 | 6679 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6680 /* Courtesy of Galeon! */ |
6681 static void | |
6682 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6683 { | |
6684 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6685 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6686 } | |
11851 | 6687 #endif |
11581 | 6688 |
6689 static void | |
6690 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6691 { | |
6692 static GdkCursor *cursor = NULL; | |
6693 | |
6694 gtkwin->in_drag = TRUE; | |
6695 | |
6696 if (gtkwin->drag_leave_signal) { | |
6697 g_signal_handler_disconnect(G_OBJECT(widget), | |
6698 gtkwin->drag_leave_signal); | |
6699 gtkwin->drag_leave_signal = 0; | |
6700 } | |
6701 | |
6702 if (cursor == NULL) | |
6703 cursor = gdk_cursor_new(GDK_FLEUR); | |
6704 | |
6705 /* Grab the pointer */ | |
6706 gtk_grab_add(gtkwin->notebook); | |
6707 #ifndef _WIN32 | |
6708 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6709 always be true after a button press. */ | |
6710 if (!gdk_pointer_is_grabbed()) | |
6711 #endif | |
6712 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6713 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6714 NULL, cursor, GDK_CURRENT_TIME); | |
6715 } | |
6716 | |
6717 static gboolean | |
6718 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6719 { | |
6720 | |
6721 /* | |
6722 * Make sure the user moved the mouse far enough for the | |
6723 * drag to be initiated. | |
6724 */ | |
6725 if (win->in_predrag) { | |
6726 if (e->x_root < win->drag_min_x || | |
6727 e->x_root >= win->drag_max_x || | |
6728 e->y_root < win->drag_min_y || | |
6729 e->y_root >= win->drag_max_y) { | |
6730 | |
6731 win->in_predrag = FALSE; | |
6732 notebook_init_grab(win, widget); | |
6733 } | |
6734 } | |
6735 else { /* Otherwise, draw the arrows. */ | |
6736 GaimGtkWindow *dest_win; | |
6737 GtkNotebook *dest_notebook; | |
6738 GtkWidget *tab; | |
6739 gint nb_x, nb_y, page_num; | |
6740 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6741 gboolean horiz_tabs = FALSE; | |
11614 | 6742 GaimGtkConversation *gtkconv; |
6743 gboolean to_right = FALSE; | |
11581 | 6744 |
6745 /* Get the window that the cursor is over. */ | |
6746 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6747 | |
6748 if (dest_win == NULL) { | |
6749 dnd_hints_hide_all(); | |
6750 | |
6751 return TRUE; | |
6752 } | |
6753 | |
6754 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6755 | |
6756 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6757 | |
6758 arrow1_x = arrow2_x = nb_x; | |
6759 arrow1_y = arrow2_y = nb_y; | |
6760 | |
6761 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6762 e->x_root, e->y_root, &to_right); |
6763 to_right = to_right && (win != dest_win); | |
11581 | 6764 |
6765 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6766 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6767 | |
6768 horiz_tabs = TRUE; | |
6769 } | |
6770 | |
11614 | 6771 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6772 tab = gtkconv->tabby; | |
11581 | 6773 |
6774 if (horiz_tabs) { | |
6775 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6776 | |
11614 | 6777 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6778 arrow1_x += tab->allocation.width; |
6779 arrow2_x += tab->allocation.width; | |
6780 } | |
6781 | |
6782 arrow1_y = nb_y + tab->allocation.y; | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6783 arrow2_y = nb_y + tab->allocation.y + tab->allocation.height; |
11581 | 6784 } else { |
6785 arrow1_x = nb_x + tab->allocation.x; | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6786 arrow2_x = nb_x + tab->allocation.x + tab->allocation.width; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6787 arrow1_y = arrow2_y = nb_y + tab->allocation.y; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6788 |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6789 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6790 arrow1_y += tab->allocation.height; |
6791 arrow2_y += tab->allocation.height; | |
6792 } | |
6793 } | |
6794 | |
6795 if (horiz_tabs) { | |
6796 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6797 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6798 } else { | |
6799 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6800 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6801 } | |
6802 } | |
6803 | |
6804 return TRUE; | |
6805 } | |
6806 | |
6807 static gboolean | |
6808 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6809 { | |
6810 if (win->in_drag) | |
6811 return FALSE; | |
6812 | |
6813 if (e->x_root < win->drag_min_x || | |
6814 e->x_root >= win->drag_max_x || | |
6815 e->y_root < win->drag_min_y || | |
6816 e->y_root >= win->drag_max_y) { | |
6817 | |
6818 win->in_predrag = FALSE; | |
6819 notebook_init_grab(win, widget); | |
6820 } | |
6821 | |
6822 return TRUE; | |
6823 } | |
6824 | |
6825 /* | |
6826 * THANK YOU GALEON! | |
6827 */ | |
6828 static gboolean | |
6829 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6830 { | |
6831 gint nb_x, nb_y, x_rel, y_rel; | |
6832 int tab_clicked; | |
6833 GtkWidget *page; | |
6834 GtkWidget *tab; | |
6835 | |
6836 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6837 return FALSE; | |
6838 | |
6839 | |
6840 if (win->in_drag) { | |
6841 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6842 "Already in the middle of a window drag at tab_press_cb\n"); | |
6843 return TRUE; | |
6844 } | |
6845 | |
6846 /* | |
6847 * Make sure a tab was actually clicked. The arrow buttons | |
6848 * mess things up. | |
6849 */ | |
11614 | 6850 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6851 |
6852 if (tab_clicked == -1) | |
6853 return FALSE; | |
6854 | |
6855 /* | |
6856 * Get the relative position of the press event, with regards to | |
6857 * the position of the notebook. | |
6858 */ | |
6859 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6860 | |
6861 x_rel = e->x_root - nb_x; | |
6862 y_rel = e->y_root - nb_y; | |
6863 | |
6864 /* Reset the min/max x/y */ | |
6865 win->drag_min_x = 0; | |
6866 win->drag_min_y = 0; | |
6867 win->drag_max_x = 0; | |
6868 win->drag_max_y = 0; | |
6869 | |
6870 /* Find out which tab was dragged. */ | |
6871 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6872 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6873 | |
6874 win->drag_min_x = tab->allocation.x + nb_x; | |
6875 win->drag_min_y = tab->allocation.y + nb_y; | |
6876 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6877 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6878 | |
6879 /* Make sure the click occurred in the tab. */ | |
6880 if (e->x_root < win->drag_min_x || | |
6881 e->x_root >= win->drag_max_x || | |
6882 e->y_root < win->drag_min_y || | |
6883 e->y_root >= win->drag_max_y) { | |
6884 | |
6885 return FALSE; | |
6886 } | |
6887 | |
6888 win->in_predrag = TRUE; | |
6889 win->drag_tab = tab_clicked; | |
6890 | |
6891 /* Connect the new motion signals. */ | |
6892 win->drag_motion_signal = | |
6893 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6894 G_CALLBACK(notebook_motion_cb), win); | |
6895 | |
6896 win->drag_leave_signal = | |
6897 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6898 G_CALLBACK(notebook_leave_cb), win); | |
6899 | |
6900 return FALSE; | |
6901 } | |
6902 | |
6903 static gboolean | |
6904 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6905 { | |
6906 GaimGtkWindow *dest_win; | |
6907 GaimConversation *conv; | |
6908 GaimGtkConversation *gtkconv; | |
6909 gint dest_page_num = 0; | |
6910 gboolean new_window = FALSE; | |
11614 | 6911 gboolean to_right = FALSE; |
11581 | 6912 |
6913 /* | |
6914 * Don't check to make sure that the event's window matches the | |
6915 * widget's, because we may be getting an event passed on from the | |
6916 * close button. | |
6917 */ | |
6918 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6919 return FALSE; | |
6920 | |
6921 if (gdk_pointer_is_grabbed()) { | |
6922 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6923 gtk_grab_remove(widget); | |
6924 } | |
6925 | |
6926 if (!win->in_predrag && !win->in_drag) | |
6927 return FALSE; | |
6928 | |
6929 /* Disconnect the motion signal. */ | |
6930 if (win->drag_motion_signal) { | |
6931 g_signal_handler_disconnect(G_OBJECT(widget), | |
6932 win->drag_motion_signal); | |
6933 | |
6934 win->drag_motion_signal = 0; | |
6935 } | |
6936 | |
6937 /* | |
6938 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6939 * signal. | |
6940 */ | |
6941 if (win->in_predrag) { | |
6942 win->in_predrag = FALSE; | |
6943 | |
6944 if (win->drag_leave_signal) { | |
6945 g_signal_handler_disconnect(G_OBJECT(widget), | |
6946 win->drag_leave_signal); | |
6947 | |
6948 win->drag_leave_signal = 0; | |
6949 } | |
6950 } | |
6951 | |
6952 /* If we're not in drag... */ | |
6953 /* We're perfectly normal people! */ | |
6954 if (!win->in_drag) | |
6955 return FALSE; | |
6956 | |
6957 win->in_drag = FALSE; | |
6958 | |
6959 dnd_hints_hide_all(); | |
6960 | |
6961 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6962 | |
6963 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6964 | |
6965 if (dest_win == NULL) { | |
6966 /* If the current window doesn't have any other conversations, | |
6967 * there isn't much point transferring the conv to a new window. */ | |
6968 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6969 /* Make a new window to stick this to. */ | |
6970 dest_win = gaim_gtk_conv_window_new(); | |
6971 new_window = TRUE; | |
6972 } | |
6973 } | |
6974 | |
6975 if (dest_win == NULL) | |
6976 return FALSE; | |
6977 | |
6978 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6979 "conversation-dragging", win, dest_win); | |
6980 | |
6981 /* Get the destination page number. */ | |
6982 if (!new_window) | |
6983 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6984 e->x_root, e->y_root, &to_right); |
11581 | 6985 |
6986 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6987 | |
6988 if (win == dest_win) { | |
6989 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6990 } else { | |
6991 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6992 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 6993 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 6994 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
6995 if (new_window) { | |
6996 gint win_width, win_height; | |
6997 | |
6998 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6999 &win_width, &win_height); | |
7000 | |
7001 gtk_window_move(GTK_WINDOW(dest_win->window), | |
7002 e->x_root - (win_width / 2), | |
7003 e->y_root - (win_height / 2)); | |
7004 | |
7005 gaim_gtk_conv_window_show(dest_win); | |
7006 } | |
7007 } | |
7008 | |
7009 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
7010 | |
7011 return TRUE; | |
7012 } | |
7013 | |
7014 | |
7015 static void | |
7016 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
7017 gpointer user_data) | |
7018 { | |
7019 GaimGtkWindow *win; | |
7020 GaimConversation *conv; | |
7021 GaimGtkConversation *gtkconv; | |
7022 | |
7023 win = user_data; | |
7024 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
7025 | |
7026 g_return_if_fail(conv != NULL); | |
7027 | |
7028 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
7029 return; | |
7030 | |
7031 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7032 | |
7033 stop_anim(NULL, gtkconv); | |
7034 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7035 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7036 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7037 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7038 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7039 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7040 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7041 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7042 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7043 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7044 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7045 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7046 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7047 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7048 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7049 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7050 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7051 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7052 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7053 /* 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
|
7054 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7055 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7056 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7057 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7058 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7059 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7060 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7061 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7062 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7063 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7064 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7065 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7066 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7067 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7068 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7069 GaimGtkWindow *win; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7070 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7071 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7072 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7073 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7074 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7075 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7076 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7077 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7078 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7079 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7080 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7081 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7082 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7083 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7084 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7085 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7086 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7087 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7088 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7089 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7090 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7091 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7092 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7093 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7094 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7095 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7096 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7097 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7098 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7099 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7100 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7101 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7102 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7103 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7104 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7105 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7106 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7107 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7108 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7109 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
7110 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
|
7111 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7112 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7113 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7114 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7115 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7116 } |
12188 | 7117 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7118 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7119 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7120 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7121 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7122 |
12824
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7123 item = gtk_menu_item_new_with_label("Close other tabs"); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7124 gtk_widget_show(item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7125 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7126 g_signal_connect(G_OBJECT(item), "activate", |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7127 G_CALLBACK(close_others_cb), menu); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7128 |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7129 item = gtk_menu_item_new_with_label("Close all tabs"); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7130 gtk_widget_show(item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7131 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7132 g_signal_connect(G_OBJECT(item), "activate", |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7133 G_CALLBACK(close_window), win); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7134 |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7135 gaim_separator(menu); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7136 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7137 item = gtk_menu_item_new_with_label("Detach this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7138 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7139 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7140 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7141 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7142 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7143 item = gtk_menu_item_new_with_label("Close this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7144 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7145 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7146 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7147 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7148 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7149 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7150 } |
11581 | 7151 |
7152 static void | |
7153 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
7154 gpointer user_data) | |
7155 { | |
7156 GaimGtkWindow *win; | |
7157 GaimConversation *conv; | |
7158 GaimGtkConversation *gtkconv; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7159 const char *sound_method; |
11581 | 7160 |
7161 win = user_data; | |
7162 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
7163 conv = gtkconv->active_conv; | |
7164 | |
7165 g_return_if_fail(conv != NULL); | |
7166 | |
7167 /* | |
7168 * Only set "unseen" to "none" if the window has focus | |
7169 */ | |
7170 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 7171 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 7172 |
7173 /* Update the menubar */ | |
7174 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
7175 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
|
7176 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
7177 |
11594 | 7178 generate_send_to_items(win); |
7179 | |
11604 | 7180 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 7181 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7182 sound_method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7183 if (strcmp(sound_method, "none") != 0) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7184 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
|
7185 gtkconv->make_sound); |
11581 | 7186 |
7187 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
7188 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
7189 | |
7190 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
12188 | 7191 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
11581 | 7192 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7193 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM && |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7194 gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7195 { |
11581 | 7196 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
7197 gtkconv->u.im->show_icon); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7198 } |
11604 | 7199 |
11581 | 7200 /* |
7201 * We pause icons when they are not visible. If this icon should | |
7202 * be animated then start it back up again. | |
7203 */ | |
7204 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
7205 (gtkconv->u.im->animate)) | |
7206 start_anim(NULL, gtkconv); | |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
7207 |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
7208 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-switched", conv); |
11581 | 7209 } |
7210 | |
7211 /************************************************************************** | |
7212 * GTK+ window ops | |
7213 **************************************************************************/ | |
7214 | |
7215 GList * | |
7216 gaim_gtk_conv_windows_get_list() | |
7217 { | |
7218 return window_list; | |
7219 } | |
7220 | |
7221 GaimGtkWindow * | |
7222 gaim_gtk_conv_window_new() | |
7223 { | |
7224 GaimGtkWindow *win; | |
7225 GtkPositionType pos; | |
7226 GtkWidget *testidea; | |
7227 GtkWidget *menubar; | |
7228 | |
7229 win = g_malloc0(sizeof(GaimGtkWindow)); | |
7230 | |
7231 window_list = g_list_append(window_list, win); | |
7232 | |
7233 /* Create the window. */ | |
7234 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
7235 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
7236 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
7237 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
7238 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
7239 | |
7240 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
7241 G_CALLBACK(close_win_cb), win); | |
7242 | |
7243 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
7244 G_CALLBACK(focus_win_cb), win); | |
7245 | |
7246 /* Create the notebook. */ | |
7247 win->notebook = gtk_notebook_new(); | |
7248 | |
7249 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
7250 | |
7251 #if 0 | |
7252 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
7253 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
7254 #endif | |
7255 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
7256 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
7257 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
7258 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
7259 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
7260 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7261 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7262 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7263 |
11581 | 7264 gtk_widget_show(win->notebook); |
7265 | |
7266 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
7267 G_CALLBACK(before_switch_conv_cb), win); | |
7268 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
7269 G_CALLBACK(switch_conv_cb), win); | |
7270 | |
7271 /* Setup the tab drag and drop signals. */ | |
7272 gtk_widget_add_events(win->notebook, | |
7273 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
7274 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
7275 G_CALLBACK(notebook_press_cb), win); | |
7276 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
7277 G_CALLBACK(notebook_release_cb), win); | |
7278 | |
7279 testidea = gtk_vbox_new(FALSE, 0); | |
7280 | |
7281 /* Setup the menubar. */ | |
7282 menubar = setup_menubar(win); | |
7283 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
7284 | |
7285 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
7286 | |
7287 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
7288 | |
7289 gtk_widget_show(testidea); | |
7290 | |
7291 return win; | |
7292 } | |
7293 | |
7294 void | |
7295 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
7296 { | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7297 gaim_prefs_disconnect_by_handle(win); |
11581 | 7298 window_list = g_list_remove(window_list, win); |
7299 | |
11611 | 7300 if (win->gtkconvs) { |
7301 while (win->gtkconvs) { | |
7302 GList *nextgtk = win->gtkconvs->next; | |
7303 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
7304 GList *nextcore = gtkconv->convs->next; | |
7305 GaimConversation *conv = gtkconv->convs->data; | |
7306 gaim_conversation_destroy(conv); | |
7307 if (!nextgtk && !nextcore) | |
7308 /* we'll end up invoking ourselves when we destroy our last child */ | |
7309 /* so don't destroy ourselves right now */ | |
7310 return; | |
7311 } | |
7312 return; | |
7313 } | |
11581 | 7314 gtk_widget_destroy(win->window); |
7315 | |
7316 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
7317 | |
7318 g_free(win); | |
7319 } | |
7320 | |
7321 void | |
7322 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
7323 { | |
7324 gtk_widget_show(win->window); | |
7325 } | |
7326 | |
7327 void | |
7328 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
7329 { | |
7330 gtk_widget_hide(win->window); | |
7331 } | |
7332 | |
7333 void | |
7334 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
7335 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
7336 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 7337 } |
7338 | |
7339 void | |
7340 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
7341 { | |
7342 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
7343 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
7344 gtkconv->tab_cont)); | |
7345 } | |
7346 | |
7347 void | |
7348 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
7349 { | |
7350 GaimConversation *conv = gtkconv->active_conv; | |
7351 GaimGtkConversation *focus_gtkconv; | |
7352 GtkWidget *tabby, *menu_tabby; | |
7353 GtkWidget *tab_cont = gtkconv->tab_cont; | |
7354 GtkWidget *close_image; | |
7355 GaimConversationType conv_type; | |
7356 const char *name; | |
7357 const gchar *tmp_lab; | |
7358 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 7359 gboolean tabs_side = FALSE; |
7360 gint angle = 0; | |
11581 | 7361 |
7362 name = gaim_conversation_get_name(conv); | |
7363 conv_type = gaim_conversation_get_type(conv); | |
7364 | |
7365 | |
7366 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
7367 gtkconv->win = win; | |
7368 | |
11619 | 7369 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
7370 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
7371 tabs_side = TRUE; | |
7372 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
7373 angle = 90; | |
7374 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
7375 angle = 270; | |
7376 | |
7377 if (angle) | |
7378 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
7379 else | |
7380 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 7381 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
7382 | |
7383 /* Close button. */ | |
7384 gtkconv->close = gtk_button_new(); | |
7385 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
7386 if (gtk_check_version(2, 4, 2) == NULL) { | |
7387 /* Need to account for extra padding around the gtkbutton */ | |
7388 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
7389 "focus-line-width", &focus_width, | |
7390 "focus-padding", &focus_pad, | |
7391 NULL); | |
7392 close_button_width += (focus_width + focus_pad) * 2; | |
7393 close_button_height += (focus_width + focus_pad) * 2; | |
7394 } | |
7395 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
7396 close_button_width, close_button_height); | |
7397 | |
7398 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
7399 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
7400 gtk_widget_show(close_image); | |
7401 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
7402 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
7403 _("Close conversation"), NULL); | |
7404 | |
7405 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
7406 G_CALLBACK(close_conv_cb), gtkconv); | |
7407 | |
11851 | 7408 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 7409 /* |
7410 * I love Galeon. They have a fix for that stupid annoying visible | |
7411 * border bug. I love you guys! -- ChipX86 | |
7412 */ | |
11851 | 7413 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 7414 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
7415 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 7416 #endif |
11581 | 7417 |
7418 /* Status icon. */ | |
7419 gtkconv->icon = gtk_image_new(); | |
7420 gtkconv->menu_icon = gtk_image_new(); | |
7421 update_tab_icon(conv); | |
7422 | |
7423 /* Tab label. */ | |
7424 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 7425 |
11581 | 7426 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 7427 if (!angle) |
7428 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 7429 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 7430 if (tabs_side) { |
7431 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
7432 } | |
7433 if (angle) | |
7434 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 7435 #endif |
7436 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
7437 #if 0 | |
7438 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
7439 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
7440 #endif | |
7441 | |
7442 /* Pack it all together. */ | |
11619 | 7443 if (angle == 90) |
7444 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
7445 else | |
7446 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 7447 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
7448 FALSE, FALSE, 0); | |
7449 | |
7450 gtk_widget_show_all(gtkconv->icon); | |
7451 gtk_widget_show_all(gtkconv->menu_icon); | |
7452 | |
7453 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
7454 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
7455 gtk_widget_show(gtkconv->tab_label); | |
7456 gtk_widget_show(gtkconv->menu_label); | |
7457 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
7458 | |
11619 | 7459 if (angle == 90) |
7460 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
7461 else | |
7462 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 7463 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
7464 gtk_widget_show(gtkconv->close); | |
7465 | |
7466 gtk_widget_show(tabby); | |
7467 gtk_widget_show(menu_tabby); | |
7468 | |
7469 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
7470 gaim_gtkconv_update_buddy_icon(conv); | |
7471 | |
7472 /* Add this pane to the conversation's notebook. */ | |
7473 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 7474 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 7475 |
7476 | |
7477 gtk_widget_show(tab_cont); | |
7478 | |
7479 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
7480 /* Er, bug in notebooks? Switch to the page manually. */ | |
7481 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
7482 | |
7483 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7484 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7485 } else | |
7486 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
7487 | |
7488 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
7489 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
7490 gtk_widget_grab_focus(focus_gtkconv->entry); | |
7491 | |
7492 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 7493 update_send_to_selection(win); |
11581 | 7494 } |
7495 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7496 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7497 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
11581 | 7498 { |
7499 unsigned int index; | |
7500 GaimConversationType conv_type; | |
7501 | |
7502 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
7503 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
7504 | |
7505 g_object_ref(gtkconv->tab_cont); | |
7506 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
7507 | |
7508 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
7509 | |
7510 /* go back to tabless if need be */ | |
7511 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
7512 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7513 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7514 } | |
7515 | |
7516 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 7517 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7518 if (!win->gtkconvs && win != hidden_convwin) |
11582 | 7519 gaim_gtk_conv_window_destroy(win); |
11581 | 7520 } |
7521 | |
7522 GaimGtkConversation * | |
7523 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
7524 { | |
7525 GtkWidget *tab_cont; | |
7526 | |
7527 if (index == -1) | |
7528 index = 0; | |
7529 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 7530 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 7531 } |
7532 | |
7533 GaimGtkConversation * | |
7534 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
7535 { | |
7536 int index; | |
7537 GtkWidget *tab_cont; | |
7538 | |
7539 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
7540 if (index == -1) | |
7541 index = 0; | |
7542 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
7543 if (!tab_cont) | |
7544 return NULL; | |
7545 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
7546 } | |
7547 | |
7548 | |
7549 GaimConversation * | |
7550 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
7551 { | |
7552 GaimGtkConversation *gtkconv; | |
7553 | |
7554 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
7555 return gtkconv ? gtkconv->active_conv : NULL; | |
7556 } | |
7557 | |
7558 gboolean | |
7559 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
7560 { | |
7561 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
7562 } | |
7563 | |
7564 gboolean | |
7565 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
7566 { | |
7567 gboolean has_focus = FALSE; | |
7568 | |
7569 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
7570 | |
7571 return has_focus; | |
7572 } | |
7573 | |
7574 GaimGtkWindow * | |
7575 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
7576 { | |
7577 GaimGtkWindow *win; | |
7578 GdkWindow *gdkwin; | |
7579 GList *l; | |
7580 | |
7581 gdkwin = gdk_window_at_pointer(&x, &y); | |
7582 | |
7583 if (gdkwin) | |
7584 gdkwin = gdk_window_get_toplevel(gdkwin); | |
7585 | |
7586 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
7587 win = l->data; | |
7588 | |
7589 if (gdkwin == win->window->window) | |
7590 return win; | |
7591 } | |
7592 | |
7593 return NULL; | |
7594 } | |
7595 | |
7596 GList * | |
7597 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
7598 { | |
7599 return win->gtkconvs; | |
7600 } | |
7601 | |
7602 guint | |
7603 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
7604 { | |
7605 return g_list_length(win->gtkconvs); | |
7606 } | |
7607 | |
7608 GaimGtkWindow * | |
7609 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
7610 { | |
7611 GList *wins, *convs; | |
7612 GaimGtkWindow *win; | |
7613 GaimGtkConversation *conv; | |
7614 | |
7615 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7616 return NULL; | |
7617 | |
7618 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7619 win = wins->data; | |
7620 | |
7621 for (convs = win->gtkconvs; | |
7622 convs != NULL; | |
7623 convs = convs->next) { | |
7624 | |
7625 conv = convs->data; | |
7626 | |
7627 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7628 return win; | |
7629 } | |
7630 } | |
7631 | |
7632 return NULL; | |
7633 } | |
7634 | |
7635 GaimGtkWindow * | |
7636 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
7637 { | |
7638 GList *wins, *convs; | |
7639 GaimGtkWindow *win; | |
7640 GaimGtkConversation *conv; | |
7641 | |
7642 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7643 return NULL; | |
7644 | |
7645 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7646 wins != NULL; | |
7647 wins = wins->prev) { | |
7648 | |
7649 win = wins->data; | |
7650 | |
7651 for (convs = win->gtkconvs; | |
7652 convs != NULL; | |
7653 convs = convs->next) { | |
7654 | |
7655 conv = convs->data; | |
7656 | |
7657 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7658 return win; | |
7659 } | |
7660 } | |
7661 | |
7662 return NULL; | |
7663 } | |
7664 | |
7665 | |
7666 /************************************************************************** | |
7667 * Conversation placement functions | |
7668 **************************************************************************/ | |
7669 typedef struct | |
7670 { | |
7671 char *id; | |
7672 char *name; | |
7673 GaimConvPlacementFunc fnc; | |
7674 | |
7675 } ConvPlacementData; | |
7676 | |
7677 static GList *conv_placement_fncs = NULL; | |
7678 static GaimConvPlacementFunc place_conv = NULL; | |
7679 | |
7680 /* This one places conversations in the last made window. */ | |
7681 static void | |
7682 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7683 { | |
7684 GaimGtkWindow *win; | |
7685 | |
7686 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7687 win = l ? l->data : NULL;; | |
7688 | |
7689 if (win == NULL) { | |
7690 win = gaim_gtk_conv_window_new(); | |
7691 | |
7692 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7693 gaim_gtk_conv_window_show(win); | |
7694 } else { | |
7695 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7696 } | |
7697 } | |
7698 | |
7699 /* This one places conversations in the last made window of the same type. */ | |
7700 static void | |
7701 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7702 { | |
7703 GaimGtkWindow *win; | |
7704 | |
7705 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7706 | |
7707 if (win == NULL) { | |
7708 win = gaim_gtk_conv_window_new(); | |
7709 | |
7710 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7711 gaim_gtk_conv_window_show(win); | |
7712 } else | |
7713 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7714 } | |
7715 | |
7716 /* This one places each conversation in its own window. */ | |
7717 static void | |
7718 conv_placement_new_window(GaimGtkConversation *conv) | |
7719 { | |
7720 GaimGtkWindow *win; | |
7721 | |
7722 win = gaim_gtk_conv_window_new(); | |
7723 | |
7724 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7725 | |
7726 gaim_gtk_conv_window_show(win); | |
7727 } | |
7728 | |
7729 static GaimGroup * | |
7730 conv_get_group(GaimGtkConversation *conv) | |
7731 { | |
7732 GaimGroup *group = NULL; | |
7733 | |
7734 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7735 GaimBuddy *buddy; | |
7736 | |
7737 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7738 gaim_conversation_get_name(conv->active_conv)); | |
7739 | |
7740 if (buddy != NULL) | |
12088 | 7741 group = gaim_buddy_get_group(buddy); |
11581 | 7742 |
7743 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7744 GaimChat *chat; | |
7745 | |
7746 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7747 gaim_conversation_get_name(conv->active_conv)); | |
7748 | |
7749 if (chat != NULL) | |
7750 group = gaim_chat_get_group(chat); | |
7751 } | |
7752 | |
7753 return group; | |
7754 } | |
7755 | |
7756 /* | |
7757 * This groups things by, well, group. Buddies from groups will always be | |
7758 * grouped together, and a buddy from a group not belonging to any currently | |
7759 * open windows will get a new window. | |
7760 */ | |
7761 static void | |
7762 conv_placement_by_group(GaimGtkConversation *conv) | |
7763 { | |
7764 GaimConversationType type; | |
7765 GaimGroup *group = NULL; | |
7766 GList *wl, *cl; | |
7767 | |
7768 type = gaim_conversation_get_type(conv->active_conv); | |
7769 | |
7770 group = conv_get_group(conv); | |
7771 | |
7772 /* Go through the list of IMs and find one with this group. */ | |
7773 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7774 GaimGtkWindow *win2; | |
7775 GaimGtkConversation *conv2; | |
7776 GaimGroup *group2 = NULL; | |
7777 | |
7778 win2 = wl->data; | |
7779 | |
7780 for (cl = win2->gtkconvs; | |
7781 cl != NULL; | |
7782 cl = cl->next) { | |
7783 conv2 = cl->data; | |
7784 | |
7785 group2 = conv_get_group(conv2); | |
7786 | |
7787 if (group == group2) { | |
7788 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7789 | |
7790 return; | |
7791 } | |
7792 } | |
7793 } | |
7794 | |
7795 /* Make a new window. */ | |
7796 conv_placement_new_window(conv); | |
7797 } | |
7798 | |
7799 /* This groups things by account. Otherwise, the same semantics as above */ | |
7800 static void | |
7801 conv_placement_by_account(GaimGtkConversation *conv) | |
7802 { | |
7803 GaimConversationType type; | |
7804 GList *wins, *convs; | |
7805 GaimAccount *account; | |
7806 | |
7807 account = gaim_conversation_get_account(conv->active_conv); | |
7808 type = gaim_conversation_get_type(conv->active_conv); | |
7809 | |
7810 /* Go through the list of IMs and find one with this group. */ | |
7811 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7812 GaimGtkWindow *win2; | |
7813 GaimGtkConversation *conv2; | |
7814 | |
7815 win2 = wins->data; | |
7816 | |
7817 for (convs = win2->gtkconvs; | |
7818 convs != NULL; | |
7819 convs = convs->next) { | |
7820 conv2 = convs->data; | |
7821 | |
7822 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7823 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7824 return; | |
7825 } | |
7826 } | |
7827 } | |
7828 | |
7829 /* Make a new window. */ | |
7830 conv_placement_new_window(conv); | |
7831 } | |
7832 | |
7833 static ConvPlacementData * | |
7834 get_conv_placement_data(const char *id) | |
7835 { | |
7836 ConvPlacementData *data = NULL; | |
7837 GList *n; | |
7838 | |
7839 for (n = conv_placement_fncs; n; n = n->next) { | |
7840 data = n->data; | |
7841 if (!strcmp(data->id, id)) | |
7842 return data; | |
7843 } | |
7844 | |
7845 return NULL; | |
7846 } | |
7847 | |
7848 static void | |
7849 add_conv_placement_fnc(const char *id, const char *name, | |
7850 GaimConvPlacementFunc fnc) | |
7851 { | |
7852 ConvPlacementData *data; | |
7853 | |
7854 data = g_new(ConvPlacementData, 1); | |
7855 | |
7856 data->id = g_strdup(id); | |
7857 data->name = g_strdup(name); | |
7858 data->fnc = fnc; | |
7859 | |
7860 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7861 } | |
7862 | |
7863 static void | |
7864 ensure_default_funcs(void) | |
7865 { | |
7866 if (conv_placement_fncs == NULL) { | |
7867 add_conv_placement_fnc("last", _("Last created window"), | |
7868 conv_placement_last_created_win); | |
7869 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7870 conv_placement_last_created_win_type); | |
7871 add_conv_placement_fnc("new", _("New window"), | |
7872 conv_placement_new_window); | |
7873 add_conv_placement_fnc("group", _("By group"), | |
7874 conv_placement_by_group); | |
7875 add_conv_placement_fnc("account", _("By account"), | |
7876 conv_placement_by_account); | |
7877 } | |
7878 } | |
7879 | |
7880 GList * | |
7881 gaim_gtkconv_placement_get_options(void) | |
7882 { | |
7883 GList *n, *list = NULL; | |
7884 ConvPlacementData *data; | |
7885 | |
7886 ensure_default_funcs(); | |
7887 | |
7888 for (n = conv_placement_fncs; n; n = n->next) { | |
7889 data = n->data; | |
7890 list = g_list_append(list, data->name); | |
7891 list = g_list_append(list, data->id); | |
7892 } | |
7893 | |
7894 return list; | |
7895 } | |
7896 | |
7897 | |
7898 void | |
7899 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
7900 GaimConvPlacementFunc fnc) | |
7901 { | |
7902 g_return_if_fail(id != NULL); | |
7903 g_return_if_fail(name != NULL); | |
7904 g_return_if_fail(fnc != NULL); | |
7905 | |
7906 ensure_default_funcs(); | |
7907 | |
7908 add_conv_placement_fnc(id, name, fnc); | |
7909 } | |
7910 | |
7911 void | |
7912 gaim_gtkconv_placement_remove_fnc(const char *id) | |
7913 { | |
7914 ConvPlacementData *data = get_conv_placement_data(id); | |
7915 | |
7916 if (data == NULL) | |
7917 return; | |
7918 | |
7919 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
7920 | |
7921 g_free(data->id); | |
7922 g_free(data->name); | |
7923 g_free(data); | |
7924 } | |
7925 | |
7926 const char * | |
7927 gaim_gtkconv_placement_get_name(const char *id) | |
7928 { | |
7929 ConvPlacementData *data; | |
7930 | |
7931 ensure_default_funcs(); | |
7932 | |
7933 data = get_conv_placement_data(id); | |
7934 | |
7935 if (data == NULL) | |
7936 return NULL; | |
7937 | |
7938 return data->name; | |
7939 } | |
7940 | |
7941 GaimConvPlacementFunc | |
7942 gaim_gtkconv_placement_get_fnc(const char *id) | |
7943 { | |
7944 ConvPlacementData *data; | |
7945 | |
7946 ensure_default_funcs(); | |
7947 | |
7948 data = get_conv_placement_data(id); | |
7949 | |
7950 if (data == NULL) | |
7951 return NULL; | |
7952 | |
7953 return data->fnc; | |
7954 } | |
7955 | |
7956 void | |
7957 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
7958 { | |
7959 g_return_if_fail(func != NULL); | |
7960 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7961 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7962 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7963 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7964 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7965 place_conv = NULL; |
11581 | 7966 } |
7967 | |
7968 GaimConvPlacementFunc | |
7969 gaim_gtkconv_placement_get_current_func(void) | |
7970 { | |
7971 return place_conv; | |
7972 } | |
7973 | |
7974 void | |
7975 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
7976 { | |
7977 if (place_conv) | |
7978 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7979 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7980 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7981 } |
12239 | 7982 |
7983 gboolean | |
7984 gaim_gtkconv_is_hidden(GaimGtkConversation *gtkconv) | |
7985 { | |
7986 g_return_val_if_fail(gtkconv != NULL, FALSE); | |
7987 | |
7988 return (gtkconv->win == hidden_convwin); | |
7989 } | |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7990 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7991 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7992 /* Algorithm from http://www.w3.org/TR/AERT#color-contrast */ |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
7993 static gboolean |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
7994 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
|
7995 { |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7996 gulong fg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7997 gulong bg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7998 gulong br_diff; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7999 gulong col_diff; |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8000 int fred, fgreen, fblue, bred, bgreen, bblue; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8001 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8002 /* 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
|
8003 * GTK on the other hand has values between 0 and 65535 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8004 * Err suggested I >> 8, which grabbed the high bits. |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8005 */ |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8006 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8007 fred = foreground.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8008 fgreen = foreground.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8009 fblue = foreground.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8010 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8011 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8012 bred = background.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8013 bgreen = background.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8014 bblue = background.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8015 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8016 fg_brightness = (fred * 299 + fgreen * 587 + fblue * 114) / 1000; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8017 bg_brightness = (bred * 299 + bgreen * 587 + bblue * 114) / 1000; |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8018 br_diff = abs(fg_brightness - bg_brightness); |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8019 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8020 col_diff = abs(fred - bred) + abs(fgreen - bgreen) + abs(fblue - bblue); |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8021 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8022 return ((col_diff > color_contrast) && (br_diff > brightness_contrast)); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8023 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8024 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8025 |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
8026 static GdkColor* |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8027 generate_nick_colors(guint *color_count, GdkColor background) |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8028 { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8029 guint numcolors = *color_count; |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8030 guint i = 0, j = 0; |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8031 GdkColor *colors = g_new(GdkColor, numcolors); |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8032 GdkColor nick_highlight; |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8033 GdkColor send_color; |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8034 time_t breakout_time; |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8035 |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8036 gdk_color_parse(HIGHLIGHT_COLOR, &nick_highlight); |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8037 gdk_color_parse(SEND_COLOR, &send_color); |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8038 |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8039 srand(background.red + background.green + background.blue + 1); |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8040 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8041 breakout_time = time(NULL) + 3; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8042 |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8043 /* 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
|
8044 * 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
|
8045 * numcolors of them that do |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8046 */ |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8047 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
|
8048 { |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8049 GdkColor color = nick_seed_colors[j]; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8050 |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8051 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
|
8052 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8053 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8054 { |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8055 colors[i] = color; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8056 i++; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8057 } |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8058 j++; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8059 } |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8060 |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8061 /* 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
|
8062 * 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
|
8063 * 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
|
8064 * conflict with each other. |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8065 */ |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8066 while(i < numcolors && time(NULL) < breakout_time) |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8067 { |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8068 GdkColor color = { 0, rand() % 65536, rand() % 65536, rand() % 65536 }; |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8069 |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8070 gaim_debug(GAIM_DEBUG_WARNING, NULL, |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8071 "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
|
8072 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8073 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
|
8074 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8075 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8076 { |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8077 colors[i] = color; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8078 i++; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8079 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8080 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8081 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8082 if (i < numcolors) { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8083 GdkColor *c = colors; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8084 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
|
8085 colors = g_memdup(c, i * sizeof(GdkColor)); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8086 g_free(c); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8087 *color_count = i; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8088 |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8089 } |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8090 |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8091 return colors; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8092 } |