Mercurial > pidgin.yaz
annotate src/gtkconv.c @ 12913:b1bc87b15818
[gaim-migrate @ 15266]
Part of SF Patch #1408093 from Philip Walford
"wgaim_conv_im_blink had the wrong signature and failed
to correctly determine the conversation associated with
a new message."
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 17 Jan 2006 16:12:44 +0000 |
parents | 3bf3f489b64b |
children | 7f633dd625a9 |
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; |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
1989 GaimConversation *old_conv; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
1990 GtkIMHtml *entry; |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
1991 const char *protocol_name; |
11672
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 g_return_if_fail(conv != NULL); |
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 gtkconv = GAIM_GTK_CONVERSATION(conv); |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
1996 old_conv = gtkconv->active_conv; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
1997 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
1998 if (old_conv == conv) |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1999 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2000 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2001 gaim_conversation_close_logs(old_conv); |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2002 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2003 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2004 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2005 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
|
2006 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2007 entry = GTK_IMHTML(gtkconv->entry); |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2008 protocol_name = gaim_account_get_protocol_name(conv->account); |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2009 gtk_imhtml_set_protocol_name(entry, protocol_name); |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2010 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol_name); |
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2011 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2012 if (!(conv->features & GAIM_CONNECTION_HTML)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2013 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2014 else if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO && |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2015 !(old_conv->features & GAIM_CONNECTION_FORMATTING_WBFO)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2016 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2017 /* The old conversation allowed formatting on parts of the |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2018 * buffer, but the new one only allows it on the whole |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2019 * buffer. This code saves the formatting from the current |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2020 * position of the cursor, clears the formatting, then |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2021 * applies the saved formatting to the entire buffer. */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2022 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2023 gboolean bold; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2024 gboolean italic; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2025 gboolean underline; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2026 char *fontface = gtk_imhtml_get_current_fontface(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2027 char *forecolor = gtk_imhtml_get_current_forecolor(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2028 char *backcolor = gtk_imhtml_get_current_backcolor(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2029 char *background = gtk_imhtml_get_current_background(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2030 gint fontsize = gtk_imhtml_get_current_fontsize(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2031 gboolean bold2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2032 gboolean italic2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2033 gboolean underline2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2034 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2035 gtk_imhtml_get_current_format(entry, &bold, &italic, &underline); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2036 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2037 /* Clear existing formatting */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2038 gtk_imhtml_clear_formatting(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2039 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2040 /* Apply saved formatting to the whole buffer. */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2041 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2042 gtk_imhtml_get_current_format(entry, &bold2, &italic2, &underline2); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2043 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2044 if (bold != bold2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2045 gtk_imhtml_toggle_bold(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2046 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2047 if (italic != italic2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2048 gtk_imhtml_toggle_italic(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2049 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2050 if (underline != underline2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2051 gtk_imhtml_toggle_underline(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2052 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2053 gtk_imhtml_toggle_fontface(entry, fontface); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2054 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2055 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2056 gtk_imhtml_font_set_size(entry, fontsize); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2057 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2058 gtk_imhtml_toggle_forecolor(entry, forecolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2059 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2060 if (!(conv->features & GAIM_CONNECTION_NO_BGCOLOR)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2061 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2062 gtk_imhtml_toggle_backcolor(entry, backcolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2063 gtk_imhtml_toggle_background(entry, background); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2064 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2065 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2066 g_free(fontface); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2067 g_free(forecolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2068 g_free(backcolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2069 g_free(background); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2070 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2071 else |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2072 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2073 /* This is done in default_formatize, which is called from clear_formatting_cb, |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2074 * which is (obviously) a clear_formatting signal handler. However, if we're |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2075 * here, we didn't call gtk_imhtml_clear_formatting() (because we want to |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2076 * preserve the formatting exactly as it is), so we have to do this now. */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2077 gtk_imhtml_set_whole_buffer_formatting_only(entry, |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2078 (conv->features & GAIM_CONNECTION_FORMATTING_WBFO)); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2079 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2080 |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
2081 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
|
2082 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2083 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
2084 void |
11604 | 2085 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
2086 { | |
2087 GaimGtkConversation *gtkconv; | |
2088 | |
2089 g_return_if_fail(conv != NULL); | |
2090 | |
2091 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2092 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2093 gaim_gtkconv_set_active_conversation(conv); |
11604 | 2094 |
2095 gray_stuff_out(gtkconv); | |
2096 update_typing_icon(gtkconv); | |
2097 | |
2098 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
2099 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
2100 } | |
2101 | |
2102 static void | |
4673 | 2103 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 2104 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2105 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 2106 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2107 GaimConversation *conv; |
4359 | 2108 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2109 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2110 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2111 |
11594 | 2112 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 2113 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 2114 } |
2115 | |
2116 static void | |
2117 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
2118 gchar *new_text, gint new_text_length, gpointer user_data) | |
2119 { | |
10810 | 2120 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2121 GaimConversation *conv; | |
2122 | |
2123 g_return_if_fail(gtkconv != NULL); | |
11508 | 2124 |
10810 | 2125 conv = gtkconv->active_conv; |
4359 | 2126 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2127 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2128 return; |
2129 | |
10810 | 2130 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2131 gtk_text_iter_is_end(position))); | |
4359 | 2132 } |
2133 | |
2134 static void | |
2135 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2136 GtkTextIter *end_pos, gpointer user_data) | |
2137 { | |
10810 | 2138 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2139 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2140 GaimConvIm *im; |
4359 | 2141 |
10810 | 2142 g_return_if_fail(gtkconv != NULL); |
11508 | 2143 |
10810 | 2144 conv = gtkconv->active_conv; |
4359 | 2145 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2146 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2147 return; |
2148 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2149 im = GAIM_CONV_IM(conv); |
4359 | 2150 |
2151 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2152 | |
2153 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2154 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2155 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2156 |
2157 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2158 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2159 GAIM_NOT_TYPING); |
4359 | 2160 } |
2161 else { | |
2162 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2163 got_typing_keypress(gtkconv, FALSE); |
4359 | 2164 } |
2165 } | |
2166 | |
8189 | 2167 /************************************************************************** |
2168 * A bunch of buddy icon functions | |
2169 **************************************************************************/ | |
11581 | 2170 GdkPixbuf * |
2171 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2172 { |
10116 | 2173 GaimAccount *account = NULL; |
2174 const char *name = NULL; | |
7143 | 2175 GdkPixbuf *status = NULL; |
2176 | |
10116 | 2177 g_return_val_if_fail(conv != NULL, NULL); |
2178 | |
2179 account = gaim_conversation_get_account(conv); | |
2180 name = gaim_conversation_get_name(conv); | |
2181 | |
2182 g_return_val_if_fail(account != NULL, NULL); | |
2183 g_return_val_if_fail(name != NULL, NULL); | |
2184 | |
11338 | 2185 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2186 GaimBuddy *b = gaim_find_buddy(account, name); |
2187 if (b != NULL) { | |
2188 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2189 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2190 } |
2191 } | |
2192 | |
2193 if (!status) { | |
2194 GdkPixbuf *pixbuf; | |
10884 | 2195 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2196 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2197 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2198 { |
7143 | 2199 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2200 GDK_INTERP_BILINEAR); | |
2201 g_object_unref(pixbuf); | |
2202 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2203 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2204 status = pixbuf; |
7143 | 2205 } |
2206 return status; | |
2207 } | |
2208 | |
8189 | 2209 static void |
2210 update_tab_icon(GaimConversation *conv) | |
2211 { | |
2212 GaimGtkConversation *gtkconv; | |
11581 | 2213 GaimGtkWindow *win; |
8189 | 2214 GaimAccount *account; |
2215 const char *name; | |
2216 GdkPixbuf *status = NULL; | |
2217 | |
10116 | 2218 g_return_if_fail(conv != NULL); |
2219 | |
8189 | 2220 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2221 win = gtkconv->win; |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2222 if (conv != gtkconv->active_conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2223 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2224 |
8189 | 2225 name = gaim_conversation_get_name(conv); |
2226 account = gaim_conversation_get_account(conv); | |
2227 | |
11581 | 2228 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2229 |
10116 | 2230 g_return_if_fail(status != NULL); |
2231 | |
8189 | 2232 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2233 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2234 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2235 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2236 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2237 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2238 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2239 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2240 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2241 { |
11581 | 2242 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2243 | |
2244 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2245 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2246 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2247 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2248 } |
8189 | 2249 } |
2250 | |
2251 static gboolean | |
2252 redraw_icon(gpointer data) | |
2253 { | |
10810 | 2254 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2255 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2256 GaimAccount *account; |
2257 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2258 |
2259 GdkPixbuf *buf; | |
2260 GdkPixbuf *scale; | |
2261 GdkPixmap *pm; | |
2262 GdkBitmap *bm; | |
2263 gint delay; | |
9318 | 2264 int scale_width, scale_height; |
8189 | 2265 |
2266 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2267 account = gaim_conversation_get_account(conv); |
2268 if(account && account->gc) | |
2269 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2270 |
2271 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2272 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2273 | |
10483 | 2274 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2275 NULL, &scale_width, &scale_height); |
2276 | |
2277 /* this code is ugly, and scares me */ | |
8189 | 2278 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2279 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2280 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2281 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2282 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2283 GDK_INTERP_BILINEAR); |
8189 | 2284 |
2285 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2286 g_object_unref(G_OBJECT(scale)); | |
2287 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2288 g_object_unref(G_OBJECT(pm)); | |
2289 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2290 | |
2291 if (bm) | |
2292 g_object_unref(G_OBJECT(bm)); | |
2293 | |
9131 | 2294 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2295 |
2296 if (delay < 100) | |
9131 | 2297 delay = 100; |
2298 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2299 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2300 |
2301 return FALSE; | |
2302 } | |
2303 | |
2304 static void | |
10810 | 2305 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2306 { |
2307 int delay; | |
2308 | |
8228 | 2309 if (gtkconv->u.im->anim == NULL) |
2310 return; | |
2311 | |
8202 | 2312 if (gtkconv->u.im->icon_timer != 0) |
2313 return; | |
2314 | |
8189 | 2315 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2316 return; | |
2317 | |
10639 | 2318 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2319 | |
2320 if (delay < 100) | |
2321 delay = 100; | |
2322 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2323 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2324 } |
2325 | |
2326 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2327 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2328 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2329 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2330 GaimGtkWindow *gtkwin; |
2331 | |
2332 g_return_if_fail(conv != NULL); | |
2333 | |
9887 | 2334 if (gtkconv->u.im->icon_container != NULL) |
2335 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2336 |
2337 if (gtkconv->u.im->anim != NULL) | |
2338 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2339 | |
2340 if (gtkconv->u.im->icon_timer != 0) | |
2341 g_source_remove(gtkconv->u.im->icon_timer); | |
2342 | |
2343 if (gtkconv->u.im->iter != NULL) | |
2344 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2345 | |
2346 gtkconv->u.im->icon_timer = 0; | |
2347 gtkconv->u.im->icon = NULL; | |
2348 gtkconv->u.im->anim = NULL; | |
2349 gtkconv->u.im->iter = NULL; | |
10456 | 2350 gtkconv->u.im->icon_container = NULL; |
9687 | 2351 gtkconv->u.im->show_icon = FALSE; |
10456 | 2352 |
11581 | 2353 gtkwin = gtkconv->win; |
10456 | 2354 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2355 } |
2356 | |
9497 | 2357 static void |
9504 | 2358 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2359 { |
10810 | 2360 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2361 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2362 FILE *fp; |
2363 GaimBuddyIcon *icon; | |
2364 const void *data; | |
2365 size_t len; | |
2366 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2367 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2368 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2369 return; |
2370 } | |
2371 | |
2372 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2373 data = gaim_buddy_icon_get_data(icon, &len); | |
2374 | |
2375 if ((len <= 0) || (data == NULL)) { | |
9504 | 2376 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2377 return; |
2378 } | |
2379 | |
2380 fwrite(data, 1, len, fp); | |
2381 fclose(fp); | |
2382 } | |
2383 | |
2384 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2385 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2386 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2387 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2388 const gchar *ext; |
9497 | 2389 gchar *buf; |
2390 | |
2391 g_return_if_fail(conv != NULL); | |
9504 | 2392 |
10953 | 2393 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2394 if (ext == NULL) | |
2395 ext = "icon"; | |
2396 | |
2397 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2398 |
2399 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2400 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2401 |
2402 g_free(buf); | |
2403 } | |
2404 | |
11581 | 2405 static void |
2406 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2407 { | |
2408 if (gtkconv->u.im->icon_timer != 0) | |
2409 g_source_remove(gtkconv->u.im->icon_timer); | |
2410 | |
2411 gtkconv->u.im->icon_timer = 0; | |
2412 } | |
2413 | |
2414 | |
2415 static void | |
2416 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2417 { | |
2418 gtkconv->u.im->animate = | |
2419 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2420 | |
2421 if (gtkconv->u.im->animate) | |
2422 start_anim(NULL, gtkconv); | |
2423 else | |
2424 stop_anim(NULL, gtkconv); | |
2425 } | |
2426 | |
8189 | 2427 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2428 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2429 { |
2430 static GtkWidget *menu = NULL; | |
2431 GtkWidget *button; | |
2432 | |
2433 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2434 return FALSE; | |
2435 | |
2436 /* | |
2437 * If a menu already exists, destroy it before creating a new one, | |
2438 * thus freeing-up the memory it occupied. | |
2439 */ | |
2440 if (menu != NULL) | |
2441 gtk_widget_destroy(menu); | |
2442 | |
2443 menu = gtk_menu_new(); | |
2444 | |
2445 if (gtkconv->u.im->anim && | |
2446 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2447 { | |
2448 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2449 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2450 gtkconv->u.im->icon_timer); |
2451 } | |
2452 | |
2453 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2454 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2455 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2456 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2457 gtk_widget_show(button); | |
2458 | |
2459 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
|
2460 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2461 0, 0, NULL); |
2462 | |
2463 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2464 | |
2465 return TRUE; | |
2466 } | |
10456 | 2467 |
2468 static void | |
2469 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2470 { | |
11581 | 2471 GaimGtkWindow *win = data; |
10456 | 2472 GaimConversation *conv; |
2473 GaimGtkConversation *gtkconv; | |
2474 gboolean active; | |
2475 | |
11581 | 2476 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2477 |
2478 if (!conv) | |
2479 return; | |
2480 | |
11338 | 2481 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2482 |
2483 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2484 | |
2485 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2486 gtkconv->u.im->show_icon = active; | |
2487 if (active) | |
2488 gaim_gtkconv_update_buddy_icon(conv); | |
2489 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2490 remove_icon(gtkconv); |
10456 | 2491 } |
2492 | |
8189 | 2493 /************************************************************************** |
2494 * End of the bunch of buddy icon functions | |
2495 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2496 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2497 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2498 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2499 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2500 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2501 if(gtkconv->win==hidden_convwin) { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
2502 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2503 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2504 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2505 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2506 gaim_gtkconv_set_active_conversation(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2507 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2508 gaim_gtk_conv_window_raise(gtkconv->win); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2509 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2510 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2511 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2512 GList * |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2513 gaim_gtk_conversations_find_unseen_list(GaimConversationType type, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2514 GaimUnseenState min_state, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2515 gboolean hidden_only, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2516 guint max_count) |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2517 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2518 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2519 GList *r = NULL; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2520 guint c = 0; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2521 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2522 if (type == GAIM_CONV_TYPE_IM) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2523 l = gaim_get_ims(); |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2524 } else if (type == GAIM_CONV_TYPE_CHAT) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2525 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2526 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2527 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2528 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2529 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2530 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
|
2531 GaimConversation *conv = (GaimConversation*)l->data; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2532 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2533 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2534 if(gtkconv->active_conv != conv) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2535 continue; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2536 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2537 if (gtkconv->unseen_state >= min_state |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2538 && (!hidden_only || |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2539 (hidden_only && gtkconv->win == hidden_convwin))) { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2540 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2541 r = g_list_prepend(r, conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2542 c++; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2543 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2544 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2545 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2546 return r; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2547 } |
8189 | 2548 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2549 static void |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2550 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2551 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2552 g_return_if_fail(conv != NULL); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2553 gaim_gtkconv_present_conversation(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2554 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2555 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2556 guint |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2557 gaim_gtk_conversations_fill_menu(GtkWidget *menu, GList *convs) |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2558 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2559 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2560 guint ret=0; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2561 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2562 g_return_val_if_fail(menu != NULL, 0); |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2563 g_return_val_if_fail(convs != NULL, 0); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2564 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2565 for (l = convs; l != NULL ; l = l->next) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2566 GaimConversation *conv = (GaimConversation*)l->data; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2567 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2568 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2569 GtkWidget *icon = gtk_image_new(); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2570 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2571 GtkWidget *item; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2572 gchar *text = g_strdup_printf("%s (%d)", |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2573 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2574 gtkconv->unseen_count); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2575 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2576 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2577 g_object_unref(pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2578 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2579 item = gtk_image_menu_item_new_with_label(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2580 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
|
2581 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
|
2582 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2583 g_free(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2584 ret++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2585 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2586 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2587 return ret; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2588 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2589 |
11581 | 2590 GaimGtkWindow * |
2591 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2592 { | |
2593 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2594 return gtkconv->win; | |
2595 } | |
2596 | |
2597 static GtkItemFactoryEntry menu_items[] = | |
2598 { | |
2599 /* Conversation menu */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2600 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>", NULL }, |
11581 | 2601 |
2602 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2603 0, "<StockItem>", GAIM_STOCK_IM }, | |
2604 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2605 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2606 |
2607 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2608 "<StockItem>", GTK_STOCK_FIND }, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2609 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", GAIM_STOCK_LOG }, |
11581 | 2610 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2611 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
12897
e9b0c90ce58a
[gaim-migrate @ 15250]
Richard Laager <rlaager@wiktel.com>
parents:
12867
diff
changeset
|
2612 { N_("/Conversation/Clea_r Scrollback"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
11581 | 2613 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2614 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2615 |
2616 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2617 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2618 0, "<StockItem>", GAIM_STOCK_POUNCE }, |
11581 | 2619 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2620 "<StockItem>", GAIM_STOCK_INFO }, | |
2621 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2622 "<StockItem>", GAIM_STOCK_INVITE }, | |
2623 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2624 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2625 |
2626 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2627 "<StockItem>", GAIM_STOCK_EDIT }, | |
2628 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2629 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2630 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2631 "<StockItem>", GTK_STOCK_ADD }, | |
2632 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2633 "<StockItem>", GTK_STOCK_REMOVE }, | |
2634 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2635 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2636 |
2637 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2638 "<StockItem>", GAIM_STOCK_LINK }, | |
2639 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2640 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2641 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2642 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2643 |
2644 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2645 "<StockItem>", GTK_STOCK_CLOSE }, | |
2646 | |
2647 /* Options */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2648 { N_("/_Options"), NULL, NULL, 0, "<Branch>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2649 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2650 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2651 { 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
|
2652 { "/Options/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2653 { 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
|
2654 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>", NULL }, |
11581 | 2655 }; |
2656 | |
2657 static const int menu_item_count = | |
2658 sizeof(menu_items) / sizeof(*menu_items); | |
2659 | |
2660 static char * | |
2661 item_factory_translate_func (const char *path, gpointer func_data) | |
2662 { | |
2663 return _((char *)path); | |
2664 } | |
2665 | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2666 static void |
12816 | 2667 sound_method_pref_changed_cb(const char *name, GaimPrefType type, |
2668 gconstpointer value, gpointer data) | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2669 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2670 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2671 const char *method = value; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2672 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2673 if (!strcmp(method, "none")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2674 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2675 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
|
2676 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2677 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2678 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2679 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2680 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2681 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2682 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2683 if (gtkconv != NULL) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2684 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
|
2685 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2686 gtk_widget_set_sensitive(win->menu.sounds, TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2687 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2688 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2689 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2690 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2691 static void |
12816 | 2692 show_buddy_icons_pref_changed_cb(const char *name, GaimPrefType type, |
2693 gconstpointer value, gpointer data) | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2694 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2695 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2696 gboolean show_icons = GPOINTER_TO_INT(value); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2697 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2698 if (!show_icons) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2699 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2700 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
|
2701 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2702 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2703 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2704 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2705 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2706 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2707 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2708 if (gtkconv != NULL) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2709 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
|
2710 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2711 gtk_widget_set_sensitive(win->menu.show_icon, TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2712 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2713 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2714 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2715 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2716 |
11581 | 2717 static GtkWidget * |
2718 setup_menubar(GaimGtkWindow *win) | |
2719 { | |
2720 GtkAccelGroup *accel_group; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2721 const char *method; |
11581 | 2722 |
2723 accel_group = gtk_accel_group_new (); | |
2724 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2725 g_object_unref(accel_group); | |
2726 | |
2727 win->menu.item_factory = | |
2728 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2729 | |
2730 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2731 item_factory_translate_func, | |
2732 NULL, NULL); | |
2733 | |
2734 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2735 menu_items, win); | |
2736 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2737 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2738 | |
2739 | |
2740 win->menu.menubar = | |
2741 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2742 | |
2743 | |
2744 win->menu.view_log = | |
2745 gtk_item_factory_get_widget(win->menu.item_factory, | |
2746 N_("/Conversation/View Log")); | |
2747 | |
2748 /* --- */ | |
2749 | |
2750 win->menu.send_file = | |
2751 gtk_item_factory_get_widget(win->menu.item_factory, | |
2752 N_("/Conversation/Send File...")); | |
2753 | |
2754 win->menu.add_pounce = | |
2755 gtk_item_factory_get_widget(win->menu.item_factory, | |
2756 N_("/Conversation/Add Buddy Pounce...")); | |
2757 | |
2758 /* --- */ | |
2759 | |
2760 win->menu.get_info = | |
2761 gtk_item_factory_get_widget(win->menu.item_factory, | |
2762 N_("/Conversation/Get Info")); | |
2763 | |
2764 win->menu.invite = | |
2765 gtk_item_factory_get_widget(win->menu.item_factory, | |
2766 N_("/Conversation/Invite...")); | |
2767 | |
2768 /* --- */ | |
2769 | |
2770 win->menu.alias = | |
2771 gtk_item_factory_get_widget(win->menu.item_factory, | |
2772 N_("/Conversation/Alias...")); | |
2773 | |
2774 win->menu.block = | |
2775 gtk_item_factory_get_widget(win->menu.item_factory, | |
2776 N_("/Conversation/Block...")); | |
2777 | |
2778 win->menu.add = | |
2779 gtk_item_factory_get_widget(win->menu.item_factory, | |
2780 N_("/Conversation/Add...")); | |
2781 | |
2782 win->menu.remove = | |
2783 gtk_item_factory_get_widget(win->menu.item_factory, | |
2784 N_("/Conversation/Remove...")); | |
2785 | |
2786 /* --- */ | |
2787 | |
2788 win->menu.insert_link = | |
2789 gtk_item_factory_get_widget(win->menu.item_factory, | |
2790 N_("/Conversation/Insert Link...")); | |
2791 | |
2792 win->menu.insert_image = | |
2793 gtk_item_factory_get_widget(win->menu.item_factory, | |
2794 N_("/Conversation/Insert Image...")); | |
2795 | |
2796 /* --- */ | |
2797 | |
2798 win->menu.logging = | |
2799 gtk_item_factory_get_widget(win->menu.item_factory, | |
2800 N_("/Options/Enable Logging")); | |
2801 win->menu.sounds = | |
2802 gtk_item_factory_get_widget(win->menu.item_factory, | |
2803 N_("/Options/Enable Sounds")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2804 method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2805 if (!strcmp(method, "none")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2806 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2807 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
|
2808 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2809 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2810 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2811 gaim_prefs_connect_callback(win, "/gaim/gtk/sound/method", |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2812 sound_method_pref_changed_cb, win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2813 |
11581 | 2814 win->menu.show_formatting_toolbar = |
2815 gtk_item_factory_get_widget(win->menu.item_factory, | |
2816 N_("/Options/Show Formatting Toolbars")); | |
2817 win->menu.show_timestamps = | |
2818 gtk_item_factory_get_widget(win->menu.item_factory, | |
2819 N_("/Options/Show Timestamps")); | |
2820 win->menu.show_icon = | |
2821 gtk_item_factory_get_widget(win->menu.item_factory, | |
2822 N_("/Options/Show Buddy Icon")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2823 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
|
2824 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2825 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
|
2826 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2827 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2828 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2829 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
|
2830 show_buddy_icons_pref_changed_cb, win); |
11581 | 2831 |
2832 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2833 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2834 win->menu.tray); | |
2835 gtk_widget_show(win->menu.tray); | |
2836 | |
2837 gtk_widget_show(win->menu.menubar); | |
2838 | |
2839 return win->menu.menubar; | |
2840 } | |
2841 | |
4359 | 2842 |
2843 /************************************************************************** | |
2844 * Utility functions | |
2845 **************************************************************************/ | |
2846 | |
2847 static void | |
10810 | 2848 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2849 { |
10810 | 2850 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2851 GaimConvIm *im; |
4685 | 2852 |
4359 | 2853 /* |
2854 * 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
|
2855 * send GAIM_TYPED any time soon. |
4359 | 2856 */ |
2857 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2858 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2859 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2860 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2861 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2862 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2863 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2864 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2865 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2866 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2867 |
2868 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2869 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2870 GAIM_TYPING); |
4359 | 2871 |
2872 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2873 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2874 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2875 gaim_conv_im_set_type_again(im, 0); |
4359 | 2876 } |
2877 } | |
2878 | |
4736 | 2879 static void |
10810 | 2880 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2881 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2882 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2883 GaimConvIm *im = NULL; |
10810 | 2884 GaimConversation *conv = gtkconv->active_conv; |
12008 | 2885 char *stock_id, *tooltip; |
11508 | 2886 |
11581 | 2887 gtkwin = gtkconv->win; |
4736 | 2888 |
12008 | 2889 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2890 im = GAIM_CONV_IM(conv); |
4736 | 2891 |
12008 | 2892 if (gtkwin->menu.typing_icon) { |
2893 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2894 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2895 |
12008 | 2896 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2897 return; | |
2898 | |
2899 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2900 stock_id = GAIM_STOCK_TYPING; | |
2901 tooltip = _("User is typing..."); | |
2902 } else { | |
2903 stock_id = GAIM_STOCK_TYPED; | |
2904 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2905 } |
12008 | 2906 |
2907 if (gtkwin->menu.typing_icon == NULL) | |
2908 { | |
2909 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
|
2910 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
|
2911 gtkwin->menu.typing_icon, |
12008 | 2912 tooltip); |
4736 | 2913 } |
12008 | 2914 else |
2915 { | |
2916 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2917 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2918 gtkwin->menu.typing_icon, | |
2919 tooltip); | |
2920 } | |
2921 | |
2922 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2923 } |
2924 | |
4685 | 2925 static gboolean |
11594 | 2926 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2927 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2928 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2929 GaimConversation *conv; |
4359 | 2930 GtkWidget *menu; |
2931 GList *child; | |
11594 | 2932 GaimBuddy *b; |
11581 | 2933 |
2934 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2935 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2936 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2937 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2938 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2939 account = gaim_conversation_get_account(conv); |
11581 | 2940 |
11594 | 2941 if (win->menu.send_to == NULL) |
4685 | 2942 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2943 |
11594 | 2944 if (!(b = gaim_find_buddy(account, conv->name))) |
2945 return FALSE; | |
2946 | |
2947 | |
2948 gtk_widget_show(win->menu.send_to); | |
4359 | 2949 |
2950 menu = gtk_menu_item_get_submenu( | |
11594 | 2951 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2952 |
2953 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2954 child != NULL; | |
2955 child = child->next) { | |
2956 | |
2957 GtkWidget *item = child->data; | |
11594 | 2958 GaimBuddy *item_buddy; |
2959 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2960 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2961 "gaim_buddy_name"); | |
2962 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2963 | |
2964 if (b == item_buddy) { | |
4359 | 2965 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2966 break; | |
2967 } | |
2968 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2969 |
4685 | 2970 return FALSE; |
4359 | 2971 } |
2972 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2973 static gboolean |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2974 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
|
2975 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2976 gtk_widget_set_sensitive(GTK_WIDGET(label), TRUE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2977 return FALSE; |
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 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2980 static gboolean |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2981 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
|
2982 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2983 gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2984 return FALSE; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2985 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2986 |
4359 | 2987 static void |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2988 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
|
2989 { |
11594 | 2990 GtkWidget *box; |
2991 GtkWidget *label; | |
2992 GtkWidget *image; | |
2993 GtkWidget *menuitem; | |
11625 | 2994 GdkPixbuf *pixbuf; |
11616 | 2995 gchar *text; |
11594 | 2996 |
2997 /* Create a pixmap for the protocol icon. */ | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2998 if (buddy != NULL) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2999 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
|
3000 else |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3001 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3002 GdkPixbuf *unscaled = gaim_gtk_create_prpl_icon(account); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3003 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3004 /* 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
|
3005 pixbuf = gdk_pixbuf_scale_simple(unscaled, 15, 15, |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3006 GDK_INTERP_BILINEAR); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3007 g_object_unref(G_OBJECT(unscaled)); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3008 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3009 |
11594 | 3010 /* Now convert it to GtkImage */ |
3011 if (pixbuf == NULL) | |
3012 image = gtk_image_new(); | |
3013 else | |
11625 | 3014 image = gtk_image_new_from_pixbuf(pixbuf); |
11594 | 3015 |
3016 gtk_size_group_add_widget(sg, image); | |
3017 | |
3018 g_object_unref(G_OBJECT(pixbuf)); | |
3019 | |
3020 /* Make our menu item */ | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3021 text = g_strdup_printf("%s (%s)", name, gaim_account_get_username(account)); |
11616 | 3022 menuitem = gtk_radio_menu_item_new_with_label(*group, text); |
3023 g_free(text); | |
11594 | 3024 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
3025 | |
3026 /* Do some evil, see some evil, speak some evil. */ | |
3027 box = gtk_hbox_new(FALSE, 0); | |
3028 | |
3029 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
3030 g_object_ref(label); | |
3031 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
3032 | |
3033 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
3034 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
3035 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3036 if (buddy != NULL && |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3037 !gaim_presence_is_online(gaim_buddy_get_presence(buddy)) && |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3038 !gaim_account_supports_offline_message(account, buddy)) |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3039 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3040 gtk_widget_set_sensitive(label, FALSE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3041 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3042 /* Set the label sensitive when the menuitem is highlighted and |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3043 * insensitive again when the mouse leaves it. This way, it |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3044 * doesn't appear weird from the highlighting of the embossed |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3045 * (insensitive style) text.*/ |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3046 g_signal_connect(menuitem, "enter-notify-event", |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3047 G_CALLBACK(send_to_item_enter_notify_cb), label); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3048 g_signal_connect(menuitem, "leave-notify-event", |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3049 G_CALLBACK(send_to_item_leave_notify_cb), label); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3050 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3051 |
11594 | 3052 g_object_unref(label); |
3053 | |
3054 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
3055 | |
3056 gtk_widget_show(label); | |
3057 gtk_widget_show(image); | |
3058 gtk_widget_show(box); | |
3059 | |
3060 /* Set our data and callbacks. */ | |
3061 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3062 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(name), g_free); |
11594 | 3063 |
3064 g_signal_connect(G_OBJECT(menuitem), "activate", | |
3065 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
3066 | |
3067 gtk_widget_show(menuitem); | |
3068 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3069 } | |
3070 | |
3071 static void | |
3072 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 3073 { |
4359 | 3074 GtkWidget *menu; |
3075 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3076 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 3077 GaimGtkConversation *gtkconv; |
3078 GSList *l, *buds; | |
3079 | |
3080 g_return_if_fail(win != NULL); | |
3081 | |
3082 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
3083 | |
11604 | 3084 g_return_if_fail(gtkconv != NULL); |
3085 | |
11594 | 3086 if (win->menu.send_to != NULL) |
3087 gtk_widget_destroy(win->menu.send_to); | |
3088 | |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12272
diff
changeset
|
3089 /* Build the Send To menu */ |
11594 | 3090 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
3091 gtk_widget_show(win->menu.send_to); | |
4359 | 3092 |
3093 menu = gtk_menu_new(); | |
11581 | 3094 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 3095 win->menu.send_to, 2); |
3096 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 3097 |
3098 gtk_widget_show(menu); | |
3099 | |
11604 | 3100 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
3101 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
|
3102 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3103 if (buds == NULL) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3104 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3105 /* The user isn't on the buddy list. */ |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3106 create_sendto_item(menu, sg, &group, NULL, gtkconv->active_conv->account, gtkconv->active_conv->name); |
11604 | 3107 } |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3108 else |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3109 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3110 GList *list = NULL, *iter; |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3111 for (l = buds; l != NULL; l = l->next) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3112 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3113 GaimBlistNode *node; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3114 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3115 node = (GaimBlistNode *) gaim_buddy_get_contact((GaimBuddy *)l->data); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3116 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3117 for (node = node->child; node != NULL; node = node->next) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3118 { |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
3119 GaimBuddy *buddy = (GaimBuddy *)node; |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3120 GaimAccount *account; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3121 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3122 if (!GAIM_BLIST_NODE_IS_BUDDY(node)) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3123 continue; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3124 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3125 account = gaim_buddy_get_account(buddy); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3126 if (gaim_account_is_connected(account)) |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3127 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3128 /* Use the GaimPresence to get unique buddies. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3129 GaimPresence *presence = gaim_buddy_get_presence(buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3130 if (!g_list_find(list, presence)) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3131 list = g_list_prepend(list, presence); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3132 } |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3133 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3134 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3135 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3136 /* 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
|
3137 * since we did a g_list_prepend() earlier. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3138 for (iter = g_list_last(list); iter != NULL; iter = iter->prev) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3139 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3140 GaimPresence *pre = iter->data; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3141 GaimBuddy *buddy = gaim_presence_get_buddies(pre)->data; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3142 create_sendto_item(menu, sg, &group, buddy, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3143 gaim_buddy_get_account(buddy), gaim_buddy_get_name(buddy)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3144 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3145 g_list_free(list); |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3146 g_slist_free(buds); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3147 } |
4359 | 3148 } |
3149 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3150 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3151 |
11594 | 3152 gtk_widget_show(win->menu.send_to); |
12455 | 3153 /* TODO: This should never be insensitive. Possibly hidden or not. */ |
11594 | 3154 if (!group) |
3155 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
3156 update_send_to_selection(win); | |
4359 | 3157 } |
3158 | |
3159 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3160 generate_invite_user_names(GaimConnection *gc) |
4359 | 3161 { |
6695 | 3162 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 3163 static GList *tmp = NULL; |
3164 | |
3165 if (tmp) | |
3166 g_list_free(tmp); | |
3167 | |
3168 tmp = g_list_append(NULL, ""); | |
3169 | |
3170 if (gc != NULL) { | |
4785 | 3171 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
3172 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
3173 continue; | |
6695 | 3174 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3175 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 3176 continue; |
6695 | 3177 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
3178 GaimBuddy *buddy; | |
3179 | |
3180 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
3181 continue; | |
3182 | |
3183 buddy = (GaimBuddy *)bnode; | |
3184 | |
3185 if (buddy->account == gc->account && | |
3186 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 3187 tmp = g_list_insert_sorted(tmp, buddy->name, |
3188 (GCompareFunc)g_utf8_collate); | |
6695 | 3189 } |
4359 | 3190 } |
3191 } | |
3192 } | |
3193 | |
3194 return tmp; | |
3195 } | |
3196 | |
9498 | 3197 static GdkPixbuf * |
9554 | 3198 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 3199 { |
9554 | 3200 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 3201 char *filename; |
10274 | 3202 const char *image = NULL; |
9554 | 3203 |
3204 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 3205 image = "founder.png"; |
9554 | 3206 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 3207 image = "op.png"; |
9554 | 3208 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 3209 image = "halfop.png"; |
9554 | 3210 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 3211 image = "voice.png"; |
9554 | 3212 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 3213 image = "ignored.png"; |
3214 } else { | |
3215 return NULL; | |
9554 | 3216 } |
10274 | 3217 |
3218 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
3219 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
3220 g_free(filename); | |
3221 | |
3222 if (!pixbuf) | |
3223 return NULL; | |
3224 | |
3225 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
3226 g_object_unref(pixbuf); | |
3227 | |
3228 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
3229 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 3230 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
3231 g_free(filename); | |
10274 | 3232 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 3233 g_object_unref(pixbuf); |
10274 | 3234 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
3235 g_object_unref(scale2); | |
9498 | 3236 } |
3237 | |
10274 | 3238 return scale; |
9498 | 3239 } |
3240 | |
4359 | 3241 static void |
11869 | 3242 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 3243 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3244 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3245 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3246 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3247 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3248 GaimPluginProtocolInfo *prpl_info; |
4359 | 3249 GtkListStore *ls; |
9498 | 3250 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3251 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3252 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3253 gboolean is_buddy; |
4359 | 3254 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3255 chat = GAIM_CONV_CHAT(conv); |
4359 | 3256 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3257 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3258 gc = gaim_conversation_get_gc(conv); |
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 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3261 return; |
4359 | 3262 |
3263 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3264 | |
9554 | 3265 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 3266 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3267 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
|
3268 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3269 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3270 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3271 |
4359 | 3272 gtk_list_store_append(ls, &iter); |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3273 |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3274 if (is_me) |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3275 { |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3276 GdkColor send_color; |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3277 gdk_color_parse(SEND_COLOR, &send_color); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3278 |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3279 gtk_list_store_set(ls, &iter, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3280 CHAT_USERS_ICON_COLUMN, pixbuf, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3281 CHAT_USERS_ALIAS_COLUMN, alias, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3282 CHAT_USERS_NAME_COLUMN, name, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3283 CHAT_USERS_FLAGS_COLUMN, flags, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3284 CHAT_USERS_COLOR_COLUMN, &send_color, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3285 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3286 -1); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3287 } |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3288 else |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3289 { |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3290 gtk_list_store_set(ls, &iter, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3291 CHAT_USERS_ICON_COLUMN, pixbuf, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3292 CHAT_USERS_ALIAS_COLUMN, alias, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3293 CHAT_USERS_NAME_COLUMN, name, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3294 CHAT_USERS_FLAGS_COLUMN, flags, |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
3295 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, name), |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3296 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3297 -1); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3298 } |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3299 |
9554 | 3300 if (pixbuf) |
3301 g_object_unref(pixbuf); | |
4359 | 3302 } |
3303 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3304 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3305 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
|
3306 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3307 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3308 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3309 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3310 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3311 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3312 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3313 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3314 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3315 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3316 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3317 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3318 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3319 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3320 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3321 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3322 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3323 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3324 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3325 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3326 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3327 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3328 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3329 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3330 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3331 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3332 (*most_matched)++; |
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 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3335 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3336 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3339 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3340 |
9605 | 3341 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3342 tab_complete(GaimConversation *conv) |
4359 | 3343 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3344 GaimGtkConversation *gtkconv; |
4359 | 3345 GtkTextIter cursor, word_start, start_buffer; |
3346 int start; | |
3347 int most_matched = -1; | |
3348 char *entered, *partial = NULL; | |
3349 char *text; | |
8021 | 3350 char *nick_partial; |
9605 | 3351 const char *prefix; |
4359 | 3352 GList *matches = NULL; |
9605 | 3353 gboolean command = FALSE; |
4359 | 3354 |
3355 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3356 | |
3357 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3358 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3359 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3360 | |
3361 word_start = cursor; | |
3362 | |
3363 /* if there's nothing there just return */ | |
3364 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3365 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
|
3366 |
4359 | 3367 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3368 &cursor, FALSE); | |
3369 | |
3370 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3371 start = strlen(text) - 1; | |
3372 | |
8021 | 3373 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3374 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3375 start-=2; |
3376 } | |
4359 | 3377 |
3378 /* find the start of the word that we're tabbing */ | |
3379 while (start >= 0 && text[start] != ' ') { | |
3380 gtk_text_iter_backward_char(&word_start); | |
3381 start--; | |
3382 } | |
3383 | |
9605 | 3384 prefix = gaim_gtk_get_cmd_prefix(); |
3385 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3386 command = TRUE; | |
3387 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3388 } | |
3389 | |
4359 | 3390 g_free(text); |
3391 | |
3392 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3393 &cursor, FALSE); | |
3394 | |
8021 | 3395 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3396 g_free(entered); |
11338 | 3397 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3398 } |
3399 | |
8021 | 3400 nick_partial = g_malloc(strlen(entered)+1); |
3401 | |
9605 | 3402 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3403 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3404 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3405 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3406 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3407 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3408 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3409 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3410 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3411 g_list_free(list); |
11338 | 3412 } 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
|
3413 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3414 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3415 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
|
3416 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3417 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3418 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3419 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3420 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3421 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3422 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3423 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3424 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3425 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3426 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3427 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
|
3428 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3429 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3430 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3431 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3432 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3433 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3434 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3435 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3436 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3437 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3438 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3439 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3440 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3441 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3442 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3443 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3444 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3445 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3446 } |
9605 | 3447 } else { |
3448 g_free(nick_partial); | |
3449 g_free(entered); | |
3450 return FALSE; | |
3451 } | |
3452 | |
8021 | 3453 g_free(nick_partial); |
3454 | |
4359 | 3455 /* we're only here if we're doing new style */ |
3456 | |
3457 /* if there weren't any matches, return */ | |
3458 if (!matches) { | |
3459 /* if matches isn't set partials won't be either */ | |
3460 g_free(entered); | |
11338 | 3461 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3462 } |
3463 | |
3464 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3465 | |
3466 if (!matches->next) { | |
3467 /* there was only one match. fill it in. */ | |
3468 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3469 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3470 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3471 | |
3472 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3473 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3474 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3475 g_free(tmp); | |
3476 } | |
3477 else | |
3478 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3479 matches->data, -1); | |
3480 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3481 g_free(matches->data); |
4359 | 3482 matches = g_list_remove(matches, matches->data); |
3483 } | |
3484 else { | |
3485 /* | |
3486 * there were lots of matches, fill in as much as possible | |
3487 * and display all of them | |
3488 */ | |
3489 char *addthis = g_malloc0(1); | |
3490 | |
3491 while (matches) { | |
3492 char *tmp = addthis; | |
3493 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3494 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3495 g_free(matches->data); |
4359 | 3496 matches = g_list_remove(matches, matches->data); |
3497 } | |
3498 | |
6982 | 3499 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3500 time(NULL)); |
3501 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3502 g_free(addthis); | |
3503 } | |
3504 | |
3505 g_free(entered); | |
3506 g_free(partial); | |
9605 | 3507 |
3508 return TRUE; | |
4359 | 3509 } |
3510 | |
10810 | 3511 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3512 { |
3513 GaimPluginProtocolInfo *prpl_info = NULL; | |
3514 GaimConnection *gc; | |
10810 | 3515 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3516 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3517 char *new_topic; |
8858 | 3518 const char *current_topic; |
7971 | 3519 |
3520 gc = gaim_conversation_get_gc(conv); | |
3521 | |
3522 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3523 return; | |
3524 | |
3525 if(prpl_info->set_chat_topic == NULL) | |
3526 return; | |
3527 | |
3528 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3529 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3530 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3531 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3532 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3533 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3534 g_free(new_topic); |
7971 | 3535 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3536 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3537 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3538 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3539 |
8858 | 3540 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3541 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3542 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3543 g_free(new_topic); |
7971 | 3544 } |
3545 | |
9554 | 3546 static gint |
3547 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3548 { | |
3549 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3550 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3551 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3552 gint ret = 0; |
3553 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3554 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3555 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3556 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3557 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3558 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3559 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3560 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3561 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3562 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3563 -1); |
9554 | 3564 |
3565 if (user1 == NULL || user2 == NULL) { | |
3566 if (!(user1 == NULL && user2 == NULL)) | |
3567 ret = (user1 == NULL) ? -1: 1; | |
3568 } else if (f1 != f2) { | |
3569 /* sort more important users first */ | |
3570 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3571 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3572 ret = buddy1 ? -1 : 1; |
9554 | 3573 } else { |
10904 | 3574 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3575 } |
3576 | |
3577 g_free(user1); | |
3578 g_free(user2); | |
3579 | |
3580 return ret; | |
3581 } | |
3582 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3583 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3584 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
|
3585 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3586 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3587 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3588 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3589 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3590 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3591 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3592 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3593 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3594 g_return_if_fail(conv != NULL); |
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 /* 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
|
3597 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
|
3598 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3599 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
|
3600 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3601 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3602 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
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 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3605 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3606 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3607 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
|
3608 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3609 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3610 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3611 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3612 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3613 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3614 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3615 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3616 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3617 alias = gaim_buddy_get_contact_alias(buddy2); |
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 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3620 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3621 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3622 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3623 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3624 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3625 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3626 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3627 f = gtk_tree_model_iter_next(model, &iter); |
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 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3630 } while (f != 0); |
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(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3633 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3634 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3635 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3636 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
|
3637 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3638 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3639 GaimPluginProtocolInfo *prpl_info; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3640 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3641 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3642 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3643 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3644 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3645 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3646 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3647 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3650 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3651 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3652 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3653 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3654 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3655 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3656 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3657 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3658 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3659 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3660 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3661 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3662 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3663 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3664 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3665 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3666 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3667 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3668 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3669 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3670 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3671 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3672 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3673 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3674 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3675 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3676 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3677 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3678 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3679 /* 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
|
3680 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3681 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3682 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3683 /* 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
|
3684 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
|
3685 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3686 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
|
3687 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3688 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3689 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3690 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3691 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3692 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3693 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3694 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
|
3695 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3696 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3697 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
|
3698 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3699 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3700 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3701 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3702 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3703 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3704 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3705 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3706 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3707 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3708 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3709 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3710 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3711 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3712 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3713 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3714 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3715 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3716 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3717 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3718 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3719 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3720 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3721 /* 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
|
3722 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3723 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3724 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3725 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3726 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3727 |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3728 static void send_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3729 { |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3730 g_signal_emit_by_name(gtkconv->entry, "message_send"); |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3731 } |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3732 |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3733 static void |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3734 entry_popup_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3735 { |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3736 GtkWidget *menuitem; |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3737 GaimGtkConversation *gtkconv = data; |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3738 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3739 g_return_if_fail(menu != NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3740 g_return_if_fail(gtkconv != NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3741 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3742 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
|
3743 G_CALLBACK(send_menu_cb), gtkconv, |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3744 0, 0, NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3745 if (gtk_text_buffer_get_char_count(imhtml->text_buffer) == 0) |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3746 gtk_widget_set_sensitive(menuitem, FALSE); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3747 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 0); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3748 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3749 menuitem = gtk_separator_menu_item_new(); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3750 gtk_widget_show(menuitem); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3751 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 1); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3752 } |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3753 |
4359 | 3754 static GtkWidget * |
10810 | 3755 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3756 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3757 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3758 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3759 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3760 GaimConnection *gc; |
4359 | 3761 GtkWidget *vpaned, *hpaned; |
10175 | 3762 GtkWidget *vbox, *hbox, *frame; |
4359 | 3763 GtkWidget *lbox, *bbox; |
3764 GtkWidget *label; | |
3765 GtkWidget *list; | |
3766 GtkWidget *button; | |
7949 | 3767 GtkWidget *sw; |
4359 | 3768 GtkListStore *ls; |
3769 GtkCellRenderer *rend; | |
3770 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3771 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3772 GList *focus_chain = NULL; |
4359 | 3773 |
3774 gtkchat = gtkconv->u.chat; | |
3775 gc = gaim_conversation_get_gc(conv); | |
3776 | |
3777 /* Setup the outer pane. */ | |
3778 vpaned = gtk_vpaned_new(); | |
3779 gtk_widget_show(vpaned); | |
3780 | |
3781 /* Setup the top part of the pane. */ | |
11243 | 3782 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3783 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3784 gtk_widget_show(vbox); |
3785 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3786 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3787 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3788 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3789 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3790 { |
11243 | 3791 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3792 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3793 gtk_widget_show(hbox); |
3794 | |
3795 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3796 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3797 gtk_widget_show(label); |
3798 | |
3799 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3800 |
7971 | 3801 if(prpl_info->set_chat_topic == NULL) { |
3802 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3803 } else { | |
3804 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3805 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3806 } |
3807 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3808 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3809 gtk_widget_show(gtkchat->topic_text); |
3810 } | |
3811 | |
3812 /* Setup the horizontal pane. */ | |
3813 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3814 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3815 gtk_widget_show(hpaned); |
3816 | |
10175 | 3817 /* Setup gtkihmtml. */ |
3818 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3819 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3820 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3821 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3822 gtk_widget_show(frame); | |
3823 | |
3824 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3825 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3826 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3827 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3828 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3829 |
4359 | 3830 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3831 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3832 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3833 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3834 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3835 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3836 |
3837 /* Build the right pane. */ | |
11243 | 3838 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3839 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3840 gtk_widget_show(lbox); |
3841 | |
3842 /* Setup the label telling how many people are in the room. */ | |
3843 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3844 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3845 gtk_widget_show(gtkchat->count); | |
3846 | |
3847 /* Setup the list of users. */ | |
7949 | 3848 sw = gtk_scrolled_window_new(NULL, NULL); |
3849 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3850 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3851 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3852 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3853 gtk_widget_show(sw); | |
4359 | 3854 |
9554 | 3855 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
|
3856 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
|
3857 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3858 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3859 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3860 GTK_SORT_ASCENDING); |
3861 | |
3862 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3863 | |
9498 | 3864 rend = gtk_cell_renderer_pixbuf_new(); |
3865 | |
4359 | 3866 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3867 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3868 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3869 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3870 |
3871 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3872 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3873 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3874 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3875 |
9498 | 3876 rend = gtk_cell_renderer_text_new(); |
3877 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3878 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3879 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3880 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3881 NULL); |
4359 | 3882 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3883 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3884 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3885 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3886 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3887 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3888 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3889 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3890 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3891 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3892 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3893 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3894 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3895 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3896 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3897 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3898 #endif |
4359 | 3899 |
3900 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3901 | |
3902 gtk_widget_set_size_request(list, 150, -1); | |
3903 | |
3904 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3905 gtk_widget_show(list); | |
3906 | |
3907 gtkchat->list = list; | |
3908 | |
7949 | 3909 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3910 |
3911 /* Setup the user list toolbar. */ | |
11243 | 3912 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3913 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3914 gtk_widget_show(bbox); | |
3915 | |
3916 /* IM */ | |
10221 | 3917 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3918 GAIM_BUTTON_VERTICAL); |
10500 | 3919 gtkchat->userlist_im = button; |
4359 | 3920 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3921 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
|
3922 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3923 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3924 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3925 |
3926 gtk_widget_show(button); | |
3927 | |
3928 /* Ignore */ | |
3929 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3930 GAIM_BUTTON_VERTICAL); | |
10500 | 3931 gtkchat->userlist_ignore = button; |
4359 | 3932 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3933 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
|
3934 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3935 _("Ignore the user"), NULL); |
4359 | 3936 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3937 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3938 gtk_widget_show(button); |
3939 | |
3940 /* Info */ | |
3941 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3942 GAIM_BUTTON_VERTICAL); | |
10500 | 3943 gtkchat->userlist_info = button; |
4359 | 3944 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3945 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3946 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3947 _("Get the user's information"), NULL); |
4359 | 3948 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3949 G_CALLBACK(info_cb), gtkconv); |
4359 | 3950 |
3951 gtk_widget_show(button); | |
3952 | |
10175 | 3953 /* Setup the bottom half of the conversation window */ |
11243 | 3954 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3955 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3956 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3957 |
11243 | 3958 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3959 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3960 gtk_widget_show(gtkconv->lower_hbox); | |
3961 | |
11243 | 3962 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3963 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3964 gtk_widget_show(vbox); | |
3965 | |
10175 | 3966 /* Setup the toolbar, entry widget and all signals */ |
3967 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3968 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3969 gtk_widget_show(frame); |
3970 | |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3971 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3972 G_CALLBACK(entry_popup_menu_cb), gtkconv); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3973 |
9005 | 3974 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3975 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3976 gaim_account_get_protocol_name(conv->account)); |
10175 | 3977 gtk_widget_set_size_request(gtkconv->entry, -1, |
3978 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3979 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3980 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3981 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3982 |
3983 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3984 G_CALLBACK(entry_key_press_cb), gtkconv); |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3985 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3986 G_CALLBACK(send_cb), gtkconv); |
4359 | 3987 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3988 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3989 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3990 G_CALLBACK(size_allocate_cb), gtkconv); |
3991 | |
3992 default_formatize(gtkconv); | |
4359 | 3993 |
9080 | 3994 /* |
3995 * Focus for chat windows should be as follows: | |
3996 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3997 * user list buttons -> entry -> buttons at bottom | |
3998 */ | |
9332 | 3999 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4000 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
4001 | |
4359 | 4002 return vpaned; |
4003 } | |
4004 | |
4005 static GtkWidget * | |
10810 | 4006 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 4007 { |
10810 | 4008 GaimConversation *conv = gtkconv->active_conv; |
10175 | 4009 GtkWidget *frame; |
4359 | 4010 GtkWidget *paned; |
10175 | 4011 GtkWidget *vbox; |
4012 GtkWidget *vbox2; | |
9080 | 4013 GList *focus_chain = NULL; |
4359 | 4014 |
10175 | 4015 /* Setup the outer pane */ |
4359 | 4016 paned = gtk_vpaned_new(); |
4017 gtk_widget_show(paned); | |
4018 | |
10175 | 4019 /* Setup the top part of the pane */ |
11243 | 4020 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
4021 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 4022 gtk_widget_show(vbox); |
4023 | |
10175 | 4024 /* Setup the gtkimhtml widget */ |
4025 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
4026 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 4027 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 4028 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
4029 gtk_widget_show(frame); | |
4030 | |
4031 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4032 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4033 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 4034 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 4035 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 4036 |
4037 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 4038 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 4039 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 4040 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 4041 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 4042 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 4043 |
10175 | 4044 /* Setup the bottom half of the conversation window */ |
11243 | 4045 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 4046 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4047 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4048 |
11243 | 4049 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 4050 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
4051 gtk_widget_show(gtkconv->lower_hbox); | |
4052 | |
11243 | 4053 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 4054 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
4055 gtk_widget_show(vbox2); | |
8821 | 4056 |
10175 | 4057 /* Setup the toolbar, entry widget and all signals */ |
4058 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 4059 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 4060 gtk_widget_show(frame); |
4061 | |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4062 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4063 G_CALLBACK(entry_popup_menu_cb), gtkconv); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4064 |
9005 | 4065 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 4066 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 4067 gaim_account_get_protocol_name(conv->account)); |
10175 | 4068 gtk_widget_set_size_request(gtkconv->entry, -1, |
4069 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4070 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4071 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 4072 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
|
4073 |
4359 | 4074 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 4075 G_CALLBACK(entry_key_press_cb), gtkconv); |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4076 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4077 G_CALLBACK(send_cb), gtkconv); |
4359 | 4078 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 4079 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 4080 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 4081 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 4082 |
4083 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 4084 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 4085 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 4086 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 4087 |
8481 | 4088 /* had to move this after the imtoolbar is attached so that the |
4089 * signals get fired to toggle the buttons on the toolbar as well. | |
4090 */ | |
10810 | 4091 default_formatize(gtkconv); |
4359 | 4092 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4093 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4094 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4095 |
8758 | 4096 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 4097 gtkconv->u.im->show_icon = TRUE; |
4359 | 4098 |
9080 | 4099 /* |
4100 * Focus for IM windows should be as follows: | |
10356 | 4101 * Tab title -> conversation scrollback -> entry |
9080 | 4102 */ |
9332 | 4103 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4104 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 4105 |
4359 | 4106 return paned; |
4107 } | |
4108 | |
4109 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4110 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 4111 GtkSelectionData *sd, guint info, guint t, |
4112 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4113 { |
10810 | 4114 GaimConversation *conv = gtkconv->active_conv; |
11581 | 4115 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4116 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4117 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4118 { |
4781 | 4119 GaimBlistNode *n = NULL; |
6695 | 4120 GaimBuddy *b; |
11581 | 4121 GaimGtkConversation *gtkconv = NULL; |
9622 | 4122 |
11812 | 4123 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4124 |
6695 | 4125 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
4126 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
4127 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
4128 b = (GaimBuddy*)n; | |
4129 else | |
4781 | 4130 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4131 |
9622 | 4132 /* |
4133 * If we already have an open conversation with this buddy, then | |
4134 * just move the conv to this window. Otherwise, create a new | |
4135 * conv and add it to this window. | |
4136 */ | |
11338 | 4137 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 4138 if (c != NULL) { |
11581 | 4139 GaimGtkWindow *oldwin; |
4140 gtkconv = GAIM_GTK_CONVERSATION(c); | |
4141 oldwin = gtkconv->win; | |
9622 | 4142 if (oldwin != win) { |
11581 | 4143 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
4144 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 4145 } |
4146 } else { | |
11338 | 4147 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 4148 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 4149 if (gtkconv->win != win) |
4150 { | |
4151 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
4152 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
4153 } | |
9622 | 4154 } |
4155 | |
4156 /* Make this conversation the active conversation */ | |
11581 | 4157 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4158 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4159 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 4160 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4161 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
|
4162 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4163 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4164 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4165 GaimAccount *account; |
11581 | 4166 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4167 |
11137 | 4168 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 4169 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4170 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4171 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4172 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4173 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4174 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4175 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4176 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4177 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4178 { |
11338 | 4179 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 4180 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 4181 if (gtkconv->win != win) |
4182 { | |
4183 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
4184 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
4185 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4186 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4187 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4188 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4189 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4190 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4191 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4192 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4193 } |
9525 | 4194 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 4195 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 4196 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 4197 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 4198 } |
10145 | 4199 else |
4200 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4201 } |
4359 | 4202 |
4203 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4204 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4205 { |
10145 | 4206 GTK_IMHTML_DND_TARGETS, |
4207 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
4208 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4209 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4210 |
10810 | 4211 static GaimGtkConversation * |
4212 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
4213 { | |
4214 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
4215 GaimContact *c; | |
4216 GaimBlistNode *cn; | |
10935 | 4217 |
10810 | 4218 if (!bud) |
4219 return NULL; | |
10935 | 4220 |
10810 | 4221 if (!(c = gaim_buddy_get_contact(bud))) |
4222 return NULL; | |
10935 | 4223 |
10810 | 4224 cn = (GaimBlistNode *)c; |
4225 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
4226 GaimConversation *conv; | |
11338 | 4227 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 4228 if (conv->ui_data) |
4229 return conv->ui_data; | |
4230 } | |
4231 } | |
10935 | 4232 |
10810 | 4233 return NULL; |
4234 } | |
4235 | |
11855 | 4236 static void |
4237 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
4238 { | |
4239 GList *list; | |
4240 | |
4241 g_return_if_fail(bnode); | |
4242 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
4243 | |
4244 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
4245 { | |
4246 GaimGtkWindow *win = list->data; | |
4247 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4248 | |
4249 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
4250 continue; | |
4251 | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
4252 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_MENU); |
11855 | 4253 } |
4254 } | |
4255 | |
11581 | 4256 /************************************************************************** |
4257 * Conversation UI operations | |
4258 **************************************************************************/ | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4259 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4260 private_gtkconv_new(GaimConversation *conv, gboolean hidden) |
11581 | 4261 { |
4262 GaimGtkConversation *gtkconv; | |
4263 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 4264 GtkWidget *pane = NULL; |
4265 GtkWidget *tab_cont; | |
11581 | 4266 |
4267 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 4268 conv->ui_data = gtkconv; |
4269 if (!g_list_find(gtkconv->convs, conv)) | |
4270 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 4271 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 4272 return; |
4359 | 4273 } |
4274 | |
11581 | 4275 gtkconv = g_new0(GaimGtkConversation, 1); |
4276 conv->ui_data = gtkconv; | |
4277 gtkconv->active_conv = conv; | |
4278 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
4279 | |
4280 /* Setup some initial variables. */ | |
4281 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
4282 gtkconv->tooltips = gtk_tooltips_new(); | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4283 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4284 gtkconv->unseen_count = 0; |
11581 | 4285 |
4286 if (conv_type == GAIM_CONV_TYPE_IM) { | |
4287 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
4288 | |
4289 pane = setup_im_pane(gtkconv); | |
4290 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
4291 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
4292 pane = setup_chat_pane(gtkconv); | |
4293 } | |
4294 | |
12101 | 4295 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
4296 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
4297 | |
11581 | 4298 if (pane == NULL) { |
4299 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
4300 g_free(gtkconv->u.chat); | |
4301 else if (conv_type == GAIM_CONV_TYPE_IM) | |
4302 g_free(gtkconv->u.im); | |
4303 | |
4304 g_free(gtkconv); | |
4305 conv->ui_data = NULL; | |
4306 return; | |
10449 | 4307 } |
11581 | 4308 |
4309 /* Setup drag-and-drop */ | |
4310 gtk_drag_dest_set(pane, | |
4311 GTK_DEST_DEFAULT_MOTION | | |
4312 GTK_DEST_DEFAULT_DROP, | |
4313 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4314 GDK_ACTION_COPY); | |
4315 gtk_drag_dest_set(pane, | |
4316 GTK_DEST_DEFAULT_MOTION | | |
4317 GTK_DEST_DEFAULT_DROP, | |
4318 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4319 GDK_ACTION_COPY); | |
4320 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4321 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4322 GDK_ACTION_COPY); | |
4323 | |
4324 gtk_drag_dest_set(gtkconv->entry, 0, | |
4325 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4326 GDK_ACTION_COPY); | |
4327 | |
4328 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
4329 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4330 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
4331 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4332 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
4333 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4334 | |
4335 /* Setup the container for the tab. */ | |
4336 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
4337 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
4338 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
4339 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
4340 gtk_widget_show(pane); | |
4341 | |
4342 gtkconv->make_sound = TRUE; | |
4343 | |
4344 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
4345 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4346 else |
11581 | 4347 gtk_widget_hide(gtkconv->toolbar); |
4348 | |
12188 | 4349 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), |
4350 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4351 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4352 gaim_account_get_protocol_name(conv->account)); |
11581 | 4353 |
4354 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
4355 G_CALLBACK(gtk_widget_grab_focus), | |
4356 gtkconv->entry); | |
4357 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4358 if (hidden) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4359 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4360 else |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4361 gaim_gtkconv_placement_place(gtkconv); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
4362 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4363 if (nick_colors == NULL) { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4364 nbr_nick_colors = NUM_NICK_COLORS; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4365 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
|
4366 } |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4367 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4368 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4369 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4370 gaim_gtkconv_new_hidden(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4371 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4372 private_gtkconv_new(conv, TRUE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4373 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4374 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4375 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4376 gaim_gtkconv_new(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4377 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4378 private_gtkconv_new(conv, FALSE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4379 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4380 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4381 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4382 received_im_msg_cb(GaimAccount *account, char *sender, char *message, |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4383 GaimConversation *conv, int flags) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4384 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4385 GaimConversationUiOps *ui_ops = gaim_gtk_conversations_get_conv_ui_ops(); |
12719
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4386 if (conv != NULL) |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4387 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4388 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4389 /* create hidden conv if hide_new pref is always */ |
12719
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4390 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
|
4391 { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4392 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4393 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4394 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4395 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4396 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4397 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4398 /* 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
|
4399 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
|
4400 !gaim_status_is_available(gaim_account_get_active_status(account))) |
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4401 { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4402 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4403 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4404 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4405 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4406 } |
11581 | 4407 } |
4408 | |
4359 | 4409 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4410 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4411 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4412 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4413 |
10810 | 4414 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4415 /* Don't destroy ourselves until all our convos are gone */ | |
4416 if (gtkconv->convs) | |
4417 return; | |
11508 | 4418 |
11581 | 4419 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4420 | |
9504 | 4421 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4422 gaim_request_close_with_handle(conv); | |
4359 | 4423 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4424 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4425 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4426 |
11338 | 4427 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4428 if (gtkconv->u.im->icon_timer != 0) |
4429 g_source_remove(gtkconv->u.im->icon_timer); | |
4430 | |
4359 | 4431 if (gtkconv->u.im->anim != NULL) |
4793 | 4432 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4433 |
4434 g_free(gtkconv->u.im); | |
11581 | 4435 } 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
|
4436 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4437 g_free(gtkconv->u.chat); |
4438 } | |
4439 | |
4633 | 4440 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4441 | |
4359 | 4442 g_free(gtkconv); |
4443 } | |
4444 | |
4445 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4446 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4447 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4448 time_t mtime) |
4359 | 4449 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4450 GaimGtkConversation *gtkconv; |
4359 | 4451 |
4452 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4453 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4454 |
6982 | 4455 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4456 } |
4457 | |
4458 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4459 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4460 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4461 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4462 GaimGtkConversation *gtkconv; |
4359 | 4463 |
4464 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4465 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4466 |
10398 | 4467 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4468 |
6982 | 4469 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4470 } |
4471 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4472 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4473 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4474 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4475 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4476 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4477 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4478 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4479 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4480 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4481 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4482 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4483 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4484 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4485 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4486 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4487 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4488 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4489 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4490 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4491 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4492 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4493 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4494 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4495 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4496 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4497 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4498 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4499 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4500 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4501 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4502 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4503 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4504 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4505 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4506 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4507 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4508 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4509 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4510 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4511 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4512 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4513 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4514 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4515 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4516 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4517 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4518 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4519 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4520 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4521 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4522 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4523 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4524 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4525 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4526 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4527 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4528 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4529 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4530 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4531 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4532 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4533 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4534 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4535 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4536 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4537 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4538 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4539 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4540 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4541 buddytag = gtk_text_buffer_create_tag( |
11096 | 4542 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4543 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4544 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4545 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4546 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4547 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4548 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4549 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4550 |
4359 | 4551 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4552 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4553 const char *message, GaimMessageFlags flags, |
4359 | 4554 time_t mtime) |
4555 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4556 GaimGtkConversation *gtkconv; |
11581 | 4557 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4558 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4559 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4560 GaimPluginProtocolInfo *prpl_info; |
4359 | 4561 int gtk_font_options = 0; |
12553 | 4562 int gtk_font_options_all = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4563 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4564 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4565 int line_count; |
4359 | 4566 char buf2[BUF_LONG]; |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4567 char *mdate; |
4359 | 4568 char color[10]; |
4569 char *str; | |
4570 char *with_font_tag; | |
4896 | 4571 char *sml_attrib = NULL; |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4572 size_t length; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4573 GaimConversationType type; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4574 char *displaying; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4575 gboolean plugin_return; |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4576 struct tm tm = *(localtime(&mtime)); |
4895 | 4577 |
4359 | 4578 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4579 |
12553 | 4580 if(gaim_prefs_get_bool("/gaim/gtk/conversations/use_smooth_scrolling")) |
4581 gtk_font_options_all |= GTK_IMHTML_USE_SMOOTHSCROLLING; | |
4582 | |
11581 | 4583 /* Set the active conversation to the one that just messaged us. */ |
4584 /* 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
|
4585 gaim_gtkconv_set_active_conversation(conv); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4586 type = gaim_conversation_get_type(conv); |
11581 | 4587 |
4359 | 4588 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4589 account = gaim_conversation_get_account(conv); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4590 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4591 displaying = g_strdup(message); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4592 plugin_return = GPOINTER_TO_INT(gaim_signal_emit_return_1( |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4593 gaim_gtk_conversations_get_handle(), (type == GAIM_CONV_TYPE_IM ? |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4594 "displaying-im-msg" : "displaying-chat-msg"), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4595 account, conv, &displaying, flags)); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4596 if (plugin_return) |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4597 { |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4598 g_free(displaying); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4599 return; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4600 } |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4601 message = displaying; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4602 length = strlen(message) + 1; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4603 |
11581 | 4604 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4605 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4606 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4607 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4608 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4609 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4610 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4611 /* 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
|
4612 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4613 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4614 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4615 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4616 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4617 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4618 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4619 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4620 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4621 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4622 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4623 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4624 |
8677 | 4625 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
12553 | 4626 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", gtk_font_options_all); |
8677 | 4627 |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4628 mdate = gaim_signal_emit_return_1(gaim_gtk_conversations_get_handle(), |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4629 "conversation-timestamp", |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4630 conv, &tm); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4631 if (mdate == NULL) |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4632 { |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4633 char buf[64]; |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4634 |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4635 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
|
4636 strftime(buf, sizeof(buf), "%x %X", &tm); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4637 else |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4638 strftime(buf, sizeof(buf), "%X", &tm); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4639 |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4640 mdate = g_strdup(buf); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4641 } |
4359 | 4642 |
4896 | 4643 if(gc) |
9699 | 4644 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4645 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4646 |
10503 | 4647 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4648 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4649 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4650 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4651 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4652 |
7956 | 4653 /* this is gonna crash one day, I can feel it. */ |
4654 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4655 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4656 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4657 } |
4359 | 4658 |
12553 | 4659 |
10737 | 4660 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4661 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4662 g_snprintf(buf2, sizeof(buf2), |
8690 | 4663 "<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
|
4664 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4665 |
12553 | 4666 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
7440 | 4667 |
8722 | 4668 } else if (flags & GAIM_MESSAGE_ERROR) { |
4669 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4670 "<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
|
4671 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4672 |
12553 | 4673 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
8962 | 4674 |
7431 | 4675 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4676 g_snprintf(buf2, BUF_LONG, |
8690 | 4677 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4678 sml_attrib ? sml_attrib : "", message); |
7440 | 4679 |
12553 | 4680 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
10346 | 4681 } else if (flags & GAIM_MESSAGE_RAW) { |
12553 | 4682 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, gtk_font_options_all); |
10346 | 4683 } else { |
4895 | 4684 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4685 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
|
4686 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4687 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4688 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
|
4689 int tag_end_offset = 0; |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4690 GtkSmileyTree *tree = NULL; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4691 GHashTable *smiley_data = NULL; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4692 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4693 if (flags & GAIM_MESSAGE_SEND) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4694 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4695 /* Temporarily revert to the original smiley-data to avoid showing up |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4696 * custom smileys of the buddy when sending message |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4697 */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4698 tree = GTK_IMHTML(gtkconv->imhtml)->default_smilies; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4699 GTK_IMHTML(gtkconv->imhtml)->default_smilies = |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4700 GTK_IMHTML(gtkconv->entry)->default_smilies; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4701 smiley_data = GTK_IMHTML(gtkconv->imhtml)->smiley_data; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4702 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
|
4703 } |
7440 | 4704 |
6621 | 4705 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4706 str = g_malloc(1024); |
7440 | 4707 |
4359 | 4708 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4709 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4710 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4711 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4712 tag_start_offset += 3; |
4359 | 4713 } |
4714 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4715 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4716 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4717 tag_end_offset = 2; |
4359 | 4718 strcpy(color, "#00FF00"); |
4719 } | |
7440 | 4720 } |
4359 | 4721 else { |
10504 | 4722 if (gaim_message_meify(new_message, -1)) { |
4359 | 4723 str = g_malloc(1024); |
7440 | 4724 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4725 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4726 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
|
4727 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4728 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4729 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4730 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4731 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4732 } |
7440 | 4733 |
6621 | 4734 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4735 strcpy(color, HIGHLIGHT_COLOR); |
4359 | 4736 else |
4737 strcpy(color, "#062585"); | |
4738 } | |
4739 else { | |
4740 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4741 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4742 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
|
4743 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4744 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4745 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4746 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4747 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4748 } |
6621 | 4749 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4750 strcpy(color, HIGHLIGHT_COLOR); |
6621 | 4751 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4752 if (flags & GAIM_MESSAGE_COLORIZE) { |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
4753 GdkColor *col = get_nick_color(gtkconv, name); |
10346 | 4754 |
10108 | 4755 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4756 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4757 } else |
7854 | 4758 strcpy(color, RECV_COLOR); |
4359 | 4759 } |
6621 | 4760 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4761 strcpy(color, SEND_COLOR); |
10892 | 4762 else { |
4763 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4764 strcpy(color, "#000000"); | |
4765 } | |
4359 | 4766 } |
4767 } | |
10892 | 4768 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4769 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4770 g_free(alias_escaped); |
11508 | 4771 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4772 /* 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
|
4773 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4774 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4775 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4776 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4777 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4778 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4779 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4780 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4781 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4782 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4783 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4784 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4785 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4786 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4787 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4788 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4789 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4790 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4791 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4792 /* 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
|
4793 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4794 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4795 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4796 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4797 } |
7440 | 4798 |
12553 | 4799 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
|
4800 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4801 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4802 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4803 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4804 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4805 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4806 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4807 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4808 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4809 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4810 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4811 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4812 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4813 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4814 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4815 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4816 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4817 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4818 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4819 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4820 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4821 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4822 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4823 |
4359 | 4824 g_free(str); |
4825 | |
4895 | 4826 if(gc){ |
4896 | 4827 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4828 char *post = "</font>"; |
4829 int pre_len = strlen(pre); | |
4830 int post_len = strlen(post); | |
7440 | 4831 |
4895 | 4832 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4833 |
4895 | 4834 strcpy(with_font_tag, pre); |
4835 memcpy(with_font_tag + pre_len, new_message, length); | |
4836 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4837 |
4895 | 4838 length += pre_len + post_len; |
4839 g_free(pre); | |
4840 } | |
4608 | 4841 else |
4895 | 4842 with_font_tag = g_memdup(new_message, length); |
7440 | 4843 |
8962 | 4844 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
12553 | 4845 with_font_tag, gtk_font_options | gtk_font_options_all); |
7440 | 4846 |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4847 if (flags & GAIM_MESSAGE_SEND) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4848 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4849 /* Restore the smiley-data */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4850 GTK_IMHTML(gtkconv->imhtml)->default_smilies = tree; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4851 GTK_IMHTML(gtkconv->imhtml)->smiley_data = smiley_data; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4852 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4853 |
7440 | 4854 g_free(with_font_tag); |
7447 | 4855 g_free(new_message); |
7440 | 4856 } |
4857 | |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4858 g_free(mdate); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4859 g_free(sml_attrib); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4860 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4861 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4862 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4863 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4864 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4865 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4866 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4867 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4868 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4869 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4870 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4871 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
|
4872 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4873 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4874 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4875 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4876 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4877 } |
12902
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4878 |
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4879 gaim_signal_emit(gaim_gtk_conversations_get_handle(), |
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4880 (type == GAIM_CONV_TYPE_IM ? "displayed-im-msg" : "displayed-chat-msg"), |
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4881 account, conv, message, flags); |
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4882 g_free(displaying); |
4359 | 4883 } |
4884 | |
4885 static void | |
12463
b1717befbb26
[gaim-migrate @ 14773]
Richard Laager <rlaager@wiktel.com>
parents:
12455
diff
changeset
|
4886 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
|
4887 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4888 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4889 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4890 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4891 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4892 GList *ll; |
11869 | 4893 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4894 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4895 int num_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 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4898 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4899 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4900 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4901 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
|
4902 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4903 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4904 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4905 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4906 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4907 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4908 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4909 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4910 l = users; |
11869 | 4911 ll = flags; |
4912 lll = aliases; | |
4913 while (l != NULL && ll != NULL && lll != NULL) { | |
4914 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
|
4915 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4916 ll = ll->next; |
11869 | 4917 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4918 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4919 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4920 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4921 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4922 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
|
4923 const char *new_name, const char *new_alias) |
4359 | 4924 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4925 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4926 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4927 GaimGtkChatPane *gtkchat; |
11869 | 4928 GaimConvChatBuddyFlags flags; |
4359 | 4929 GtkTreeIter iter; |
4930 GtkTreeModel *model; | |
4931 int f = 1; | |
4932 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4933 chat = GAIM_CONV_CHAT(conv); |
4359 | 4934 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4935 gtkchat = gtkconv->u.chat; | |
4936 | |
9554 | 4937 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4938 | |
4939 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4940 return; | |
4941 | |
4942 while (f != 0) { | |
4943 char *val; | |
4944 | |
11869 | 4945 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4946 |
4947 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4948 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4949 g_free(val); | |
4359 | 4950 break; |
4951 } | |
9554 | 4952 |
4953 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4954 | |
4955 g_free(val); | |
4359 | 4956 } |
4957 | |
9554 | 4958 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4959 return; |
4960 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4961 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4962 |
11869 | 4963 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4964 } |
4965 | |
4966 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4967 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4968 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4969 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4970 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4971 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4972 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4973 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4974 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4975 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4976 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4977 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4978 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4979 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4980 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4981 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4982 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4983 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
|
4984 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4985 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4986 for (l = users; l != NULL; l = l->next) { |
9554 | 4987 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4988 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4989 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4990 continue; |
4991 | |
4992 do { | |
4993 char *val; | |
4994 | |
4995 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4996 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4997 | |
9696 | 4998 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4999 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 5000 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 5001 #else |
5002 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5003 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5004 #endif | |
5005 } | |
9554 | 5006 else |
5007 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5008 | |
5009 g_free(val); | |
5010 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5011 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5012 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5013 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5014 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5015 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5016 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5017 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5018 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5019 |
9554 | 5020 static void |
5021 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
5022 { | |
5023 GaimConvChat *chat; | |
11869 | 5024 GaimConvChatBuddyFlags flags; |
9554 | 5025 GaimGtkConversation *gtkconv; |
5026 GaimGtkChatPane *gtkchat; | |
5027 GtkTreeIter iter; | |
5028 GtkTreeModel *model; | |
5029 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5030 char *alias = NULL; |
9554 | 5031 |
5032 chat = GAIM_CONV_CHAT(conv); | |
5033 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5034 gtkchat = gtkconv->u.chat; | |
5035 | |
5036 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
5037 | |
5038 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5039 return; | |
5040 | |
5041 while (f != 0) { | |
5042 char *val; | |
5043 | |
5044 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5045 | |
5046 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
5047 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 5048 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
5049 g_free(val); | |
5050 break; | |
5051 } | |
5052 | |
5053 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5054 | |
5055 g_free(val); | |
5056 } | |
5057 | |
5058 if (!gaim_conv_chat_find_user(chat, user)) | |
5059 return; | |
5060 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5061 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5062 |
11869 | 5063 flags = gaim_conv_chat_user_get_flags(chat, user); |
5064 | |
5065 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5066 g_free(alias); |
9554 | 5067 } |
5068 | |
11581 | 5069 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5070 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5071 { |
11581 | 5072 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
5073 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5074 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5075 |
11581 | 5076 win = gtkconv->win; |
5077 | |
5078 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
|
5079 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5080 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5081 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5082 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
5083 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5084 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5085 |
12335 | 5086 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data) |
5087 { | |
5088 GtkIMHtmlSmiley *smiley; | |
12682 | 5089 |
12335 | 5090 smiley = (GtkIMHtmlSmiley *)user_data; |
5091 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
12682 | 5092 |
12335 | 5093 if (smiley->icon) |
5094 g_object_ref(G_OBJECT(smiley->icon)); | |
12682 | 5095 #ifdef DEBUG_CUSTOM_SMILEY |
5096 gaim_debug_info("custom-smiley", "gaim_gtkconv_custom_smiley_allocated(): got GdkPixbufAnimation %p for smiley '%s'\n", smiley->icon, smiley->smile); | |
12335 | 5097 #endif |
5098 } | |
5099 | |
5100 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data) | |
5101 { | |
5102 GtkIMHtmlSmiley *smiley; | |
5103 GtkWidget *icon = NULL; | |
5104 GtkTextChildAnchor *anchor = NULL; | |
5105 GSList *current = NULL; | |
12682 | 5106 |
12335 | 5107 smiley = (GtkIMHtmlSmiley *)user_data; |
5108 if (!smiley->imhtml) { | |
5109 #ifdef DEBUG_CUSTOM_SMILEY | |
12682 | 5110 gaim_debug_error("custom-smiley", "gaim_gtkconv_custom_smiley_closed(): orphan smiley found: %p\n", smiley); |
12335 | 5111 #endif |
5112 g_object_unref(G_OBJECT(loader)); | |
5113 smiley->loader = NULL; | |
5114 return; | |
5115 } | |
5116 | |
5117 for (current = smiley->anchors; current; current = g_slist_next(current)) { | |
5118 | |
5119 icon = gtk_image_new_from_animation(smiley->icon); | |
5120 | |
12682 | 5121 #ifdef DEBUG_CUSTOM_SMILEY |
5122 gaim_debug_info("custom-smiley", "gaim_gtkconv_custom_smiley_closed(): got GtkImage %p from GtkPixbufAnimation %p for smiley '%s'\n", | |
5123 icon, smiley->icon, smiley->smile); | |
12335 | 5124 #endif |
5125 if (icon) { | |
5126 gtk_widget_show(icon); | |
12682 | 5127 |
12335 | 5128 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
5129 | |
5130 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smiley->smile)), g_free); | |
5131 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley->smile), g_free); | |
12682 | 5132 |
12335 | 5133 if (smiley->imhtml) |
5134 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(smiley->imhtml), icon, anchor); | |
5135 } | |
5136 | |
5137 } | |
5138 | |
5139 g_slist_free(smiley->anchors); | |
5140 smiley->anchors = NULL; | |
12682 | 5141 |
12335 | 5142 g_object_unref(G_OBJECT(loader)); |
5143 smiley->loader = NULL; | |
5144 } | |
5145 | |
10526 | 5146 static gboolean |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5147 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
|
5148 { |
10526 | 5149 GtkIMHtmlSmiley *smiley; |
5150 GdkPixbufLoader *loader; | |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5151 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5152 smiley = gtk_imhtml_smiley_get(imhtml, sml, smile); |
10526 | 5153 |
5154 if (smiley) { | |
11525 | 5155 |
5156 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
5157 return FALSE; | |
5158 } | |
5159 | |
5160 /* Close the old GdkPixbufAnimation, then create a new one for | |
5161 * the smiley we are about to receive */ | |
5162 g_object_unref(G_OBJECT(smiley->icon)); | |
5163 | |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5164 /* XXX: Is it necessary to _unref the loader first? */ |
11525 | 5165 smiley->loader = gdk_pixbuf_loader_new(); |
12335 | 5166 smiley->icon = NULL; |
5167 | |
5168 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); | |
5169 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
5170 | |
11525 | 5171 return TRUE; |
10526 | 5172 } |
5173 | |
5174 loader = gdk_pixbuf_loader_new(); | |
5175 | |
5176 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
5177 /* 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
|
5178 GtkIMHtmlSmiley by opaque */ |
10526 | 5179 smiley = g_new0(GtkIMHtmlSmiley, 1); |
5180 smiley->file = NULL; | |
5181 smiley->smile = g_strdup(smile); | |
5182 smiley->loader = loader; | |
11525 | 5183 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 5184 |
12335 | 5185 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); |
5186 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
11525 | 5187 |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5188 gtk_imhtml_associate_smiley(imhtml, sml, smiley); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5189 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5190 return TRUE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5191 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5192 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5193 static gboolean |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5194 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
|
5195 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5196 GaimGtkConversation *gtkconv; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5197 struct smiley_list *list; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5198 const char *sml = NULL, *conv_sml; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5199 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5200 if (!conv || !smile || !*smile) { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5201 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5202 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5203 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5204 /* If smileys are off, return false */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5205 if (gaim_gtkthemes_smileys_disabled()) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5206 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5207 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5208 /* If possible add this smiley to the current theme. |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5209 * 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
|
5210 conv_sml = gaim_account_get_protocol_name(conv->account); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5211 gtkconv = GAIM_GTK_CONVERSATION(conv); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5212 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5213 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
|
5214 if (!strcmp(list->sml, conv_sml)) { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5215 sml = list->sml; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5216 break; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5217 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5218 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5219 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5220 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
|
5221 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5222 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5223 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
|
5224 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
|
5225 return FALSE; |
10537 | 5226 |
10526 | 5227 return TRUE; |
5228 } | |
5229 | |
10537 | 5230 static void |
10526 | 5231 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 5232 const guchar *data, gsize size) |
10526 | 5233 { |
5234 GaimGtkConversation *gtkconv; | |
5235 GtkIMHtmlSmiley *smiley; | |
10537 | 5236 GdkPixbufLoader *loader; |
10526 | 5237 const char *sml; |
5238 | |
5239 sml = gaim_account_get_protocol_name(conv->account); | |
5240 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5241 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5242 | |
10537 | 5243 if (!smiley) |
10526 | 5244 return; |
10537 | 5245 |
10526 | 5246 loader = smiley->loader; |
10537 | 5247 if (!loader) |
10526 | 5248 return; |
5249 | |
5250 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
5251 } | |
5252 | |
5253 static void | |
5254 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
5255 { | |
5256 GaimGtkConversation *gtkconv; | |
5257 GtkIMHtmlSmiley *smiley; | |
5258 GdkPixbufLoader *loader; | |
5259 const char *sml; | |
5260 | |
5261 g_return_if_fail(conv != NULL); | |
5262 g_return_if_fail(smile != NULL); | |
5263 | |
5264 sml = gaim_account_get_protocol_name(conv->account); | |
5265 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5266 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5267 | |
10537 | 5268 if (!smiley) |
10526 | 5269 return; |
5270 | |
5271 loader = smiley->loader; | |
5272 | |
10537 | 5273 if (!loader) |
10526 | 5274 return; |
10537 | 5275 |
12335 | 5276 |
11525 | 5277 |
10526 | 5278 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
5279 | |
5280 gdk_pixbuf_loader_close(loader, NULL); | |
12335 | 5281 |
10526 | 5282 } |
5283 | |
11581 | 5284 /* |
5285 * Makes sure all the menu items and all the buttons are hidden/shown and | |
5286 * sensitive/insensitive. This is called after changing tabs and when an | |
5287 * account signs on or off. | |
5288 */ | |
5289 static void | |
5290 gray_stuff_out(GaimGtkConversation *gtkconv) | |
5291 { | |
5292 GaimGtkWindow *win; | |
5293 GaimConversation *conv = gtkconv->active_conv; | |
5294 GaimConnection *gc; | |
5295 GaimPluginProtocolInfo *prpl_info = NULL; | |
5296 GdkPixbuf *window_icon = NULL; | |
5297 GtkIMHtmlButtons buttons; | |
5298 GaimAccount *account; | |
5299 | |
5300 win = gaim_gtkconv_get_window(gtkconv); | |
5301 gc = gaim_conversation_get_gc(conv); | |
5302 account = gaim_conversation_get_account(conv); | |
5303 | |
5304 if (gc != NULL) | |
5305 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
5306 | |
11594 | 5307 if (win->menu.send_to != NULL) |
11734 | 5308 update_send_to_selection(win); |
11581 | 5309 |
5310 /* | |
5311 * Handle hiding and showing stuff based on what type of conv this is. | |
5312 * Stuff that Gaim IMs support in general should be shown for IM | |
5313 * conversations. Stuff that Gaim chats support in general should be | |
5314 * shown for chat conversations. It doesn't matter whether the PRPL | |
5315 * supports it or not--that only affects if the button or menu item | |
5316 * is sensitive or not. | |
5317 */ | |
5318 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
5319 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
5320 | |
5321 /* Deal with menu items */ | |
5322 gtk_widget_show(win->menu.view_log); | |
5323 gtk_widget_show(win->menu.send_file); | |
5324 gtk_widget_show(win->menu.add_pounce); | |
5325 gtk_widget_show(win->menu.get_info); | |
5326 gtk_widget_hide(win->menu.invite); | |
5327 gtk_widget_show(win->menu.alias); | |
5328 gtk_widget_show(win->menu.block); | |
5329 | |
5330 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
5331 gtk_widget_show(win->menu.add); | |
5332 gtk_widget_hide(win->menu.remove); | |
5333 } else { | |
5334 gtk_widget_show(win->menu.remove); | |
5335 gtk_widget_hide(win->menu.add); | |
5336 } | |
5337 | |
5338 gtk_widget_show(win->menu.insert_link); | |
5339 gtk_widget_show(win->menu.insert_image); | |
5340 gtk_widget_show(win->menu.show_icon); | |
5341 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
5342 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
5343 | |
5344 /* Deal with menu items */ | |
5345 gtk_widget_show(win->menu.view_log); | |
5346 gtk_widget_hide(win->menu.send_file); | |
5347 gtk_widget_hide(win->menu.add_pounce); | |
5348 gtk_widget_hide(win->menu.get_info); | |
5349 gtk_widget_show(win->menu.invite); | |
5350 gtk_widget_show(win->menu.alias); | |
5351 gtk_widget_hide(win->menu.block); | |
5352 gtk_widget_hide(win->menu.show_icon); | |
5353 | |
5354 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
5355 /* If the chat is NOT in the buddy list */ | |
5356 gtk_widget_show(win->menu.add); | |
5357 gtk_widget_hide(win->menu.remove); | |
5358 } else { | |
5359 /* If the chat IS in the buddy list */ | |
5360 gtk_widget_hide(win->menu.add); | |
5361 gtk_widget_show(win->menu.remove); | |
5362 } | |
5363 | |
5364 gtk_widget_show(win->menu.insert_link); | |
5365 gtk_widget_hide(win->menu.insert_image); | |
5366 } | |
5367 | |
5368 /* | |
5369 * Handle graying stuff out based on whether an account is connected | |
5370 * and what features that account supports. | |
5371 */ | |
5372 if ((gc != NULL) && | |
12012 | 5373 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
5374 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
5375 { | |
11581 | 5376 /* Account is online */ |
5377 /* Deal with the toolbar */ | |
12012 | 5378 if (conv->features & GAIM_CONNECTION_HTML) |
5379 { | |
5380 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
5381 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
5382 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
5383 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
5384 { | |
5385 buttons &= ~GTK_IMHTML_GROW; | |
5386 buttons &= ~GTK_IMHTML_SHRINK; | |
5387 } | |
5388 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
5389 buttons &= ~GTK_IMHTML_LINKDESC; | |
5390 } else { | |
12216 | 5391 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
12012 | 5392 } |
12216 | 5393 |
5394 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
5395 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
5396 buttons &= ~GTK_IMHTML_IMAGE; | |
5397 | |
12012 | 5398 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); |
5399 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 5400 |
5401 /* Deal with menu items */ | |
12012 | 5402 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5403 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5404 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
5405 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
5406 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
5407 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 5408 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 5409 |
5410 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
5411 { | |
5412 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
5413 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
5414 gtk_widget_set_sensitive(win->menu.send_file, | |
5415 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
5416 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
5417 gtk_widget_set_sensitive(win->menu.alias, | |
5418 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
5419 } | |
5420 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5421 { | |
5422 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
5423 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
5424 gtk_widget_set_sensitive(win->menu.alias, | |
5425 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
5426 } | |
11581 | 5427 |
5428 /* Deal with chat userlist buttons */ | |
12012 | 5429 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5430 { | |
5431 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
5432 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
5433 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
5434 } | |
5435 } else { | |
11581 | 5436 /* Account is offline */ |
5437 /* Or it's a chat that we've left. */ | |
5438 | |
5439 /* Then deal with menu items */ | |
12012 | 5440 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5441 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
5442 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5443 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
5444 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
5445 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
5446 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
5447 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
5448 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
5449 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
5450 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 5451 |
5452 /* Deal with chat userlist buttons */ | |
12012 | 5453 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5454 { | |
5455 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5456 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5457 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5458 } | |
5459 } | |
11581 | 5460 |
5461 /* | |
5462 * Update the window's icon | |
5463 */ | |
12171 | 5464 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5465 { |
12171 | 5466 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
5467 (gtkconv->u.im->anim)) | |
5468 { | |
5469 window_icon = | |
5470 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5471 g_object_ref(window_icon); | |
5472 } else { | |
5473 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5474 } | |
5475 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5476 if (window_icon != NULL) | |
5477 g_object_unref(G_OBJECT(window_icon)); | |
5478 } | |
11581 | 5479 } |
5480 | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5481 static void |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5482 gaim_gtkconv_update_fields(GaimConversation *conv, GaimGtkConvFields fields) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5483 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5484 GaimGtkConversation *gtkconv; |
11581 | 5485 GaimGtkWindow *win; |
10116 | 5486 |
4359 | 5487 gtkconv = GAIM_GTK_CONVERSATION(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5488 if (!gtkconv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5489 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5490 win = gaim_gtkconv_get_window(gtkconv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5491 if (!win) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5492 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5493 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5494 if (fields & GAIM_GTKCONV_SET_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5495 { |
4359 | 5496 gaim_conversation_autoset_title(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5497 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5498 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5499 if (fields & GAIM_GTKCONV_BUDDY_ICON) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5500 { |
11338 | 5501 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5502 gaim_gtkconv_update_buddy_icon(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5503 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5504 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5505 if (fields & GAIM_GTKCONV_MENU) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5506 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5507 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5508 generate_send_to_items(win); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5509 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5510 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5511 if (fields & GAIM_GTKCONV_TAB_ICON) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5512 { |
6395 | 5513 update_tab_icon(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5514 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
|
5515 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5516 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5517 if ((fields & GAIM_GTKCONV_TOPIC) && |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5518 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5519 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5520 const char *topic; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5521 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5522 GaimGtkChatPane *gtkchat = gtkconv->u.chat; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5523 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5524 topic = gaim_conv_chat_get_topic(chat); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5525 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5526 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5527 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5528 topic ? topic : "", NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5529 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5530 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5531 if (fields & GAIM_GTKCONV_SMILEY_THEME) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5532 gaim_gtkthemes_smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml); |
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 if ((fields & GAIM_GTKCONV_COLORIZE_TITLE) || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5535 (fields & GAIM_GTKCONV_SET_TITLE)) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5536 { |
9472 | 5537 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5538 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5539 GaimAccount *account = gaim_conversation_get_account(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5540 /* 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
|
5541 char style[51]; |
4736 | 5542 |
11338 | 5543 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5544 im = GAIM_CONV_IM(conv); |
4359 | 5545 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5546 if (!gaim_account_is_connected(account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5547 || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5548 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5549 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5550 else | |
5551 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5552 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5553 *style = '\0'; |
4359 | 5554 |
5555 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5556 gtk_widget_realize(gtkconv->tab_label); | |
5557 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5558 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5559 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5560 { |
11759 | 5561 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5562 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5563 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5564 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5565 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5566 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5567 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5568 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5569 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5570 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5571 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5572 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5573 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5574 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5575 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5576 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5577 { |
11758 | 5578 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5579 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5580 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5581 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5582 { |
8536 | 5583 char *html_title,*label; |
5584 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5585 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5586 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5587 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5588 style, html_title); |
8536 | 5589 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5590 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5591 g_free(label); |
4359 | 5592 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5593 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5594 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5595 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5596 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5597 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5598 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5599 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5600 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5601 gtk_window_set_title(GTK_WINDOW(win->window), title); |
9472 | 5602 |
5603 g_free(title); | |
4359 | 5604 } |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5605 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5606 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5607 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5608 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5609 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5610 GaimGtkConvFields flags = 0; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5611 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5612 g_return_if_fail(conv != NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5613 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5614 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5615 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5616 flags = GAIM_GTKCONV_ALL; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5617 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5618 else if (type == GAIM_CONV_UPDATE_TYPING || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5619 type == GAIM_CONV_UPDATE_UNSEEN || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5620 type == GAIM_CONV_UPDATE_TITLE) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5621 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5622 flags = GAIM_GTKCONV_COLORIZE_TITLE; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5623 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5624 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5625 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5626 flags = GAIM_GTKCONV_TOPIC; |
4359 | 5627 } |
5628 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5629 type == GAIM_CONV_ACCOUNT_OFFLINE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5630 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5631 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
|
5632 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5633 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5634 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5635 flags = GAIM_GTKCONV_TAB_ICON; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5636 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5637 else if (type == GAIM_CONV_UPDATE_ADD || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5638 type == GAIM_CONV_UPDATE_REMOVE || |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5639 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5640 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5641 flags = GAIM_GTKCONV_SET_TITLE | GAIM_GTKCONV_MENU; |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5642 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5643 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5644 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5645 flags = GAIM_GTKCONV_BUDDY_ICON; |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5646 } |
10665 | 5647 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5648 { | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5649 flags = GAIM_GTKCONV_MENU; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5650 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5651 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5652 gaim_gtkconv_update_fields(conv, flags); |
4359 | 5653 } |
5654 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5655 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5656 { |
11581 | 5657 gaim_gtkconv_new, |
4359 | 5658 gaim_gtkconv_destroy, /* destroy_conversation */ |
5659 gaim_gtkconv_write_chat, /* write_chat */ | |
5660 gaim_gtkconv_write_im, /* write_im */ | |
5661 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5662 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5663 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5664 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5665 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12618
diff
changeset
|
5666 gaim_gtkconv_present_conversation, /* present */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5667 gaim_gtkconv_has_focus, /* has_focus */ |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12618
diff
changeset
|
5668 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
10526 | 5669 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5670 gaim_gtkconv_custom_smiley_close /* custom_smiley_close */ |
4359 | 5671 }; |
5672 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5673 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5674 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5675 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5676 return &conversation_ui_ops; |
4359 | 5677 } |
5678 | |
5679 /************************************************************************** | |
5680 * Public conversation utility functions | |
5681 **************************************************************************/ | |
5682 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5683 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5684 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5685 GaimGtkConversation *gtkconv; |
11581 | 5686 GaimGtkWindow *win; |
4359 | 5687 |
10381 | 5688 GdkPixbufLoader *loader; |
5689 GdkPixbufAnimation *anim; | |
4359 | 5690 GError *err = NULL; |
5691 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5692 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5693 size_t len; |
4359 | 5694 |
5695 GdkPixbuf *buf; | |
5696 | |
5697 GtkWidget *event; | |
5698 GtkWidget *frame; | |
5699 GdkPixbuf *scale; | |
5700 GdkPixmap *pm; | |
5701 GdkBitmap *bm; | |
9318 | 5702 int scale_width, scale_height; |
5703 | |
5704 GaimAccount *account; | |
5705 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5706 |
9324 | 5707 GaimBuddyIcon *icon; |
5708 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5709 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5710 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5711 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5712 |
5713 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5714 win = gtkconv->win; |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5715 if (conv != gtkconv->active_conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5716 return; |
10175 | 5717 |
9687 | 5718 if (!gtkconv->u.im->show_icon) |
5719 return; | |
5720 | |
9318 | 5721 account = gaim_conversation_get_account(conv); |
5722 if(account && account->gc) | |
5723 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5724 |
9845 | 5725 /* Remove the current icon stuff */ |
9885 | 5726 if (gtkconv->u.im->icon_container != NULL) |
5727 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5728 gtkconv->u.im->icon_container = NULL; | |
9845 | 5729 |
5730 if (gtkconv->u.im->anim != NULL) | |
5731 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5732 | |
9887 | 5733 gtkconv->u.im->anim = NULL; |
5734 | |
9845 | 5735 if (gtkconv->u.im->icon_timer != 0) |
5736 g_source_remove(gtkconv->u.im->icon_timer); | |
5737 | |
5738 gtkconv->u.im->icon_timer = 0; | |
5739 | |
5740 if (gtkconv->u.im->iter != NULL) | |
5741 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5742 |
10116 | 5743 gtkconv->u.im->iter = NULL; |
5744 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5745 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5746 return; |
5747 | |
5748 if (gaim_conversation_get_gc(conv) == NULL) | |
5749 return; | |
5750 | |
9324 | 5751 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5752 | |
5753 if (icon == NULL) | |
5754 return; | |
5755 | |
5756 data = gaim_buddy_icon_get_data(icon, &len); | |
5757 | |
10381 | 5758 loader = gdk_pixbuf_loader_new(); |
5759 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
12601
e63fb8e9f4ac
[gaim-migrate @ 14935]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
5760 gdk_pixbuf_loader_close(loader, &err); |
10381 | 5761 anim = gdk_pixbuf_loader_get_animation(loader); |
5762 if (anim) | |
5763 g_object_ref(G_OBJECT(anim)); | |
5764 g_object_unref(loader); | |
5765 | |
5766 if (!anim) | |
9324 | 5767 return; |
10381 | 5768 gtkconv->u.im->anim = anim; |
9324 | 5769 |
4359 | 5770 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5771 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5772 "Buddy icon error: %s\n", err->message); |
4359 | 5773 g_error_free(err); |
5774 } | |
5775 | |
5776 if (!gtkconv->u.im->anim) | |
5777 return; | |
5778 | |
5779 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5780 gtkconv->u.im->iter = NULL; | |
5781 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5782 } else { | |
5783 gtkconv->u.im->iter = | |
8496 | 5784 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5785 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5786 if (gtkconv->u.im->animate) |
10810 | 5787 start_anim(NULL, gtkconv); |
4359 | 5788 } |
5789 | |
10483 | 5790 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5791 NULL, &scale_width, &scale_height); |
4359 | 5792 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5793 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5794 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5795 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5796 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5797 GDK_INTERP_BILINEAR); |
4359 | 5798 |
5799 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5800 g_object_unref(G_OBJECT(scale)); |
4359 | 5801 |
8821 | 5802 |
9885 | 5803 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5804 |
4359 | 5805 frame = gtk_frame_new(NULL); |
5806 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5807 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5808 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5809 FALSE, FALSE, 0); | |
8821 | 5810 |
4359 | 5811 event = gtk_event_box_new(); |
5812 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5813 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5814 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5815 gtk_widget_show(event); |
5816 | |
4635 | 5817 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5818 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5819 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5820 gtk_widget_show(gtkconv->u.im->icon); | |
5821 | |
4793 | 5822 g_object_unref(G_OBJECT(pm)); |
4359 | 5823 |
5824 if (bm) | |
4793 | 5825 g_object_unref(G_OBJECT(bm)); |
7143 | 5826 |
10356 | 5827 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5828 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5829 |
9885 | 5830 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5831 gtk_widget_show(frame); |
5832 | |
7143 | 5833 /* The buddy icon code needs badly to be fixed. */ |
5834 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
|
5835 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5836 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
4359 | 5837 } |
5838 | |
5839 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5840 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5841 { |
11581 | 5842 GaimGtkWindow *win; |
4359 | 5843 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5844 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5845 return; |
5846 | |
11581 | 5847 win = GAIM_GTK_CONVERSATION(conv)->win; |
5848 | |
5849 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5850 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5851 } |
5852 | |
5853 int | |
11614 | 5854 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5855 { |
4359 | 5856 gint nb_x, nb_y, x_rel, y_rel; |
5857 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5858 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5859 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5860 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5861 gboolean horiz; |
4359 | 5862 |
11614 | 5863 if (to_right) |
5864 *to_right = FALSE; | |
5865 | |
11581 | 5866 notebook = GTK_NOTEBOOK(win->notebook); |
5867 | |
5868 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5869 x_rel = x - nb_x; |
5870 y_rel = y - nb_y; | |
5871 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5872 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5873 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5874 |
11780 | 5875 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5876 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5877 #else |
5878 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5879 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5880 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5881 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5882 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5883 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5884 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5885 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5886 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5887 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5888 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5889 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
|
5890 page_num = i; |
11614 | 5891 |
5892 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5893 *to_right = TRUE; | |
5894 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5895 break; |
4359 | 5896 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5897 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5898 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5899 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
|
5900 page_num = i; |
11614 | 5901 |
5902 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5903 *to_right = TRUE; | |
5904 | |
4359 | 5905 break; |
5906 } | |
5907 } | |
5908 } | |
5909 | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5910 if (page_num == -1) { |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5911 /* Add after the last tab */ |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5912 page_num = count - 1; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5913 } |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5914 |
4359 | 5915 return page_num; |
5916 } | |
5917 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5918 static void |
12816 | 5919 close_on_tabs_pref_cb(const char *name, GaimPrefType type, |
5920 gconstpointer value, gpointer data) | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5921 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5922 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5923 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5924 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5925 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5926 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5927 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5928 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5929 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5930 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5931 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5932 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5933 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5934 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5935 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5936 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5937 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5938 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5939 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5940 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5941 static void |
12816 | 5942 spellcheck_pref_cb(const char *name, GaimPrefType type, |
5943 gconstpointer value, gpointer data) | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5944 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5945 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5946 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5947 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5948 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5949 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5950 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5951 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5952 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5953 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5954 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5955 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5956 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5957 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5958 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5959 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5960 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5961 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5962 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5963 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5964 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5965 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5966 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5967 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5968 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5969 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5970 static void |
12816 | 5971 tab_side_pref_cb(const char *name, GaimPrefType type, |
5972 gconstpointer value, gpointer data) | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5973 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5974 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5975 GtkPositionType pos; |
11581 | 5976 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5977 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5978 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5979 |
11581 | 5980 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5981 win = l->data; | |
5982 | |
11619 | 5983 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
|
5984 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5985 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5986 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5987 static void |
12188 | 5988 show_timestamps_pref_cb(const char *name, GaimPrefType type, |
12816 | 5989 gconstpointer value, gpointer data) |
12188 | 5990 { |
5991 GList *l; | |
5992 GaimConversation *conv; | |
5993 GaimGtkConversation *gtkconv; | |
5994 GaimGtkWindow *win; | |
5995 | |
5996 for (l = gaim_get_conversations(); l != NULL; l = l->next) | |
5997 { | |
5998 conv = (GaimConversation *)l->data; | |
5999 | |
6000 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
6001 continue; | |
6002 | |
6003 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6004 win = gtkconv->win; | |
6005 | |
6006 gtk_check_menu_item_set_active( | |
6007 GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
6008 (gboolean)GPOINTER_TO_INT(value)); | |
6009 | |
6010 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
6011 (gboolean)GPOINTER_TO_INT(value)); | |
6012 } | |
6013 } | |
6014 | |
6015 static void | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6016 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
12816 | 6017 gconstpointer value, gpointer data) |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6018 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6019 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6020 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6021 GaimGtkConversation *gtkconv; |
11581 | 6022 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6023 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6024 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6025 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6026 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6027 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6028 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6029 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6030 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6031 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 6032 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6033 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6034 gtk_check_menu_item_set_active( |
11581 | 6035 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
6036 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 6037 |
6038 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 6039 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6040 else |
8317 | 6041 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6042 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6043 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6044 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6045 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6046 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
12816 | 6047 gconstpointer value, gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6048 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6049 GList *l; |
8189 | 6050 GaimConversation *conv; |
6051 GaimGtkConversation *gtkconv; | |
11581 | 6052 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6053 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6054 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
|
6055 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6056 |
8189 | 6057 /* Set the "animate" flag for each icon based on the new preference */ |
6058 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
6059 conv = (GaimConversation *)l->data; | |
6060 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 6061 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6062 } |
8189 | 6063 |
6064 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 6065 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
6066 win = l->data; | |
6067 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 6068 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6069 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6070 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6071 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6072 static void |
12816 | 6073 show_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
6074 gconstpointer value, gpointer data) | |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6075 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6076 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6077 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6078 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6079 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6080 |
11338 | 6081 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 6082 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6083 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6084 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6085 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
6086 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6087 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
12816 | 6088 gconstpointer value, gpointer data) |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6089 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6090 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6091 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6092 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6093 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6094 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6095 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6096 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6097 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6098 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6099 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6100 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6101 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
|
6102 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6103 |
12310 | 6104 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
|
6105 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6106 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6107 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6108 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6109 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6110 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6111 |
12310 | 6112 if(!gaim_status_is_available( |
6113 gaim_account_get_active_status( | |
6114 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6115 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6116 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6117 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6118 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6119 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6120 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6121 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6122 static void |
12816 | 6123 hide_new_pref_cb(const char *name, GaimPrefType type, |
6124 gconstpointer value, gpointer data) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6125 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6126 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6127 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6128 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6129 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6130 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6131 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6132 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6133 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6134 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
|
6135 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6136 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6137 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
|
6138 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6139 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6140 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6141 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6142 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6143 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6144 |
12310 | 6145 if(when_away && !gaim_status_is_available( |
6146 gaim_account_get_active_status( | |
6147 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6148 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6149 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6150 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6151 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6152 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6153 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6154 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6155 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6156 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6157 conv_placement_pref_cb(const char *name, GaimPrefType type, |
12816 | 6158 gconstpointer value, gpointer data) |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6159 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6160 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6161 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6162 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6163 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6164 |
11581 | 6165 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6166 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6167 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6168 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6169 |
11581 | 6170 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6171 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6172 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6173 static GaimGtkConversation * |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6174 get_gtkconv_with_contact(GaimContact *contact) |
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 GaimBlistNode *node; |
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 node = ((GaimBlistNode*)contact)->child; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6179 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6180 for (; node; node = node->next) |
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 GaimBuddy *buddy = (GaimBuddy*)node; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6183 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6184 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
|
6185 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6186 return GAIM_GTK_CONVERSATION(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 return NULL; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6189 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6190 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6191 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6192 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6193 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6194 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6195 GaimAccount *account; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6196 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6197 account = gaim_connection_get_account(gc); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6198 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6199 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6200 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6201 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6202 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6203 /* 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
|
6204 * case of this account matching one of the other buddies in |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6205 * one of the contacts containing the buddy corresponding to |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6206 * a conversation. It's easier to just update them all. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6207 /* if (gaim_conversation_get_account(conv) == account) */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6208 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON | |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6209 GAIM_GTKCONV_MENU | GAIM_GTKCONV_COLORIZE_TITLE); |
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 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6212 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6213 static gboolean |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6214 update_buddy_status_timeout(GaimBuddy *buddy) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6215 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6216 /* To remove the signing-on/off door icon */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6217 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6218 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6219 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
|
6220 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6221 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6222 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6223 return FALSE; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6224 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6225 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6226 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6227 update_buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *newstatus) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6228 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6229 GaimGtkConversation *gtkconv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6230 GaimConversation *conv; |
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 gtkconv = get_gtkconv_with_contact(gaim_buddy_get_contact(buddy)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6233 if (gtkconv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6234 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6235 conv = gtkconv->active_conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6236 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
|
6237 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
|
6238 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_MENU); |
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 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6241 /* 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
|
6242 g_timeout_add(11000, (GSourceFunc)update_buddy_status_timeout, buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6243 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6244 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6245 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6246 update_buddy_idle_changed(GaimBuddy *buddy, gboolean old, gboolean newidle) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6247 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6248 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6249 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6250 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
|
6251 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6252 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6253 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6254 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6255 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6256 update_buddy_icon(GaimBuddy *buddy) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6257 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6258 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6259 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6260 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
|
6261 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6262 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_BUDDY_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6263 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6264 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6265 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6266 update_buddy_sign(GaimBuddy *buddy, const char *which) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6267 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6268 GaimPresence *presence; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6269 GaimStatus *on, *off; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6270 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6271 presence = gaim_buddy_get_presence(buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6272 if (!presence) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6273 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6274 off = gaim_presence_get_status(presence, "offline"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6275 on = gaim_presence_get_status(presence, "available"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6276 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6277 if (*(which+1) == 'f') |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6278 update_buddy_status_changed(buddy, on, off); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6279 else |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6280 update_buddy_status_changed(buddy, off, on); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6281 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6282 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6283 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6284 update_conversation_switched(GaimConversation *conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6285 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6286 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
|
6287 GAIM_GTKCONV_MENU | GAIM_GTKCONV_BUDDY_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6288 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6289 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6290 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6291 update_buddy_typing(GaimAccount *account, const char *who) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6292 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6293 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6294 GaimGtkConversation *gtkconv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6295 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6296 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
|
6297 if (!conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6298 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6299 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6300 gtkconv = GAIM_GTK_CONVERSATION(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6301 if (gtkconv && gtkconv->active_conv == conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6302 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_COLORIZE_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6303 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6304 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6305 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6306 update_chat(GaimConversation *conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6307 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6308 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TOPIC | |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6309 GAIM_GTKCONV_MENU | GAIM_GTKCONV_SET_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6310 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6311 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6312 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6313 update_chat_topic(GaimConversation *conv, const char *old, const char *new) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6314 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6315 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TOPIC); |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6316 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6317 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6318 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6319 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6320 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6321 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6322 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6323 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6324 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6325 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6326 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
6327 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6328 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6329 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6330 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6331 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6332 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6333 gaim_prefs_add_none("/gaim/gtk/conversations"); |
12553 | 6334 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
|
6335 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6336 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6337 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6338 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6339 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
6340 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
6341 |
12264 | 6342 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6343 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 6344 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 6345 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6346 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 6347 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 6348 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
6349 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6350 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6351 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6352 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6353 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
|
6354 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6355 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6356 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6357 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6358 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6359 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6360 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6361 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6362 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6363 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 6364 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6365 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 6366 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6367 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6368 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6369 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 6370 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
|
6371 |
12616
eee2042ad4f4
[gaim-migrate @ 14952]
Richard Laager <rlaager@wiktel.com>
parents:
12604
diff
changeset
|
6372 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
|
6373 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6374 /* Connect callbacks. */ |
10087 | 6375 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
|
6376 close_on_tabs_pref_cb, NULL); |
12188 | 6377 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
6378 show_timestamps_pref_cb, NULL); | |
10087 | 6379 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
|
6380 show_formatting_toolbar_pref_cb, NULL); |
10087 | 6381 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6382 spellcheck_pref_cb, NULL); |
10087 | 6383 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6384 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6385 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6386 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6387 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6388 |
10087 | 6389 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6390 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6391 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6392 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6393 /* IM callbacks */ |
10087 | 6394 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
|
6395 animate_buddy_icons_pref_cb, NULL); |
10087 | 6396 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
|
6397 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6398 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6399 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6400 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6401 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6402 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6403 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6404 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6405 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
6406 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6407 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
12837
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6408 gaim_value_new(GAIM_TYPE_BOXED, |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6409 "GaimGtkWindow *"), |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6410 gaim_value_new(GAIM_TYPE_BOXED, |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6411 "GaimGtkWindow *")); |
9167 | 6412 |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6413 gaim_signal_register(handle, "conversation-timestamp", |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6414 gaim_marshal_POINTER__POINTER_POINTER, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6415 gaim_value_new(GAIM_TYPE_POINTER), 2, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6416 gaim_value_new(GAIM_TYPE_SUBTYPE, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6417 GAIM_SUBTYPE_CONVERSATION), |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6418 gaim_value_new(GAIM_TYPE_POINTER)); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6419 |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6420 gaim_signal_register(handle, "displaying-im-msg", |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6421 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6422 gaim_value_new(GAIM_TYPE_BOOLEAN), 4, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6423 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6424 GAIM_SUBTYPE_ACCOUNT), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6425 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6426 GAIM_SUBTYPE_CONVERSATION), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6427 gaim_value_new_outgoing(GAIM_TYPE_STRING), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6428 gaim_value_new(G_TYPE_INT)); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6429 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6430 gaim_signal_register(handle, "displayed-im-msg", |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6431 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6432 NULL, 4, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6433 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6434 GAIM_SUBTYPE_ACCOUNT), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6435 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6436 GAIM_SUBTYPE_CONVERSATION), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6437 gaim_value_new(GAIM_TYPE_STRING), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6438 gaim_value_new(G_TYPE_INT)); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6439 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6440 gaim_signal_register(handle, "displaying-chat-msg", |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6441 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6442 gaim_value_new(GAIM_TYPE_BOOLEAN), 4, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6443 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6444 GAIM_SUBTYPE_ACCOUNT), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6445 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6446 GAIM_SUBTYPE_CONVERSATION), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6447 gaim_value_new_outgoing(GAIM_TYPE_STRING), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6448 gaim_value_new(G_TYPE_INT)); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6449 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6450 gaim_signal_register(handle, "displayed-chat-msg", |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6451 gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6452 NULL, 4, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6453 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6454 GAIM_SUBTYPE_ACCOUNT), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6455 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6456 GAIM_SUBTYPE_CONVERSATION), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6457 gaim_value_new(GAIM_TYPE_STRING), |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6458 gaim_value_new(G_TYPE_INT)); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6459 |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6460 gaim_signal_register(handle, "conversation-switched", |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6461 gaim_marshal_VOID__POINTER_POINTER, NULL, 1, |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6462 gaim_value_new(GAIM_TYPE_SUBTYPE, |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6463 GAIM_SUBTYPE_CONVERSATION)); |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6464 |
9167 | 6465 /********************************************************************** |
6466 * Register commands | |
6467 **********************************************************************/ | |
9829 | 6468 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
6469 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
6470 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 6471 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
6472 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6473 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 6474 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
6475 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6476 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
|
6477 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6478 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6479 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 6480 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 6481 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
6482 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 6483 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6484 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6485 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6486 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6487 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6488 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6489 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6490 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6491 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6492 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6493 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6494 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6495 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6496 handle, G_CALLBACK(received_im_msg_cb), NULL); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6497 |
11581 | 6498 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6499 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6500 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6501 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6502 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6503 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6504 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6505 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6506 /* Callbacks to update a conversation */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6507 gaim_signal_connect(blist_handle, "buddy-added", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6508 G_CALLBACK(buddy_update_cb), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6509 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6510 G_CALLBACK(buddy_update_cb), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6511 gaim_signal_connect(blist_handle, "buddy-signed-on", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6512 handle, GAIM_CALLBACK(update_buddy_sign), "on"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6513 gaim_signal_connect(blist_handle, "buddy-signed-off", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6514 handle, GAIM_CALLBACK(update_buddy_sign), "off"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6515 gaim_signal_connect(blist_handle, "buddy-status-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6516 handle, GAIM_CALLBACK(update_buddy_status_changed), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6517 gaim_signal_connect(blist_handle, "buddy-idle-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6518 handle, GAIM_CALLBACK(update_buddy_idle_changed), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6519 gaim_signal_connect(blist_handle, "buddy-icon-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6520 handle, GAIM_CALLBACK(update_buddy_icon), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6521 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6522 handle, GAIM_CALLBACK(update_buddy_typing), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6523 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing-stopped", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6524 handle, GAIM_CALLBACK(update_buddy_typing), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6525 gaim_signal_connect(gaim_gtk_conversations_get_handle(), "conversation-switched", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6526 handle, GAIM_CALLBACK(update_conversation_switched), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6527 gaim_signal_connect(gaim_conversations_get_handle(), "chat-left", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6528 GAIM_CALLBACK(update_chat), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6529 gaim_signal_connect(gaim_conversations_get_handle(), "chat-joined", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6530 GAIM_CALLBACK(update_chat), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6531 gaim_signal_connect(gaim_conversations_get_handle(), "chat-topic-changed", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6532 GAIM_CALLBACK(update_chat_topic), NULL); |
12806
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6533 gaim_signal_connect_priority(gaim_conversations_get_handle(), "conversation-updated", handle, |
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6534 GAIM_CALLBACK(gaim_gtkconv_updated), NULL, |
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6535 GAIM_SIGNAL_PRIORITY_LOWEST); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6536 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6537 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6538 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6539 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6540 { |
10443 | 6541 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 6542 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6543 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6544 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6545 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6546 } |
11581 | 6547 |
6548 | |
6549 | |
6550 | |
6551 | |
6552 | |
6553 | |
6554 | |
6555 | |
6556 | |
6557 | |
6558 | |
6559 | |
6560 | |
6561 | |
6562 | |
6563 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
6564 * and touch each others' private members all day long */ | |
6565 | |
6566 /** | |
6567 * @file gtkconvwin.c GTK+ Conversation Window API | |
6568 * @ingroup gtkui | |
6569 * | |
6570 * gaim | |
6571 * | |
6572 * Gaim is the legal property of its developers, whose names are too numerous | |
6573 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6574 * source distribution. | |
6575 * | |
6576 * This program is free software; you can redistribute it and/or modify | |
6577 * it under the terms of the GNU General Public License as published by | |
6578 * the Free Software Foundation; either version 2 of the License, or | |
6579 * (at your option) any later version. | |
6580 * | |
6581 * This program is distributed in the hope that it will be useful, | |
6582 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
6583 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
6584 * GNU General Public License for more details. | |
6585 * | |
6586 * You should have received a copy of the GNU General Public License | |
6587 * along with this program; if not, write to the Free Software | |
6588 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
6589 * | |
6590 */ | |
6591 #include "internal.h" | |
6592 #include "gtkgaim.h" | |
6593 | |
6594 | |
6595 #include <gdk/gdkkeysyms.h> | |
6596 | |
6597 #include "account.h" | |
6598 #include "cmds.h" | |
6599 #include "debug.h" | |
6600 #include "imgstore.h" | |
6601 #include "log.h" | |
6602 #include "notify.h" | |
6603 #include "prpl.h" | |
6604 #include "request.h" | |
6605 #include "util.h" | |
6606 | |
6607 #include "gtkdnd-hints.h" | |
6608 #include "gtkblist.h" | |
6609 #include "gtkconv.h" | |
6610 #include "gtkdialogs.h" | |
6611 #include "gtkmenutray.h" | |
6612 #include "gtkpounce.h" | |
6613 #include "gtkprefs.h" | |
6614 #include "gtkprivacy.h" | |
6615 #include "gtkutils.h" | |
6616 #include "gtkstock.h" | |
6617 #include "gtkimhtml.h" | |
6618 #include "gtkimhtmltoolbar.h" | |
6619 | |
6620 static void | |
6621 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
6622 { | |
6623 gtk_widget_destroy(warn_close_dialog); | |
6624 warn_close_dialog = NULL; | |
6625 | |
6626 if (resp == GTK_RESPONSE_OK) | |
6627 gaim_gtk_conv_window_destroy(win); | |
6628 } | |
6629 | |
6630 static void | |
6631 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
6632 { | |
6633 GtkWidget *label; | |
6634 GtkWidget *vbox, *hbox; | |
6635 GtkWidget *img; | |
6636 | |
6637 g_return_if_fail(warn_close_dialog == NULL); | |
6638 | |
6639 | |
6640 warn_close_dialog = gtk_dialog_new_with_buttons( | |
12660 | 6641 _("Confirm close"), |
6642 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
6643 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
6644 GAIM_STOCK_CLOSE_TABS, GTK_RESPONSE_OK, NULL); | |
11581 | 6645 |
6646 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
6647 GTK_RESPONSE_OK); | |
6648 | |
6649 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
6650 6); | |
6651 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
6652 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
6653 FALSE); | |
6654 | |
6655 /* Setup the outside spacing. */ | |
6656 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
6657 | |
6658 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
6659 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
6660 | |
6661 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
6662 GTK_ICON_SIZE_DIALOG); | |
6663 /* Setup the inner hbox and put the dialog's icon in it. */ | |
6664 hbox = gtk_hbox_new(FALSE, 12); | |
6665 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
6666 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
6667 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
6668 | |
6669 /* Setup the right vbox. */ | |
6670 vbox = gtk_vbox_new(FALSE, 12); | |
6671 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
6672 | |
6673 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
6674 gtk_widget_set_size_request(label, 350, -1); | |
6675 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
6676 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
6677 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
6678 | |
6679 /* Connect the signals. */ | |
6680 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
6681 G_CALLBACK(do_close), gtkwin); | |
6682 | |
6683 } | |
6684 | |
6685 /************************************************************************** | |
6686 * Callbacks | |
6687 **************************************************************************/ | |
6688 | |
6689 static gboolean | |
6690 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
6691 { | |
6692 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6693 GList *l; |
11581 | 6694 |
6695 /* If there are unread messages then show a warning dialog */ | |
6696 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
6697 l != NULL; l = l->next) | |
6698 { | |
6699 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6700 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
|
6701 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6702 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6703 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6704 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6705 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6706 return TRUE; |
11581 | 6707 } |
6708 } | |
6709 | |
6710 gaim_gtk_conv_window_destroy(win); | |
6711 | |
6712 return TRUE; | |
6713 } | |
6714 | |
11604 | 6715 static void |
6716 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
6717 { | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6718 if (state == GAIM_UNSEEN_NONE) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6719 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6720 gtkconv->unseen_count = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6721 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6722 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6723 else |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6724 { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6725 if (state >= GAIM_UNSEEN_TEXT) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6726 gtkconv->unseen_count++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6727 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6728 if (state > gtkconv->unseen_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6729 gtkconv->unseen_state = state; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6730 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6731 |
12806
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6732 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
|
6733 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6734 |
11581 | 6735 /* |
6736 * When a conversation window is focused, we know the user | |
6737 * has looked at it so we know there are no longer unseen | |
6738 * messages. | |
6739 */ | |
6740 static gint | |
6741 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6742 { | |
6743 GaimGtkWindow *win = d; | |
11604 | 6744 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6745 | |
6746 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6747 |
6748 return FALSE; | |
6749 } | |
6750 | |
11851 | 6751 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6752 /* Courtesy of Galeon! */ |
6753 static void | |
6754 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6755 { | |
6756 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6757 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6758 } | |
11851 | 6759 #endif |
11581 | 6760 |
6761 static void | |
6762 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6763 { | |
6764 static GdkCursor *cursor = NULL; | |
6765 | |
6766 gtkwin->in_drag = TRUE; | |
6767 | |
6768 if (gtkwin->drag_leave_signal) { | |
6769 g_signal_handler_disconnect(G_OBJECT(widget), | |
6770 gtkwin->drag_leave_signal); | |
6771 gtkwin->drag_leave_signal = 0; | |
6772 } | |
6773 | |
6774 if (cursor == NULL) | |
6775 cursor = gdk_cursor_new(GDK_FLEUR); | |
6776 | |
6777 /* Grab the pointer */ | |
6778 gtk_grab_add(gtkwin->notebook); | |
6779 #ifndef _WIN32 | |
6780 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6781 always be true after a button press. */ | |
6782 if (!gdk_pointer_is_grabbed()) | |
6783 #endif | |
6784 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6785 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6786 NULL, cursor, GDK_CURRENT_TIME); | |
6787 } | |
6788 | |
6789 static gboolean | |
6790 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6791 { | |
6792 | |
6793 /* | |
6794 * Make sure the user moved the mouse far enough for the | |
6795 * drag to be initiated. | |
6796 */ | |
6797 if (win->in_predrag) { | |
6798 if (e->x_root < win->drag_min_x || | |
6799 e->x_root >= win->drag_max_x || | |
6800 e->y_root < win->drag_min_y || | |
6801 e->y_root >= win->drag_max_y) { | |
6802 | |
6803 win->in_predrag = FALSE; | |
6804 notebook_init_grab(win, widget); | |
6805 } | |
6806 } | |
6807 else { /* Otherwise, draw the arrows. */ | |
6808 GaimGtkWindow *dest_win; | |
6809 GtkNotebook *dest_notebook; | |
6810 GtkWidget *tab; | |
6811 gint nb_x, nb_y, page_num; | |
6812 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6813 gboolean horiz_tabs = FALSE; | |
11614 | 6814 GaimGtkConversation *gtkconv; |
6815 gboolean to_right = FALSE; | |
11581 | 6816 |
6817 /* Get the window that the cursor is over. */ | |
6818 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6819 | |
6820 if (dest_win == NULL) { | |
6821 dnd_hints_hide_all(); | |
6822 | |
6823 return TRUE; | |
6824 } | |
6825 | |
6826 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6827 | |
6828 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6829 | |
6830 arrow1_x = arrow2_x = nb_x; | |
6831 arrow1_y = arrow2_y = nb_y; | |
6832 | |
6833 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6834 e->x_root, e->y_root, &to_right); |
6835 to_right = to_right && (win != dest_win); | |
11581 | 6836 |
6837 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6838 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6839 | |
6840 horiz_tabs = TRUE; | |
6841 } | |
6842 | |
11614 | 6843 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6844 tab = gtkconv->tabby; | |
11581 | 6845 |
6846 if (horiz_tabs) { | |
6847 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6848 | |
11614 | 6849 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6850 arrow1_x += tab->allocation.width; |
6851 arrow2_x += tab->allocation.width; | |
6852 } | |
6853 | |
6854 arrow1_y = nb_y + tab->allocation.y; | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6855 arrow2_y = nb_y + tab->allocation.y + tab->allocation.height; |
11581 | 6856 } else { |
6857 arrow1_x = nb_x + tab->allocation.x; | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6858 arrow2_x = nb_x + tab->allocation.x + tab->allocation.width; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6859 arrow1_y = arrow2_y = nb_y + tab->allocation.y; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6860 |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6861 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6862 arrow1_y += tab->allocation.height; |
6863 arrow2_y += tab->allocation.height; | |
6864 } | |
6865 } | |
6866 | |
6867 if (horiz_tabs) { | |
6868 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6869 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6870 } else { | |
6871 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6872 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6873 } | |
6874 } | |
6875 | |
6876 return TRUE; | |
6877 } | |
6878 | |
6879 static gboolean | |
6880 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6881 { | |
6882 if (win->in_drag) | |
6883 return FALSE; | |
6884 | |
6885 if (e->x_root < win->drag_min_x || | |
6886 e->x_root >= win->drag_max_x || | |
6887 e->y_root < win->drag_min_y || | |
6888 e->y_root >= win->drag_max_y) { | |
6889 | |
6890 win->in_predrag = FALSE; | |
6891 notebook_init_grab(win, widget); | |
6892 } | |
6893 | |
6894 return TRUE; | |
6895 } | |
6896 | |
6897 /* | |
6898 * THANK YOU GALEON! | |
6899 */ | |
6900 static gboolean | |
6901 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6902 { | |
6903 gint nb_x, nb_y, x_rel, y_rel; | |
6904 int tab_clicked; | |
6905 GtkWidget *page; | |
6906 GtkWidget *tab; | |
6907 | |
6908 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6909 return FALSE; | |
6910 | |
6911 | |
6912 if (win->in_drag) { | |
6913 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6914 "Already in the middle of a window drag at tab_press_cb\n"); | |
6915 return TRUE; | |
6916 } | |
6917 | |
6918 /* | |
6919 * Make sure a tab was actually clicked. The arrow buttons | |
6920 * mess things up. | |
6921 */ | |
11614 | 6922 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6923 |
6924 if (tab_clicked == -1) | |
6925 return FALSE; | |
6926 | |
6927 /* | |
6928 * Get the relative position of the press event, with regards to | |
6929 * the position of the notebook. | |
6930 */ | |
6931 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6932 | |
6933 x_rel = e->x_root - nb_x; | |
6934 y_rel = e->y_root - nb_y; | |
6935 | |
6936 /* Reset the min/max x/y */ | |
6937 win->drag_min_x = 0; | |
6938 win->drag_min_y = 0; | |
6939 win->drag_max_x = 0; | |
6940 win->drag_max_y = 0; | |
6941 | |
6942 /* Find out which tab was dragged. */ | |
6943 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6944 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6945 | |
6946 win->drag_min_x = tab->allocation.x + nb_x; | |
6947 win->drag_min_y = tab->allocation.y + nb_y; | |
6948 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6949 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6950 | |
6951 /* Make sure the click occurred in the tab. */ | |
6952 if (e->x_root < win->drag_min_x || | |
6953 e->x_root >= win->drag_max_x || | |
6954 e->y_root < win->drag_min_y || | |
6955 e->y_root >= win->drag_max_y) { | |
6956 | |
6957 return FALSE; | |
6958 } | |
6959 | |
6960 win->in_predrag = TRUE; | |
6961 win->drag_tab = tab_clicked; | |
6962 | |
6963 /* Connect the new motion signals. */ | |
6964 win->drag_motion_signal = | |
6965 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6966 G_CALLBACK(notebook_motion_cb), win); | |
6967 | |
6968 win->drag_leave_signal = | |
6969 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6970 G_CALLBACK(notebook_leave_cb), win); | |
6971 | |
6972 return FALSE; | |
6973 } | |
6974 | |
6975 static gboolean | |
6976 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6977 { | |
6978 GaimGtkWindow *dest_win; | |
6979 GaimConversation *conv; | |
6980 GaimGtkConversation *gtkconv; | |
6981 gint dest_page_num = 0; | |
6982 gboolean new_window = FALSE; | |
11614 | 6983 gboolean to_right = FALSE; |
11581 | 6984 |
6985 /* | |
6986 * Don't check to make sure that the event's window matches the | |
6987 * widget's, because we may be getting an event passed on from the | |
6988 * close button. | |
6989 */ | |
6990 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6991 return FALSE; | |
6992 | |
6993 if (gdk_pointer_is_grabbed()) { | |
6994 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6995 gtk_grab_remove(widget); | |
6996 } | |
6997 | |
6998 if (!win->in_predrag && !win->in_drag) | |
6999 return FALSE; | |
7000 | |
7001 /* Disconnect the motion signal. */ | |
7002 if (win->drag_motion_signal) { | |
7003 g_signal_handler_disconnect(G_OBJECT(widget), | |
7004 win->drag_motion_signal); | |
7005 | |
7006 win->drag_motion_signal = 0; | |
7007 } | |
7008 | |
7009 /* | |
7010 * If we're in a pre-drag, we'll also need to disconnect the leave | |
7011 * signal. | |
7012 */ | |
7013 if (win->in_predrag) { | |
7014 win->in_predrag = FALSE; | |
7015 | |
7016 if (win->drag_leave_signal) { | |
7017 g_signal_handler_disconnect(G_OBJECT(widget), | |
7018 win->drag_leave_signal); | |
7019 | |
7020 win->drag_leave_signal = 0; | |
7021 } | |
7022 } | |
7023 | |
7024 /* If we're not in drag... */ | |
7025 /* We're perfectly normal people! */ | |
7026 if (!win->in_drag) | |
7027 return FALSE; | |
7028 | |
7029 win->in_drag = FALSE; | |
7030 | |
7031 dnd_hints_hide_all(); | |
7032 | |
7033 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
7034 | |
7035 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
7036 | |
7037 if (dest_win == NULL) { | |
7038 /* If the current window doesn't have any other conversations, | |
7039 * there isn't much point transferring the conv to a new window. */ | |
7040 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
7041 /* Make a new window to stick this to. */ | |
7042 dest_win = gaim_gtk_conv_window_new(); | |
7043 new_window = TRUE; | |
7044 } | |
7045 } | |
7046 | |
7047 if (dest_win == NULL) | |
7048 return FALSE; | |
7049 | |
7050 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
7051 "conversation-dragging", win, dest_win); | |
7052 | |
7053 /* Get the destination page number. */ | |
7054 if (!new_window) | |
7055 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 7056 e->x_root, e->y_root, &to_right); |
11581 | 7057 |
7058 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7059 | |
7060 if (win == dest_win) { | |
7061 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
7062 } else { | |
7063 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
7064 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 7065 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 7066 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
7067 if (new_window) { | |
7068 gint win_width, win_height; | |
7069 | |
7070 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
7071 &win_width, &win_height); | |
7072 | |
7073 gtk_window_move(GTK_WINDOW(dest_win->window), | |
7074 e->x_root - (win_width / 2), | |
7075 e->y_root - (win_height / 2)); | |
7076 | |
7077 gaim_gtk_conv_window_show(dest_win); | |
7078 } | |
7079 } | |
7080 | |
7081 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
7082 | |
7083 return TRUE; | |
7084 } | |
7085 | |
7086 | |
7087 static void | |
7088 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
7089 gpointer user_data) | |
7090 { | |
7091 GaimGtkWindow *win; | |
7092 GaimConversation *conv; | |
7093 GaimGtkConversation *gtkconv; | |
7094 | |
7095 win = user_data; | |
7096 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
7097 | |
7098 g_return_if_fail(conv != NULL); | |
7099 | |
7100 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
7101 return; | |
7102 | |
7103 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7104 | |
7105 stop_anim(NULL, gtkconv); | |
7106 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7107 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7108 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7109 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7110 close_win_cb(w, NULL, win); |
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 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7113 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7114 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7115 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7116 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7117 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7118 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7119 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7120 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7121 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7122 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7123 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7124 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7125 /* 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
|
7126 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7127 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7128 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7129 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7130 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7131 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7132 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7133 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7134 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7135 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7136 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7137 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7138 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7139 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7140 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7141 GaimGtkWindow *win; |
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 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7144 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7145 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7146 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7147 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7148 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7149 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7150 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7151 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7152 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7153 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7154 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7155 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7156 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7157 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7158 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7159 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7160 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7161 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7162 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7163 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7164 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7165 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7166 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7167 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7168 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7169 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7170 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7171 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7172 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7173 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7174 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7175 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7176 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7177 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7178 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7179 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7180 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7181 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
7182 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
|
7183 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7184 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7185 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7186 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7187 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7188 } |
12188 | 7189 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7190 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7191 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7192 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7193 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7194 |
12824
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7195 item = gtk_menu_item_new_with_label("Close other tabs"); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7196 gtk_widget_show(item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7197 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7198 g_signal_connect(G_OBJECT(item), "activate", |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7199 G_CALLBACK(close_others_cb), menu); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7200 |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7201 item = gtk_menu_item_new_with_label("Close all tabs"); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7202 gtk_widget_show(item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7203 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7204 g_signal_connect(G_OBJECT(item), "activate", |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7205 G_CALLBACK(close_window), win); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7206 |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7207 gaim_separator(menu); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7208 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7209 item = gtk_menu_item_new_with_label("Detach this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7210 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7211 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7212 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7213 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7214 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7215 item = gtk_menu_item_new_with_label("Close this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7216 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7217 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7218 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7219 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7220 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7221 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7222 } |
11581 | 7223 |
7224 static void | |
7225 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
7226 gpointer user_data) | |
7227 { | |
7228 GaimGtkWindow *win; | |
7229 GaimConversation *conv; | |
7230 GaimGtkConversation *gtkconv; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7231 const char *sound_method; |
11581 | 7232 |
7233 win = user_data; | |
7234 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
7235 conv = gtkconv->active_conv; | |
7236 | |
7237 g_return_if_fail(conv != NULL); | |
7238 | |
7239 /* | |
7240 * Only set "unseen" to "none" if the window has focus | |
7241 */ | |
7242 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 7243 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 7244 |
7245 /* Update the menubar */ | |
7246 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
7247 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
|
7248 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
7249 |
11594 | 7250 generate_send_to_items(win); |
7251 | |
11604 | 7252 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 7253 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7254 sound_method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7255 if (strcmp(sound_method, "none") != 0) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7256 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
|
7257 gtkconv->make_sound); |
11581 | 7258 |
7259 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
7260 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
7261 | |
7262 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
12188 | 7263 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
11581 | 7264 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7265 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM && |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7266 gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7267 { |
11581 | 7268 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
7269 gtkconv->u.im->show_icon); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7270 } |
11604 | 7271 |
11581 | 7272 /* |
7273 * We pause icons when they are not visible. If this icon should | |
7274 * be animated then start it back up again. | |
7275 */ | |
7276 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
7277 (gtkconv->u.im->animate)) | |
7278 start_anim(NULL, gtkconv); | |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
7279 |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
7280 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-switched", conv); |
11581 | 7281 } |
7282 | |
7283 /************************************************************************** | |
7284 * GTK+ window ops | |
7285 **************************************************************************/ | |
7286 | |
7287 GList * | |
7288 gaim_gtk_conv_windows_get_list() | |
7289 { | |
7290 return window_list; | |
7291 } | |
7292 | |
7293 GaimGtkWindow * | |
7294 gaim_gtk_conv_window_new() | |
7295 { | |
7296 GaimGtkWindow *win; | |
7297 GtkPositionType pos; | |
7298 GtkWidget *testidea; | |
7299 GtkWidget *menubar; | |
7300 | |
7301 win = g_malloc0(sizeof(GaimGtkWindow)); | |
7302 | |
7303 window_list = g_list_append(window_list, win); | |
7304 | |
7305 /* Create the window. */ | |
7306 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
7307 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
7308 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
7309 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
7310 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
7311 | |
7312 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
7313 G_CALLBACK(close_win_cb), win); | |
7314 | |
7315 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
7316 G_CALLBACK(focus_win_cb), win); | |
7317 | |
7318 /* Create the notebook. */ | |
7319 win->notebook = gtk_notebook_new(); | |
7320 | |
7321 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
7322 | |
7323 #if 0 | |
7324 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
7325 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
7326 #endif | |
7327 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
7328 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
7329 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
7330 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
7331 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
7332 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7333 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7334 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7335 |
11581 | 7336 gtk_widget_show(win->notebook); |
7337 | |
7338 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
7339 G_CALLBACK(before_switch_conv_cb), win); | |
7340 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
7341 G_CALLBACK(switch_conv_cb), win); | |
7342 | |
7343 /* Setup the tab drag and drop signals. */ | |
7344 gtk_widget_add_events(win->notebook, | |
7345 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
7346 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
7347 G_CALLBACK(notebook_press_cb), win); | |
7348 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
7349 G_CALLBACK(notebook_release_cb), win); | |
7350 | |
7351 testidea = gtk_vbox_new(FALSE, 0); | |
7352 | |
7353 /* Setup the menubar. */ | |
7354 menubar = setup_menubar(win); | |
7355 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
7356 | |
7357 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
7358 | |
7359 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
7360 | |
7361 gtk_widget_show(testidea); | |
7362 | |
7363 return win; | |
7364 } | |
7365 | |
7366 void | |
7367 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
7368 { | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7369 gaim_prefs_disconnect_by_handle(win); |
11581 | 7370 window_list = g_list_remove(window_list, win); |
7371 | |
11611 | 7372 if (win->gtkconvs) { |
7373 while (win->gtkconvs) { | |
7374 GList *nextgtk = win->gtkconvs->next; | |
7375 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
7376 GList *nextcore = gtkconv->convs->next; | |
7377 GaimConversation *conv = gtkconv->convs->data; | |
7378 gaim_conversation_destroy(conv); | |
7379 if (!nextgtk && !nextcore) | |
7380 /* we'll end up invoking ourselves when we destroy our last child */ | |
7381 /* so don't destroy ourselves right now */ | |
7382 return; | |
7383 } | |
7384 return; | |
7385 } | |
11581 | 7386 gtk_widget_destroy(win->window); |
7387 | |
7388 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
7389 | |
7390 g_free(win); | |
7391 } | |
7392 | |
7393 void | |
7394 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
7395 { | |
7396 gtk_widget_show(win->window); | |
7397 } | |
7398 | |
7399 void | |
7400 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
7401 { | |
7402 gtk_widget_hide(win->window); | |
7403 } | |
7404 | |
7405 void | |
7406 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
7407 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
7408 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 7409 } |
7410 | |
7411 void | |
7412 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
7413 { | |
7414 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
7415 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
7416 gtkconv->tab_cont)); | |
7417 } | |
7418 | |
7419 void | |
7420 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
7421 { | |
7422 GaimConversation *conv = gtkconv->active_conv; | |
7423 GaimGtkConversation *focus_gtkconv; | |
7424 GtkWidget *tabby, *menu_tabby; | |
7425 GtkWidget *tab_cont = gtkconv->tab_cont; | |
7426 GtkWidget *close_image; | |
7427 GaimConversationType conv_type; | |
7428 const char *name; | |
7429 const gchar *tmp_lab; | |
7430 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 7431 gboolean tabs_side = FALSE; |
7432 gint angle = 0; | |
11581 | 7433 |
7434 name = gaim_conversation_get_name(conv); | |
7435 conv_type = gaim_conversation_get_type(conv); | |
7436 | |
7437 | |
7438 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
7439 gtkconv->win = win; | |
7440 | |
11619 | 7441 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
7442 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
7443 tabs_side = TRUE; | |
7444 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
7445 angle = 90; | |
7446 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
7447 angle = 270; | |
7448 | |
7449 if (angle) | |
7450 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
7451 else | |
7452 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 7453 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
7454 | |
7455 /* Close button. */ | |
7456 gtkconv->close = gtk_button_new(); | |
7457 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
7458 if (gtk_check_version(2, 4, 2) == NULL) { | |
7459 /* Need to account for extra padding around the gtkbutton */ | |
7460 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
7461 "focus-line-width", &focus_width, | |
7462 "focus-padding", &focus_pad, | |
7463 NULL); | |
7464 close_button_width += (focus_width + focus_pad) * 2; | |
7465 close_button_height += (focus_width + focus_pad) * 2; | |
7466 } | |
7467 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
7468 close_button_width, close_button_height); | |
7469 | |
7470 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
7471 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
7472 gtk_widget_show(close_image); | |
7473 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
7474 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
7475 _("Close conversation"), NULL); | |
7476 | |
7477 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
7478 G_CALLBACK(close_conv_cb), gtkconv); | |
7479 | |
11851 | 7480 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 7481 /* |
7482 * I love Galeon. They have a fix for that stupid annoying visible | |
7483 * border bug. I love you guys! -- ChipX86 | |
7484 */ | |
11851 | 7485 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 7486 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
7487 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 7488 #endif |
11581 | 7489 |
7490 /* Status icon. */ | |
7491 gtkconv->icon = gtk_image_new(); | |
7492 gtkconv->menu_icon = gtk_image_new(); | |
7493 update_tab_icon(conv); | |
7494 | |
7495 /* Tab label. */ | |
7496 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 7497 |
11581 | 7498 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 7499 if (!angle) |
7500 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 7501 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 7502 if (tabs_side) { |
7503 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
7504 } | |
7505 if (angle) | |
7506 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 7507 #endif |
7508 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
7509 #if 0 | |
7510 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
7511 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
7512 #endif | |
7513 | |
7514 /* Pack it all together. */ | |
11619 | 7515 if (angle == 90) |
7516 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
7517 else | |
7518 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 7519 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
7520 FALSE, FALSE, 0); | |
7521 | |
7522 gtk_widget_show_all(gtkconv->icon); | |
7523 gtk_widget_show_all(gtkconv->menu_icon); | |
7524 | |
7525 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
7526 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
7527 gtk_widget_show(gtkconv->tab_label); | |
7528 gtk_widget_show(gtkconv->menu_label); | |
7529 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
7530 | |
11619 | 7531 if (angle == 90) |
7532 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
7533 else | |
7534 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 7535 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
7536 gtk_widget_show(gtkconv->close); | |
7537 | |
7538 gtk_widget_show(tabby); | |
7539 gtk_widget_show(menu_tabby); | |
7540 | |
7541 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
7542 gaim_gtkconv_update_buddy_icon(conv); | |
7543 | |
7544 /* Add this pane to the conversation's notebook. */ | |
7545 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 7546 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 7547 |
7548 | |
7549 gtk_widget_show(tab_cont); | |
7550 | |
7551 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
7552 /* Er, bug in notebooks? Switch to the page manually. */ | |
7553 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
7554 | |
7555 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7556 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7557 } else | |
7558 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
7559 | |
7560 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
7561 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
7562 gtk_widget_grab_focus(focus_gtkconv->entry); | |
7563 | |
7564 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 7565 update_send_to_selection(win); |
11581 | 7566 } |
7567 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7568 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7569 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
11581 | 7570 { |
7571 unsigned int index; | |
7572 GaimConversationType conv_type; | |
7573 | |
7574 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
7575 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
7576 | |
7577 g_object_ref(gtkconv->tab_cont); | |
7578 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
7579 | |
7580 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
7581 | |
7582 /* go back to tabless if need be */ | |
7583 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
7584 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7585 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7586 } | |
7587 | |
7588 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 7589 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7590 if (!win->gtkconvs && win != hidden_convwin) |
11582 | 7591 gaim_gtk_conv_window_destroy(win); |
11581 | 7592 } |
7593 | |
7594 GaimGtkConversation * | |
7595 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
7596 { | |
7597 GtkWidget *tab_cont; | |
7598 | |
7599 if (index == -1) | |
7600 index = 0; | |
7601 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 7602 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 7603 } |
7604 | |
7605 GaimGtkConversation * | |
7606 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
7607 { | |
7608 int index; | |
7609 GtkWidget *tab_cont; | |
7610 | |
7611 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
7612 if (index == -1) | |
7613 index = 0; | |
7614 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
7615 if (!tab_cont) | |
7616 return NULL; | |
7617 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
7618 } | |
7619 | |
7620 | |
7621 GaimConversation * | |
7622 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
7623 { | |
7624 GaimGtkConversation *gtkconv; | |
7625 | |
7626 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
7627 return gtkconv ? gtkconv->active_conv : NULL; | |
7628 } | |
7629 | |
7630 gboolean | |
7631 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
7632 { | |
7633 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
7634 } | |
7635 | |
7636 gboolean | |
7637 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
7638 { | |
7639 gboolean has_focus = FALSE; | |
7640 | |
7641 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
7642 | |
7643 return has_focus; | |
7644 } | |
7645 | |
7646 GaimGtkWindow * | |
7647 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
7648 { | |
7649 GaimGtkWindow *win; | |
7650 GdkWindow *gdkwin; | |
7651 GList *l; | |
7652 | |
7653 gdkwin = gdk_window_at_pointer(&x, &y); | |
7654 | |
7655 if (gdkwin) | |
7656 gdkwin = gdk_window_get_toplevel(gdkwin); | |
7657 | |
7658 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
7659 win = l->data; | |
7660 | |
7661 if (gdkwin == win->window->window) | |
7662 return win; | |
7663 } | |
7664 | |
7665 return NULL; | |
7666 } | |
7667 | |
7668 GList * | |
7669 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
7670 { | |
7671 return win->gtkconvs; | |
7672 } | |
7673 | |
7674 guint | |
7675 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
7676 { | |
7677 return g_list_length(win->gtkconvs); | |
7678 } | |
7679 | |
7680 GaimGtkWindow * | |
7681 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
7682 { | |
7683 GList *wins, *convs; | |
7684 GaimGtkWindow *win; | |
7685 GaimGtkConversation *conv; | |
7686 | |
7687 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7688 return NULL; | |
7689 | |
7690 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7691 win = wins->data; | |
7692 | |
7693 for (convs = win->gtkconvs; | |
7694 convs != NULL; | |
7695 convs = convs->next) { | |
7696 | |
7697 conv = convs->data; | |
7698 | |
7699 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7700 return win; | |
7701 } | |
7702 } | |
7703 | |
7704 return NULL; | |
7705 } | |
7706 | |
7707 GaimGtkWindow * | |
7708 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
7709 { | |
7710 GList *wins, *convs; | |
7711 GaimGtkWindow *win; | |
7712 GaimGtkConversation *conv; | |
7713 | |
7714 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7715 return NULL; | |
7716 | |
7717 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7718 wins != NULL; | |
7719 wins = wins->prev) { | |
7720 | |
7721 win = wins->data; | |
7722 | |
7723 for (convs = win->gtkconvs; | |
7724 convs != NULL; | |
7725 convs = convs->next) { | |
7726 | |
7727 conv = convs->data; | |
7728 | |
7729 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7730 return win; | |
7731 } | |
7732 } | |
7733 | |
7734 return NULL; | |
7735 } | |
7736 | |
7737 | |
7738 /************************************************************************** | |
7739 * Conversation placement functions | |
7740 **************************************************************************/ | |
7741 typedef struct | |
7742 { | |
7743 char *id; | |
7744 char *name; | |
7745 GaimConvPlacementFunc fnc; | |
7746 | |
7747 } ConvPlacementData; | |
7748 | |
7749 static GList *conv_placement_fncs = NULL; | |
7750 static GaimConvPlacementFunc place_conv = NULL; | |
7751 | |
7752 /* This one places conversations in the last made window. */ | |
7753 static void | |
7754 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7755 { | |
7756 GaimGtkWindow *win; | |
7757 | |
7758 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7759 win = l ? l->data : NULL;; | |
7760 | |
7761 if (win == NULL) { | |
7762 win = gaim_gtk_conv_window_new(); | |
7763 | |
7764 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7765 gaim_gtk_conv_window_show(win); | |
7766 } else { | |
7767 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7768 } | |
7769 } | |
7770 | |
7771 /* This one places conversations in the last made window of the same type. */ | |
7772 static void | |
7773 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7774 { | |
7775 GaimGtkWindow *win; | |
7776 | |
7777 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7778 | |
7779 if (win == NULL) { | |
7780 win = gaim_gtk_conv_window_new(); | |
7781 | |
7782 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7783 gaim_gtk_conv_window_show(win); | |
7784 } else | |
7785 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7786 } | |
7787 | |
7788 /* This one places each conversation in its own window. */ | |
7789 static void | |
7790 conv_placement_new_window(GaimGtkConversation *conv) | |
7791 { | |
7792 GaimGtkWindow *win; | |
7793 | |
7794 win = gaim_gtk_conv_window_new(); | |
7795 | |
7796 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7797 | |
7798 gaim_gtk_conv_window_show(win); | |
7799 } | |
7800 | |
7801 static GaimGroup * | |
7802 conv_get_group(GaimGtkConversation *conv) | |
7803 { | |
7804 GaimGroup *group = NULL; | |
7805 | |
7806 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7807 GaimBuddy *buddy; | |
7808 | |
7809 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7810 gaim_conversation_get_name(conv->active_conv)); | |
7811 | |
7812 if (buddy != NULL) | |
12088 | 7813 group = gaim_buddy_get_group(buddy); |
11581 | 7814 |
7815 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7816 GaimChat *chat; | |
7817 | |
7818 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7819 gaim_conversation_get_name(conv->active_conv)); | |
7820 | |
7821 if (chat != NULL) | |
7822 group = gaim_chat_get_group(chat); | |
7823 } | |
7824 | |
7825 return group; | |
7826 } | |
7827 | |
7828 /* | |
7829 * This groups things by, well, group. Buddies from groups will always be | |
7830 * grouped together, and a buddy from a group not belonging to any currently | |
7831 * open windows will get a new window. | |
7832 */ | |
7833 static void | |
7834 conv_placement_by_group(GaimGtkConversation *conv) | |
7835 { | |
7836 GaimConversationType type; | |
7837 GaimGroup *group = NULL; | |
7838 GList *wl, *cl; | |
7839 | |
7840 type = gaim_conversation_get_type(conv->active_conv); | |
7841 | |
7842 group = conv_get_group(conv); | |
7843 | |
7844 /* Go through the list of IMs and find one with this group. */ | |
7845 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7846 GaimGtkWindow *win2; | |
7847 GaimGtkConversation *conv2; | |
7848 GaimGroup *group2 = NULL; | |
7849 | |
7850 win2 = wl->data; | |
7851 | |
7852 for (cl = win2->gtkconvs; | |
7853 cl != NULL; | |
7854 cl = cl->next) { | |
7855 conv2 = cl->data; | |
7856 | |
7857 group2 = conv_get_group(conv2); | |
7858 | |
7859 if (group == group2) { | |
7860 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7861 | |
7862 return; | |
7863 } | |
7864 } | |
7865 } | |
7866 | |
7867 /* Make a new window. */ | |
7868 conv_placement_new_window(conv); | |
7869 } | |
7870 | |
7871 /* This groups things by account. Otherwise, the same semantics as above */ | |
7872 static void | |
7873 conv_placement_by_account(GaimGtkConversation *conv) | |
7874 { | |
7875 GaimConversationType type; | |
7876 GList *wins, *convs; | |
7877 GaimAccount *account; | |
7878 | |
7879 account = gaim_conversation_get_account(conv->active_conv); | |
7880 type = gaim_conversation_get_type(conv->active_conv); | |
7881 | |
7882 /* Go through the list of IMs and find one with this group. */ | |
7883 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7884 GaimGtkWindow *win2; | |
7885 GaimGtkConversation *conv2; | |
7886 | |
7887 win2 = wins->data; | |
7888 | |
7889 for (convs = win2->gtkconvs; | |
7890 convs != NULL; | |
7891 convs = convs->next) { | |
7892 conv2 = convs->data; | |
7893 | |
7894 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7895 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7896 return; | |
7897 } | |
7898 } | |
7899 } | |
7900 | |
7901 /* Make a new window. */ | |
7902 conv_placement_new_window(conv); | |
7903 } | |
7904 | |
7905 static ConvPlacementData * | |
7906 get_conv_placement_data(const char *id) | |
7907 { | |
7908 ConvPlacementData *data = NULL; | |
7909 GList *n; | |
7910 | |
7911 for (n = conv_placement_fncs; n; n = n->next) { | |
7912 data = n->data; | |
7913 if (!strcmp(data->id, id)) | |
7914 return data; | |
7915 } | |
7916 | |
7917 return NULL; | |
7918 } | |
7919 | |
7920 static void | |
7921 add_conv_placement_fnc(const char *id, const char *name, | |
7922 GaimConvPlacementFunc fnc) | |
7923 { | |
7924 ConvPlacementData *data; | |
7925 | |
7926 data = g_new(ConvPlacementData, 1); | |
7927 | |
7928 data->id = g_strdup(id); | |
7929 data->name = g_strdup(name); | |
7930 data->fnc = fnc; | |
7931 | |
7932 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7933 } | |
7934 | |
7935 static void | |
7936 ensure_default_funcs(void) | |
7937 { | |
7938 if (conv_placement_fncs == NULL) { | |
7939 add_conv_placement_fnc("last", _("Last created window"), | |
7940 conv_placement_last_created_win); | |
7941 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7942 conv_placement_last_created_win_type); | |
7943 add_conv_placement_fnc("new", _("New window"), | |
7944 conv_placement_new_window); | |
7945 add_conv_placement_fnc("group", _("By group"), | |
7946 conv_placement_by_group); | |
7947 add_conv_placement_fnc("account", _("By account"), | |
7948 conv_placement_by_account); | |
7949 } | |
7950 } | |
7951 | |
7952 GList * | |
7953 gaim_gtkconv_placement_get_options(void) | |
7954 { | |
7955 GList *n, *list = NULL; | |
7956 ConvPlacementData *data; | |
7957 | |
7958 ensure_default_funcs(); | |
7959 | |
7960 for (n = conv_placement_fncs; n; n = n->next) { | |
7961 data = n->data; | |
7962 list = g_list_append(list, data->name); | |
7963 list = g_list_append(list, data->id); | |
7964 } | |
7965 | |
7966 return list; | |
7967 } | |
7968 | |
7969 | |
7970 void | |
7971 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
7972 GaimConvPlacementFunc fnc) | |
7973 { | |
7974 g_return_if_fail(id != NULL); | |
7975 g_return_if_fail(name != NULL); | |
7976 g_return_if_fail(fnc != NULL); | |
7977 | |
7978 ensure_default_funcs(); | |
7979 | |
7980 add_conv_placement_fnc(id, name, fnc); | |
7981 } | |
7982 | |
7983 void | |
7984 gaim_gtkconv_placement_remove_fnc(const char *id) | |
7985 { | |
7986 ConvPlacementData *data = get_conv_placement_data(id); | |
7987 | |
7988 if (data == NULL) | |
7989 return; | |
7990 | |
7991 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
7992 | |
7993 g_free(data->id); | |
7994 g_free(data->name); | |
7995 g_free(data); | |
7996 } | |
7997 | |
7998 const char * | |
7999 gaim_gtkconv_placement_get_name(const char *id) | |
8000 { | |
8001 ConvPlacementData *data; | |
8002 | |
8003 ensure_default_funcs(); | |
8004 | |
8005 data = get_conv_placement_data(id); | |
8006 | |
8007 if (data == NULL) | |
8008 return NULL; | |
8009 | |
8010 return data->name; | |
8011 } | |
8012 | |
8013 GaimConvPlacementFunc | |
8014 gaim_gtkconv_placement_get_fnc(const char *id) | |
8015 { | |
8016 ConvPlacementData *data; | |
8017 | |
8018 ensure_default_funcs(); | |
8019 | |
8020 data = get_conv_placement_data(id); | |
8021 | |
8022 if (data == NULL) | |
8023 return NULL; | |
8024 | |
8025 return data->fnc; | |
8026 } | |
8027 | |
8028 void | |
8029 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
8030 { | |
8031 g_return_if_fail(func != NULL); | |
8032 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8033 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8034 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8035 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8036 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8037 place_conv = NULL; |
11581 | 8038 } |
8039 | |
8040 GaimConvPlacementFunc | |
8041 gaim_gtkconv_placement_get_current_func(void) | |
8042 { | |
8043 return place_conv; | |
8044 } | |
8045 | |
8046 void | |
8047 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
8048 { | |
8049 if (place_conv) | |
8050 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8051 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8052 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8053 } |
12239 | 8054 |
8055 gboolean | |
8056 gaim_gtkconv_is_hidden(GaimGtkConversation *gtkconv) | |
8057 { | |
8058 g_return_val_if_fail(gtkconv != NULL, FALSE); | |
8059 | |
8060 return (gtkconv->win == hidden_convwin); | |
8061 } | |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8062 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8063 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8064 /* Algorithm from http://www.w3.org/TR/AERT#color-contrast */ |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
8065 static gboolean |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8066 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
|
8067 { |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8068 gulong fg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8069 gulong bg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8070 gulong br_diff; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8071 gulong col_diff; |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8072 int fred, fgreen, fblue, bred, bgreen, bblue; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8073 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8074 /* 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
|
8075 * GTK on the other hand has values between 0 and 65535 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8076 * Err suggested I >> 8, which grabbed the high bits. |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8077 */ |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8078 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8079 fred = foreground.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8080 fgreen = foreground.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8081 fblue = foreground.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8082 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8083 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8084 bred = background.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8085 bgreen = background.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8086 bblue = background.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8087 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8088 fg_brightness = (fred * 299 + fgreen * 587 + fblue * 114) / 1000; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8089 bg_brightness = (bred * 299 + bgreen * 587 + bblue * 114) / 1000; |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8090 br_diff = abs(fg_brightness - bg_brightness); |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8091 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8092 col_diff = abs(fred - bred) + abs(fgreen - bgreen) + abs(fblue - bblue); |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8093 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8094 return ((col_diff > color_contrast) && (br_diff > brightness_contrast)); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8095 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8096 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8097 |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
8098 static GdkColor* |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8099 generate_nick_colors(guint *color_count, GdkColor background) |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8100 { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8101 guint numcolors = *color_count; |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8102 guint i = 0, j = 0; |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8103 GdkColor *colors = g_new(GdkColor, numcolors); |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8104 GdkColor nick_highlight; |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8105 GdkColor send_color; |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8106 time_t breakout_time; |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8107 |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8108 gdk_color_parse(HIGHLIGHT_COLOR, &nick_highlight); |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8109 gdk_color_parse(SEND_COLOR, &send_color); |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8110 |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8111 srand(background.red + background.green + background.blue + 1); |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8112 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8113 breakout_time = time(NULL) + 3; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8114 |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8115 /* 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
|
8116 * 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
|
8117 * numcolors of them that do |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8118 */ |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8119 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
|
8120 { |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8121 GdkColor color = nick_seed_colors[j]; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8122 |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8123 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
|
8124 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8125 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8126 { |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8127 colors[i] = color; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8128 i++; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8129 } |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8130 j++; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8131 } |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8132 |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8133 /* 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
|
8134 * 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
|
8135 * 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
|
8136 * conflict with each other. |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8137 */ |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8138 while(i < numcolors && time(NULL) < breakout_time) |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8139 { |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8140 GdkColor color = { 0, rand() % 65536, rand() % 65536, rand() % 65536 }; |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8141 |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8142 gaim_debug(GAIM_DEBUG_WARNING, NULL, |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8143 "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
|
8144 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8145 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
|
8146 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8147 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8148 { |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8149 colors[i] = color; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8150 i++; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8151 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8152 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8153 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8154 if (i < numcolors) { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8155 GdkColor *c = colors; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8156 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
|
8157 colors = g_memdup(c, i * sizeof(GdkColor)); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8158 g_free(c); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8159 *color_count = i; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8160 |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8161 } |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8162 |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8163 return colors; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8164 } |