Mercurial > pidgin
annotate src/gtkconv.c @ 13769:1afc1b0c4fb3
[gaim-migrate @ 16181]
SF Patch #1475297 points out that the side tab width is too much for people with lower resolutions. We've had a couple complaints. I e-mailed gaim-devel and I don't remember any responses (nor do I see any in my e-mail archive).
I'm changing the side tab with from 18 to 12. The submitter of that patch item suggested 10, but I compromised a bit.
If you object to this, let me know (or commit something else).
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 12 May 2006 20:21:35 +0000 |
parents | 410c965f56e0 |
children | 743e38a3182b |
rev | line source |
---|---|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
1 /** |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
2 * @file gtkconv.c GTK+ Conversation API |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
3 * @ingroup gtkui |
4359 | 4 * |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
5 * gaim |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
6 * |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
10 * |
4359 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
9791 | 26 #include "internal.h" |
27 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
28 |
4359 | 29 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
30 # include <X11/Xlib.h> |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
31 #endif |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
32 |
4359 | 33 #ifdef USE_GTKSPELL |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
34 # include <gtkspell/gtkspell.h> |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
35 # ifdef _WIN32 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
36 # include "wspell.h" |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
37 # endif |
4359 | 38 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
39 |
4359 | 40 #include <gdk/gdkkeysyms.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
41 |
9699 | 42 #include "account.h" |
9130 | 43 #include "cmds.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
44 #include "debug.h" |
12272 | 45 #include "idle.h" |
6982 | 46 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
47 #include "log.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5402
diff
changeset
|
48 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
49 #include "prpl.h" |
6038 | 50 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
51 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
52 |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
53 #include "gtkdnd-hints.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
54 #include "gtkblist.h" |
5717 | 55 #include "gtkconv.h" |
11583 | 56 #include "gtkconvwin.h" |
9709 | 57 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
58 #include "gtkimhtml.h" |
8317 | 59 #include "gtkimhtmltoolbar.h" |
7431 | 60 #include "gtklog.h" |
11554
f8443218b7fe
[gaim-migrate @ 13814]
Gary Kramlich <grim@reaperworld.com>
parents:
11552
diff
changeset
|
61 #include "gtkmenutray.h" |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
62 #include "gtkpounce.h" |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
63 #include "gtkprefs.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
64 #include "gtkprivacy.h" |
11525 | 65 #include "gtkthemes.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
66 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
67 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
68 |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
69 #include "gtknickcolors.h" |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
70 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
71 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
72 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
73 typedef enum |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
74 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
75 GAIM_GTKCONV_SET_TITLE = 1 << 0, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
76 GAIM_GTKCONV_BUDDY_ICON = 1 << 1, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
77 GAIM_GTKCONV_MENU = 1 << 2, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
78 GAIM_GTKCONV_TAB_ICON = 1 << 3, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
79 GAIM_GTKCONV_TOPIC = 1 << 4, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
80 GAIM_GTKCONV_SMILEY_THEME = 1 << 5, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
81 GAIM_GTKCONV_COLORIZE_TITLE = 1 << 6 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
82 }GaimGtkConvFields; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
83 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
84 #define GAIM_GTKCONV_ALL ((1 << 7) - 1) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
85 |
12359
cbf9f2e26916
[gaim-migrate @ 14663]
Richard Laager <rlaager@wiktel.com>
parents:
12358
diff
changeset
|
86 #define SEND_COLOR "#204a87" |
cbf9f2e26916
[gaim-migrate @ 14663]
Richard Laager <rlaager@wiktel.com>
parents:
12358
diff
changeset
|
87 #define RECV_COLOR "#cc0000" |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
88 #define HIGHLIGHT_COLOR "#AF7F00" |
7854 | 89 |
12335 | 90 /* Undef this to turn off "custom-smiley" debug messages */ |
91 #define DEBUG_CUSTOM_SMILEY | |
92 | |
10108 | 93 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
94 | |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
95 #if 0 |
10108 | 96 /* These colors come from the default GNOME palette */ |
97 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
98 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
99 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
100 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
101 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
102 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
103 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
104 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
105 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
106 {0, 34816, 17920, 12544}, /* Red Dark */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
107 {0, 49408, 14336, 8704}, /* Red Shadow */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
108 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
109 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
110 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
111 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
112 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
113 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
114 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
115 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
116 {0, 57088, 16896, 7680}, /* Accent Red */ |
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
117 {0, 39168, 0, 0}, /* Accent Red Dark */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
118 {0, 17920, 40960, 17920}, /* Accent Green */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
119 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 120 }; |
6291 | 121 |
4359 | 122 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
123 #endif |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
124 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
125 /* From http://www.w3.org/TR/AERT#color-contrast */ |
12354
709548d845a1
[gaim-migrate @ 14658]
Luke Schierer <lschiere@pidgin.im>
parents:
12353
diff
changeset
|
126 #define MIN_BRIGHTNESS_CONTRAST 75 |
709548d845a1
[gaim-migrate @ 14658]
Luke Schierer <lschiere@pidgin.im>
parents:
12353
diff
changeset
|
127 #define MIN_COLOR_CONTRAST 200 |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
128 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
129 #define NUM_NICK_COLORS 220 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
130 static GdkColor *nick_colors = NULL; |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
131 static guint nbr_nick_colors; |
4359 | 132 |
11581 | 133 typedef struct { |
4359 | 134 GtkWidget *window; |
135 | |
136 GtkWidget *entry; | |
137 GtkWidget *message; | |
138 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
139 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
140 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
141 } InviteBuddyInfo; |
4359 | 142 |
143 static GtkWidget *invite_dialog = NULL; | |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
144 static GtkWidget *warn_close_dialog = NULL; |
4359 | 145 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
146 static GaimGtkWindow *hidden_convwin = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
147 static GList *window_list = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
148 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
149 |
11594 | 150 static gboolean update_send_to_selection(GaimGtkWindow *win); |
151 static void generate_send_to_items(GaimGtkWindow *win); | |
11581 | 152 |
4359 | 153 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
10810 | 154 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
11604 | 155 static void gray_stuff_out(GaimGtkConversation *gtkconv); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
156 static GList *generate_invite_user_names(GaimConnection *gc); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
157 static void add_chat_buddy_common(GaimConversation *conv, const char *name, |
11869 | 158 GaimConvChatBuddyFlags flags, const char *alias, const char *old_name); |
9605 | 159 static gboolean tab_complete(GaimConversation *conv); |
11604 | 160 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); |
11613 | 161 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); |
10810 | 162 static void update_typing_icon(GaimGtkConversation *gtkconv); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
163 static const char *item_factory_translate_func (const char *path, gpointer func_data); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
164 gboolean gaim_gtkconv_has_focus(GaimConversation *conv); |
12335 | 165 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data); |
166 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data); | |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
167 static GdkColor* generate_nick_colors(guint *numcolors, GdkColor background); |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
168 static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
169 static void gaim_gtkconv_update_fields(GaimConversation *conv, GaimGtkConvFields fields); |
4359 | 170 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
171 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
172 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
173 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
174 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
175 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
176 col = nick_colors[g_str_hash(name) % nbr_nick_colors]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
177 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
178 (LUMINANCE(style->white)/MAX(MAX(col.red, col.blue), col.green))); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
179 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
180 /* The colors are chosen to look fine on white; we should never have to darken */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
181 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
182 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
183 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
184 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
185 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
186 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
187 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
188 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
189 |
4359 | 190 /************************************************************************** |
191 * Callbacks | |
192 **************************************************************************/ | |
10971 | 193 |
4359 | 194 static gint |
10810 | 195 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 196 { |
10810 | 197 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 198 |
10810 | 199 l = list; |
200 while (l) { | |
201 GaimConversation *conv = l->data; | |
202 gaim_conversation_destroy(conv); | |
203 l = l->next; | |
204 } | |
11508 | 205 |
10810 | 206 g_list_free(list); |
11508 | 207 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
208 return TRUE; |
4359 | 209 } |
210 | |
8914 | 211 static gboolean |
10810 | 212 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 213 { |
10810 | 214 GaimConversation *conv = gtkconv->active_conv; |
11508 | 215 |
8914 | 216 if (!GTK_WIDGET_VISIBLE(w)) |
217 return FALSE; | |
218 | |
219 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
220 return FALSE; | |
221 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
222 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
223 * tab bar will fit, but then I don't want new windows taking up the entire screen. I check to see |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
224 * if there is only one conversation in the window. This way we'll be setting new windows to the |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
225 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
226 /* I think that the above justification is not the majority, and that the new tab resizing should |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
227 * negate it anyway. --luke */ |
11338 | 228 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 229 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
230 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
231 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_width", allocation->width); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
232 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_height", allocation->height); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
233 } |
8914 | 234 if (w == gtkconv->entry) |
235 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
236 } | |
11338 | 237 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 238 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
239 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
240 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_width", allocation->width); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
241 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_height", allocation->height); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
242 } |
8914 | 243 if (w == gtkconv->entry) |
244 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
245 } | |
246 | |
247 return FALSE; | |
248 } | |
249 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
250 static void |
10810 | 251 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
252 { |
10810 | 253 GaimConversation *conv = c->active_conv; |
11508 | 254 |
10665 | 255 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
256 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
259 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold") != GTK_IMHTML(c->entry)->edit.bold) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
261 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
262 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic") != GTK_IMHTML(c->entry)->edit.italic) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
264 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
266 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline") != GTK_IMHTML(c->entry)->edit.underline) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
267 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
268 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
269 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
270 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
271 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
272 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
273 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
274 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
275 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
276 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
277 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
278 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
279 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
280 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
281 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
282 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
283 fg_color.blue / 256); |
8061 | 284 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
285 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
286 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
287 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
288 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
289 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
290 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
291 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
292 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
293 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
294 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
295 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
296 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
297 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
298 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
299 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
300 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
301 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
302 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
303 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
304 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
305 g_free(color); |
8677 | 306 |
9025 | 307 |
10665 | 308 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 309 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
310 else | |
311 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 312 } |
313 } | |
9130 | 314 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
315 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
316 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
317 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
318 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
319 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
320 |
9130 | 321 static const char * |
322 gaim_gtk_get_cmd_prefix(void) | |
323 { | |
324 return "/"; | |
325 } | |
326 | |
9167 | 327 static GaimCmdRet |
9829 | 328 say_command_cb(GaimConversation *conv, |
329 const char *cmd, char **args, char **error, void *data) | |
330 { | |
11338 | 331 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 332 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 333 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 334 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
335 | |
336 return GAIM_CMD_RET_OK; | |
337 } | |
338 | |
339 static GaimCmdRet | |
9167 | 340 me_command_cb(GaimConversation *conv, |
9597 | 341 const char *cmd, char **args, char **error, void *data) |
9167 | 342 { |
343 char *tmp; | |
344 | |
345 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 346 |
11338 | 347 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 348 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 349 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 350 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
351 | |
352 g_free(tmp); | |
353 return GAIM_CMD_RET_OK; | |
354 } | |
355 | |
9212 | 356 static GaimCmdRet |
357 debug_command_cb(GaimConversation *conv, | |
9597 | 358 const char *cmd, char **args, char **error, void *data) |
9212 | 359 { |
360 char *tmp, *markup; | |
361 GaimCmdStatus status; | |
362 | |
363 if (!g_ascii_strcasecmp(args[0], "version")) { | |
13369 | 364 tmp = g_strdup_printf("me is using Gaim v%s.", VERSION); |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
365 markup = g_markup_escape_text(tmp, -1); |
9212 | 366 |
367 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
368 | |
369 g_free(tmp); | |
370 g_free(markup); | |
371 return status; | |
372 } else { | |
373 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
374 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
375 return GAIM_CMD_STATUS_OK; | |
376 } | |
377 } | |
378 | |
9213 | 379 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
380 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
381 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
382 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
383 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
384 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
385 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
386 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
387 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
388 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
389 } |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
390 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
391 static GaimCmdRet |
9213 | 392 help_command_cb(GaimConversation *conv, |
9597 | 393 const char *cmd, char **args, char **error, void *data) |
9213 | 394 { |
9597 | 395 GList *l, *text; |
9213 | 396 GString *s; |
9597 | 397 |
398 if (args[0] != NULL) { | |
399 s = g_string_new(""); | |
400 text = gaim_cmd_help(conv, args[0]); | |
401 | |
402 if (text) { | |
403 for (l = text; l; l = l->next) | |
404 if (l->next) | |
9816 | 405 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 406 else |
9816 | 407 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 408 } else { |
409 g_string_append(s, _("No such command (in this context).")); | |
410 } | |
411 } else { | |
412 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
413 "The following commands are available in this context:\n")); | |
414 | |
415 text = gaim_cmd_list(conv); | |
416 for (l = text; l; l = l->next) | |
9213 | 417 if (l->next) |
9597 | 418 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 419 else |
9597 | 420 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 421 } |
422 | |
423 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
424 g_string_free(s, TRUE); | |
425 | |
426 return GAIM_CMD_STATUS_OK; | |
427 } | |
428 | |
4359 | 429 static void |
9374 | 430 send_history_add(GaimConversation *conv, const char *message) |
431 { | |
432 GList *first; | |
433 | |
434 first = g_list_first(conv->send_history); | |
435 | |
436 if (first->data) | |
437 g_free(first->data); | |
438 | |
439 first->data = g_strdup(message); | |
440 | |
441 conv->send_history = g_list_prepend(first, NULL); | |
442 } | |
443 | |
9832 | 444 static gboolean |
445 check_for_and_do_command(GaimConversation *conv) | |
446 { | |
447 GaimGtkConversation *gtkconv; | |
448 char *cmd; | |
449 const char *prefix; | |
450 GtkTextIter start; | |
451 | |
452 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
453 prefix = gaim_gtk_get_cmd_prefix(); | |
454 | |
455 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
456 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
457 | |
458 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
459 && !gtk_text_iter_get_child_anchor(&start)) { | |
460 GaimCmdStatus status; | |
461 char *error, *cmdline, *markup, *send_history; | |
462 GtkTextIter end; | |
463 | |
464 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
465 send_history_add(conv, send_history); | |
466 g_free(send_history); | |
467 | |
468 cmdline = cmd + strlen(prefix); | |
469 | |
470 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
471 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
472 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
473 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
474 g_free(cmd); | |
475 g_free(markup); | |
476 | |
477 switch (status) { | |
478 case GAIM_CMD_STATUS_OK: | |
479 return TRUE; | |
480 case GAIM_CMD_STATUS_NOT_FOUND: | |
481 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
482 gaim_conversation_write(conv, "", _("No such command."), | |
483 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
484 | |
485 return TRUE; | |
486 } | |
487 return FALSE; | |
488 case GAIM_CMD_STATUS_WRONG_ARGS: | |
489 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
490 "to that command."), | |
491 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
492 return TRUE; | |
493 case GAIM_CMD_STATUS_FAILED: | |
494 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
495 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
496 if(error) | |
497 g_free(error); | |
498 return TRUE; | |
499 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 500 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 501 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 502 GAIM_MESSAGE_NO_LOG, time(NULL)); |
503 else | |
10843 | 504 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 505 GAIM_MESSAGE_NO_LOG, time(NULL)); |
506 return TRUE; | |
507 case GAIM_CMD_STATUS_WRONG_PRPL: | |
508 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
509 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
510 return TRUE; | |
511 } | |
512 } | |
513 | |
514 g_free(cmd); | |
515 return FALSE; | |
516 } | |
517 | |
9374 | 518 static void |
10810 | 519 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 520 { |
10810 | 521 GaimConversation *conv = gtkconv->active_conv; |
8655 | 522 GaimAccount *account; |
8677 | 523 GaimConnection *gc; |
12216 | 524 GaimMessageFlags flags = 0; |
8448 | 525 char *buf, *clean; |
4359 | 526 |
8655 | 527 account = gaim_conversation_get_account(conv); |
9130 | 528 |
9471 | 529 if (!gaim_account_is_connected(account)) |
530 return; | |
531 | |
11338 | 532 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 533 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 534 return; |
535 | |
9832 | 536 if (check_for_and_do_command(conv)) { |
537 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
538 return; | |
9130 | 539 } |
540 | |
8442 | 541 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 542 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 543 |
4359 | 544 gtk_widget_grab_focus(gtkconv->entry); |
545 | |
8448 | 546 if (strlen(clean) == 0) { |
547 g_free(clean); | |
4359 | 548 return; |
549 } | |
550 | |
12272 | 551 gaim_idle_touch(); |
552 | |
12216 | 553 /* XXX: is there a better way to tell if the message has images? */ |
554 if (GTK_IMHTML(gtkconv->entry)->im_images != NULL) | |
555 flags |= GAIM_MESSAGE_IMAGES; | |
556 | |
8677 | 557 gc = gaim_account_get_connection(account); |
10665 | 558 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 559 char **bufs; |
560 int i; | |
561 | |
562 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
563 for (i = 0; bufs[i]; i++) { | |
9374 | 564 send_history_add(conv, bufs[i]); |
11338 | 565 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 566 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), bufs[i], flags); |
11338 | 567 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 568 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), bufs[i], flags); |
8677 | 569 } |
570 | |
571 g_strfreev(bufs); | |
572 | |
573 } else { | |
9374 | 574 send_history_add(conv, buf); |
11338 | 575 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 576 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), buf, flags); |
11338 | 577 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 578 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), buf, flags); |
8677 | 579 } |
4359 | 580 |
8677 | 581 g_free(clean); |
4359 | 582 g_free(buf); |
583 | |
8061 | 584 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 585 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 586 } |
587 | |
588 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
589 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 590 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
591 GaimAccount *account; |
4359 | 592 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
593 GaimConversation *conv = gtkconv->active_conv; |
4359 | 594 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
595 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
596 name = gaim_conversation_get_name(conv); |
7879 | 597 |
11338 | 598 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 599 GaimBuddy *b; |
600 | |
601 b = gaim_find_buddy(account, name); | |
602 if (b != NULL) | |
9730 | 603 gaim_gtkdialogs_remove_buddy(b); |
7859 | 604 else if (account != NULL && gaim_account_is_connected(account)) |
605 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 606 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 607 GaimChat *c; |
608 | |
609 c = gaim_blist_find_chat(account, name); | |
610 if (c != NULL) | |
9730 | 611 gaim_gtkdialogs_remove_chat(c); |
7859 | 612 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 613 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 614 } |
4359 | 615 |
616 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
617 } | |
618 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
619 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 620 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
621 GaimConversation *conv = gtkconv->active_conv; |
7975 | 622 GaimPluginProtocolInfo *prpl_info = NULL; |
623 GaimConnection *gc; | |
624 | |
625 if ((gc = gaim_conversation_get_gc(conv))) { | |
626 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
627 | |
628 /* | |
629 * If there are special needs for getting info on users in | |
630 * buddy chat "rooms"... | |
631 */ | |
632 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
633 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
634 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
635 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
636 } |
7975 | 637 else |
638 prpl_info->get_info(gc, who); | |
639 } | |
640 } | |
641 | |
642 | |
4359 | 643 static void |
10810 | 644 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 645 { |
10810 | 646 GaimConversation *conv = gtkconv->active_conv; |
4359 | 647 |
11338 | 648 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 649 serv_get_info(gaim_conversation_get_gc(conv), |
650 gaim_conversation_get_name(conv)); | |
651 | |
652 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 653 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 654 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
655 GaimGtkChatPane *gtkchat; |
4359 | 656 GtkTreeIter iter; |
657 GtkTreeModel *model; | |
658 GtkTreeSelection *sel; | |
9554 | 659 char *name; |
4359 | 660 |
661 gtkchat = gtkconv->u.chat; | |
662 | |
663 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
664 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
665 | |
666 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 667 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 668 else |
669 return; | |
670 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
671 chat_do_info(gtkconv, name); |
9554 | 672 g_free(name); |
4359 | 673 } |
674 } | |
675 | |
676 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
677 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 678 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
679 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
680 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
681 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
682 account = gaim_conversation_get_account(conv); |
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 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
685 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 686 |
687 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
688 } | |
689 | |
690 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
691 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 692 { |
693 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
694 GaimGtkConversation *gtkconv; |
4359 | 695 |
696 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
697 | |
698 if (resp == GTK_RESPONSE_OK) { | |
699 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
700 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
701 | |
10113 | 702 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 703 return; |
704 | |
705 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
706 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 707 message, buddy); |
708 } | |
709 | |
710 gtk_widget_destroy(invite_dialog); | |
711 invite_dialog = NULL; | |
712 | |
713 g_free(info); | |
714 } | |
715 | |
716 static void | |
9909 | 717 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
718 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
719 { | |
720 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
721 const char *convprotocol; | |
722 | |
723 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
724 | |
725 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
726 { | |
727 GaimBlistNode *node = NULL; | |
728 GaimBuddy *buddy; | |
729 | |
730 memcpy(&node, sd->data, sizeof(node)); | |
731 | |
732 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
733 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
734 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
735 buddy = (GaimBuddy *)node; | |
736 else | |
737 return; | |
738 | |
739 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
740 { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
741 gaim_notify_error(GAIM_GTK_CONVERSATION(info->conv), NULL, |
9909 | 742 _("That buddy is not on the same protocol as this " |
10843 | 743 "chat."), NULL); |
9909 | 744 } |
745 else | |
746 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
747 | |
748 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
749 } | |
750 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
751 { | |
752 char *protocol = NULL; | |
753 char *username = NULL; | |
754 GaimAccount *account; | |
755 | |
11137 | 756 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 757 &protocol, &username, NULL)) |
758 { | |
759 if (account == NULL) | |
760 { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
761 gaim_notify_error(GAIM_GTK_CONVERSATION(info->conv), NULL, |
9909 | 762 _("You are not currently signed on with an account that " |
763 "can invite that buddy."), NULL); | |
764 } | |
765 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
766 { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
767 gaim_notify_error(GAIM_GTK_CONVERSATION(info->conv), NULL, |
9909 | 768 _("That buddy is not on the same protocol as this " |
10843 | 769 "chat."), NULL); |
9909 | 770 } |
771 else | |
772 { | |
773 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
774 } | |
775 } | |
776 | |
777 if (username != NULL) g_free(username); | |
778 if (protocol != NULL) g_free(protocol); | |
779 | |
780 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
781 } | |
782 } | |
783 | |
784 static const GtkTargetEntry dnd_targets[] = | |
785 { | |
786 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
787 {"application/x-im-contact", 0, 1} | |
788 }; | |
789 | |
790 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
791 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 792 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
793 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
794 InviteBuddyInfo *info = NULL; |
4359 | 795 |
796 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
797 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
798 GaimGtkWindow *gtkwin; |
4359 | 799 GtkWidget *label; |
800 GtkWidget *vbox, *hbox; | |
801 GtkWidget *table; | |
802 GtkWidget *img; | |
803 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
804 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 805 GTK_ICON_SIZE_DIALOG); |
4359 | 806 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
807 info = g_new0(InviteBuddyInfo, 1); |
4359 | 808 info->conv = conv; |
809 | |
11581 | 810 gc = gaim_conversation_get_gc(conv); |
811 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 812 |
813 /* Create the new dialog. */ | |
814 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 815 _("Invite Buddy Into Chat Room"), |
7879 | 816 GTK_WINDOW(gtkwin->window), 0, |
817 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
818 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 819 |
820 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 821 GTK_RESPONSE_OK); |
11243 | 822 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 823 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
824 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
825 | |
9909 | 826 info->window = GTK_WIDGET(invite_dialog); |
827 | |
4359 | 828 /* Setup the outside spacing. */ |
829 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
830 | |
11243 | 831 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
832 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 833 |
834 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 835 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 836 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
837 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
838 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
839 | |
840 /* Setup the right vbox. */ | |
841 vbox = gtk_vbox_new(FALSE, 0); | |
842 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
843 | |
844 /* Put our happy label in it. */ | |
845 label = gtk_label_new(_("Please enter the name of the user you wish " | |
846 "to invite, along with an optional invite " | |
847 "message.")); | |
848 gtk_widget_set_size_request(label, 350, -1); | |
849 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
850 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
851 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
852 | |
853 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 854 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 855 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
856 | |
857 /* Setup the table we're going to use to lay stuff out. */ | |
858 table = gtk_table_new(2, 2, FALSE); | |
11243 | 859 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
860 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
861 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 862 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
863 | |
864 /* Now the Buddy label */ | |
865 label = gtk_label_new(NULL); | |
866 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
867 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
868 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
869 | |
870 /* Now the Buddy drop-down entry field. */ | |
871 info->entry = gtk_combo_new(); | |
872 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
873 gtk_entry_set_activates_default( | |
874 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
875 | |
876 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
877 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
878 | |
879 /* Fill in the names. */ | |
880 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
881 generate_invite_user_names(gc)); | |
882 | |
883 | |
884 /* Now the label for "Message" */ | |
885 label = gtk_label_new(NULL); | |
886 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
887 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
888 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
889 | |
890 | |
891 /* And finally, the Message entry field. */ | |
892 info->message = gtk_entry_new(); | |
893 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
894 | |
895 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
896 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
897 | |
898 /* Connect the signals. */ | |
899 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
900 G_CALLBACK(do_invite), info); | |
9909 | 901 /* Setup drag-and-drop */ |
902 gtk_drag_dest_set(info->window, | |
903 GTK_DEST_DEFAULT_MOTION | | |
904 GTK_DEST_DEFAULT_DROP, | |
905 dnd_targets, | |
906 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
907 GDK_ACTION_COPY); | |
908 gtk_drag_dest_set(info->entry, | |
909 GTK_DEST_DEFAULT_MOTION | | |
910 GTK_DEST_DEFAULT_DROP, | |
911 dnd_targets, | |
912 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
913 GDK_ACTION_COPY); | |
914 | |
915 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
916 G_CALLBACK(invite_dnd_recv), info); | |
917 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
918 G_CALLBACK(invite_dnd_recv), info); | |
919 | |
4359 | 920 } |
921 | |
922 gtk_widget_show_all(invite_dialog); | |
923 | |
924 if (info != NULL) | |
925 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
926 } | |
927 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
928 static void |
7748 | 929 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
930 { | |
9714 | 931 gaim_gtkdialogs_im(); |
7748 | 932 } |
933 | |
934 static void | |
9504 | 935 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 936 { |
9504 | 937 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 938 FILE *fp; |
939 const char *name; | |
10849 | 940 gchar *text; |
9489 | 941 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
942 if ((fp = g_fopen(filename, "w+")) == NULL) { |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
943 gaim_notify_error(GAIM_GTK_CONVERSATION(conv), NULL, _("Unable to open file."), NULL); |
9489 | 944 return; |
945 } | |
946 | |
947 name = gaim_conversation_get_name(conv); | |
10849 | 948 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 949 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 950 |
951 text = gtk_imhtml_get_markup( | |
952 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
953 fprintf(fp, "%s", text); | |
954 g_free(text); | |
955 | |
956 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 957 fclose(fp); |
958 } | |
959 | |
10849 | 960 /* |
961 * It would be kinda cool if this gave the option of saving a | |
962 * plaintext v. HTML file. | |
963 */ | |
9489 | 964 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
965 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
966 { |
11581 | 967 GaimGtkWindow *win = data; |
968 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 969 gchar *buf; |
970 | |
971 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 972 |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
973 gaim_request_file(GAIM_GTK_CONVERSATION(conv), _("Save Conversation"), |
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
974 gaim_escape_filename(buf), |
10849 | 975 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); |
9489 | 976 |
977 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
978 } |
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 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
981 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
982 { |
11581 | 983 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
984 GaimConversation *conv; |
9917 | 985 GaimLogType type; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
986 GaimGtkBuddyList *gtkblist; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
987 GdkCursor *cursor; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
988 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
989 GaimAccount *account; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
990 GSList *buddies; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
991 GSList *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
992 |
11581 | 993 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
994 |
11338 | 995 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 996 type = GAIM_LOG_IM; |
11338 | 997 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 998 type = GAIM_LOG_CHAT; |
999 else | |
1000 return; | |
1001 | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1002 gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13424
diff
changeset
|
1003 |
12232
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 gdk_window_set_cursor(gtkblist->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1006 gdk_window_set_cursor(win->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1007 gdk_cursor_unref(cursor); |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13424
diff
changeset
|
1008 #if GTK_CHECK_VERSION(2,4,0) |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13424
diff
changeset
|
1009 gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window))); |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13424
diff
changeset
|
1010 #else |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13424
diff
changeset
|
1011 gdk_flush(); |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13424
diff
changeset
|
1012 #endif |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1013 |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1014 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1015 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1016 |
10845 | 1017 buddies = gaim_find_buddies(account, name); |
1018 for (cur = buddies; cur != NULL; cur = cur->next) | |
1019 { | |
1020 GaimBlistNode *node = cur->data; | |
10846 | 1021 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 1022 { |
1023 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
1024 g_slist_free(buddies); | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1025 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1026 gdk_window_set_cursor(win->window->window, NULL); |
10845 | 1027 return; |
1028 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1029 } |
10845 | 1030 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1031 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1032 gaim_gtk_log_show(type, name, account); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1033 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1034 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1035 gdk_window_set_cursor(win->window->window, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1036 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1037 |
8974 | 1038 static void |
1039 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
1040 { | |
11581 | 1041 GaimGtkWindow *win = data; |
8974 | 1042 GaimConversation *conv; |
1043 GaimGtkConversation *gtkconv; | |
1044 | |
11581 | 1045 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 1046 gtkconv = GAIM_GTK_CONVERSATION(conv); |
1047 | |
1048 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1049 } | |
1050 | |
7295 | 1051 struct _search { |
1052 GaimGtkConversation *gtkconv; | |
1053 GtkWidget *entry; | |
1054 }; | |
1055 | |
7929 | 1056 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 1057 { |
7929 | 1058 switch (resp) { |
1059 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1060 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1061 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1062 break; |
1063 | |
1064 case GTK_RESPONSE_DELETE_EVENT: | |
1065 case GTK_RESPONSE_CLOSE: | |
1066 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1067 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1068 s->gtkconv->dialogs.search = NULL; | |
1069 g_free(s); | |
1070 break; | |
1071 } | |
7295 | 1072 } |
1073 | |
1074 static void | |
7751 | 1075 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1076 { |
11581 | 1077 GaimGtkWindow *gtkwin = data; |
1078 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1079 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1080 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1081 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1082 GTK_ICON_SIZE_DIALOG); |
7929 | 1083 GtkWidget *label; |
7295 | 1084 struct _search *s; |
1085 | |
7798 | 1086 if (gtkconv->dialogs.search) { |
1087 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1088 return; |
7798 | 1089 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1090 |
7295 | 1091 s = g_malloc(sizeof(struct _search)); |
1092 s->gtkconv = gtkconv; | |
7929 | 1093 |
1094 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1095 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1096 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1097 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1098 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1099 GTK_RESPONSE_OK); |
7929 | 1100 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1101 G_CALLBACK(do_search_cb), s); | |
1102 | |
11243 | 1103 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1104 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1105 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1106 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
|
1107 gtk_container_set_border_width( |
11243 | 1108 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1109 | |
1110 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1111 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1112 hbox); |
7929 | 1113 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1114 | |
1115 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1116 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1117 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1118 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1119 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1120 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1121 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1122 | |
1123 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1124 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1125 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1126 g_signal_connect(G_OBJECT(s->entry), "changed", |
1127 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1128 gtkconv->dialogs.search); | |
1129 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
|
1130 |
7295 | 1131 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1132 gtk_widget_grab_focus(s->entry); |
7295 | 1133 } |
1134 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1135 static void |
9468 | 1136 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1137 { | |
11581 | 1138 GaimGtkWindow *win = data; |
1139 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1140 |
11338 | 1141 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1142 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1143 } | |
1144 | |
1145 } | |
1146 | |
1147 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1148 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1149 { |
11581 | 1150 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1151 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1152 |
11581 | 1153 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
|
1154 |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1155 gaim_gtk_pounce_editor_show(gaim_conversation_get_account(conv), |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1156 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1157 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1158 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1159 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1160 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1161 { |
11581 | 1162 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1163 GaimGtkConversation *gtkconv; |
8756 | 1164 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1165 |
11581 | 1166 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1167 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1168 | |
1169 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1170 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1171 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1172 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1173 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1174 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1175 { |
11581 | 1176 GaimGtkWindow *win = data; |
8756 | 1177 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1178 GaimGtkConversation *gtkconv; |
8756 | 1179 GtkIMHtmlToolbar *toolbar; |
1180 | |
11581 | 1181 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1182 conv = gtkconv->active_conv; | |
8756 | 1183 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1184 | |
1185 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1186 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1187 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1188 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1189 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1190 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1191 { |
11581 | 1192 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1193 GaimConversation *conv; |
7879 | 1194 GaimAccount *account; |
1195 const char *name; | |
1196 | |
11581 | 1197 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1198 account = gaim_conversation_get_account(conv); |
1199 name = gaim_conversation_get_name(conv); | |
1200 | |
11338 | 1201 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1202 GaimBuddy *b; |
1203 | |
1204 b = gaim_find_buddy(account, name); | |
1205 if (b != NULL) | |
9730 | 1206 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1207 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1208 GaimChat *c; |
1209 | |
1210 c = gaim_blist_find_chat(account, name); | |
1211 if (c != NULL) | |
9730 | 1212 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1216 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1218 { |
11581 | 1219 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1220 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1221 |
11581 | 1222 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1223 |
10810 | 1224 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1225 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1226 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1227 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1228 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1229 { |
11581 | 1230 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1231 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1232 |
11581 | 1233 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1234 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1235 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1236 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1237 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1238 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1239 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1240 { |
11581 | 1241 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1242 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1243 |
11581 | 1244 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1245 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1246 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1247 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1248 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1249 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1250 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1251 { |
11581 | 1252 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1253 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1254 |
11581 | 1255 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1256 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1257 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1258 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1259 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1260 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1261 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1262 { |
11581 | 1263 GaimGtkWindow *win = data; |
1264 | |
1265 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
|
1266 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1267 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1268 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1269 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1270 { |
11581 | 1271 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1272 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1273 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1274 |
11581 | 1275 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1276 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1277 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1278 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1279 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1280 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
|
1281 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1282 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1283 return; |
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 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1286 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1287 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1288 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1289 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1290 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1291 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1292 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1293 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1294 time(NULL)); |
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 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1297 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1298 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1299 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1300 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1301 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1302 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1303 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1304 /* 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
|
1305 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1306 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1307 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1309 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1310 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1311 { |
10377 | 1312 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1313 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
|
1314 } |
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 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1317 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1318 { |
11581 | 1319 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1320 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1321 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1322 |
11581 | 1323 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1324 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1325 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1326 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1327 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1328 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1329 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1330 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1331 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1332 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1333 |
7961 | 1334 static void |
9188 | 1335 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1336 { | |
12188 | 1337 gaim_prefs_set_bool("/gaim/gtk/conversations/show_timestamps", |
9188 | 1338 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
1339 } | |
1340 | |
1341 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1342 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1343 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1344 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1345 GaimAccount *account; |
1346 GaimConnection *gc; | |
7961 | 1347 GaimPluginProtocolInfo *prpl_info = NULL; |
1348 char *real_who; | |
1349 | |
1350 account = gaim_conversation_get_account(conv); | |
10431 | 1351 g_return_if_fail(account != NULL); |
1352 | |
1353 gc = gaim_account_get_connection(account); | |
1354 g_return_if_fail(gc != NULL); | |
1355 | |
1356 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1357 | |
1358 if (prpl_info && prpl_info->get_cb_real_name) | |
1359 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1360 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1361 else | |
1362 real_who = g_strdup(who); | |
1363 | |
1364 if(!real_who) | |
1365 return; | |
1366 | |
10431 | 1367 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1368 |
1369 g_free(real_who); | |
1370 } | |
1371 | |
1372 static void | |
10810 | 1373 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1374 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1375 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1376 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1377 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1378 GtkTreeSelection *sel; |
9554 | 1379 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1380 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1381 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1382 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1383 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1384 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1385 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1386 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1387 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
|
1388 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1389 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1390 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1391 chat_do_im(gtkconv, name); |
9554 | 1392 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1393 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1394 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1395 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1396 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1397 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1398 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1399 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1400 GaimConvChat *chat; |
11869 | 1401 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1402 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1403 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1404 GtkTreeSelection *sel; |
10504 | 1405 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1406 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1407 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1408 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1409 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1410 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1411 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1412 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
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 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1415 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1416 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1417 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1418 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1419 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1420 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1421 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1422 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1423 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1424 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1425 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1426 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1427 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1428 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1429 |
11869 | 1430 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1431 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1432 g_free(alias); |
5908
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 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1435 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1436 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1437 { |
1438 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1439 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1440 chat_do_im(gtkconv, who); |
5908
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 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1443 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1444 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1445 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1446 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1447 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1448 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1449 | |
1450 serv_send_file(gc, who, NULL); | |
1451 } | |
1452 | |
1453 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1454 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1455 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1456 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1457 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1458 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1459 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1460 chat_do_info(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_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1465 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1466 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1467 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1468 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1469 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1470 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1471 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1472 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1473 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1474 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1475 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1476 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1477 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1478 * 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
|
1479 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1480 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1481 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1482 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1483 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1484 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1485 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1486 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1487 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1488 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1489 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1490 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1491 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1492 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1493 GaimAccount *account; |
6695 | 1494 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1495 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1496 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1497 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1498 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1499 b = gaim_find_buddy(account, name); |
5908
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 (b != NULL) |
9730 | 1502 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1503 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1504 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1505 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1506 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
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 |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1509 static GtkTextMark * |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1510 get_mark_for_user(GaimGtkConversation *gtkconv, const char *who) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1511 { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1512 GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1513 char *tmp = g_strconcat("user:", who, NULL); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1514 GtkTextMark *mark = gtk_text_buffer_get_mark(buf, tmp); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1515 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1516 g_free(tmp); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1517 return mark; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1518 } |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1519 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1520 static void |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1521 menu_last_said_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1522 { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1523 GtkTextMark *mark; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1524 const char *who; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1525 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1526 who = g_object_get_data(G_OBJECT(w), "user_data"); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1527 mark = get_mark_for_user(gtkconv, who); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1528 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1529 if (mark != NULL) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1530 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(gtkconv->imhtml), mark, 0.1, FALSE, 0, 0); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1531 else |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1532 g_return_if_reached(); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1533 } |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1534 |
8143 | 1535 static GtkWidget * |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1536 create_chat_menu(GaimConversation *conv, const char *who, GaimConnection *gc) |
8143 | 1537 { |
1538 static GtkWidget *menu = NULL; | |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1539 GaimPluginProtocolInfo *prpl_info = NULL; |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1540 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1541 gboolean is_me = FALSE; |
8143 | 1542 GtkWidget *button; |
1543 | |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1544 if (gc != NULL) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1545 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1546 |
8143 | 1547 /* |
1548 * If a menu already exists, destroy it before creating a new one, | |
1549 * thus freeing-up the memory it occupied. | |
1550 */ | |
1551 if (menu) | |
1552 gtk_widget_destroy(menu); | |
1553 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1554 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1555 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1556 |
8143 | 1557 menu = gtk_menu_new(); |
1558 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1559 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1560 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1561 G_CALLBACK(menu_chat_im_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1562 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1563 if (gc == NULL) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1564 gtk_widget_set_sensitive(button, FALSE); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1565 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1566 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
|
1567 |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1568 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1569 if (prpl_info && prpl_info->send_file) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1570 { |
11508 | 1571 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1572 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1573 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1574 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1575 if (gc == NULL || prpl_info == NULL || |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1576 !(!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1577 { |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1578 gtk_widget_set_sensitive(button, FALSE); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1579 } |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1580 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1581 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
|
1582 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1583 |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1584 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1585 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
|
1586 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
|
1587 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1588 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1589 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1590 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1591 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1592 if (gc == NULL) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1593 gtk_widget_set_sensitive(button, FALSE); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1594 |
10504 | 1595 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1596 } |
9498 | 1597 |
13445 | 1598 if (prpl_info && (prpl_info->get_info || prpl_info->get_cb_info)) { |
10221 | 1599 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
|
1600 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1601 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1602 if (gc == NULL) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1603 gtk_widget_set_sensitive(button, FALSE); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1604 |
10504 | 1605 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1606 } |
1607 | |
13445 | 1608 if (prpl_info && prpl_info->get_cb_away) { |
10221 | 1609 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
|
1610 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1611 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1612 if (gc == NULL) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1613 gtk_widget_set_sensitive(button, FALSE); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1614 |
10504 | 1615 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1616 } |
1617 | |
13457
1eed4ec0912d
[gaim-migrate @ 15832]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13445
diff
changeset
|
1618 if (!is_me && prpl_info && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1619 if (gaim_find_buddy(conv->account, who)) |
10221 | 1620 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
|
1621 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1622 else |
10221 | 1623 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
|
1624 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1625 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1626 if (gc == NULL) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1627 gtk_widget_set_sensitive(button, FALSE); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1628 |
10504 | 1629 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1630 } |
1631 | |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1632 button = gaim_new_item_from_stock(menu, _("Last said"), GTK_STOCK_INDEX, |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1633 G_CALLBACK(menu_last_said_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1634 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1635 if (!get_mark_for_user(GAIM_GTK_CONVERSATION(conv), who)) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1636 gtk_widget_set_sensitive(button, FALSE); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1637 |
8143 | 1638 return menu; |
1639 } | |
1640 | |
1641 | |
1642 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1643 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1644 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1645 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1646 GaimGtkChatPane *gtkchat; |
1647 GaimConnection *gc; | |
1648 GaimAccount *account; | |
1649 GtkTreeSelection *sel; | |
1650 GtkTreeIter iter; | |
1651 GtkTreeModel *model; | |
1652 GtkWidget *menu; | |
1653 gchar *who; | |
1654 | |
1655 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1656 gtkchat = gtkconv->u.chat; | |
1657 account = gaim_conversation_get_account(conv); | |
1658 gc = account->gc; | |
1659 | |
1660 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1661 | |
1662 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1663 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1664 return FALSE; | |
1665 | |
9498 | 1666 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1667 menu = create_chat_menu (conv, who, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1668 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1669 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1670 0, GDK_CURRENT_TIME); |
10504 | 1671 g_free(who); |
8143 | 1672 |
1673 return TRUE; | |
1674 } | |
1675 | |
1676 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1677 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1678 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1679 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1680 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1681 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1682 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1683 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1684 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1685 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1686 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1687 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1688 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1689 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1690 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1691 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1692 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1693 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1694 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1695 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1696 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1697 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1698 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
|
1699 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1700 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1701 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1702 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1703 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1704 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1705 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1706 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1707 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1708 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
|
1709 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1710 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1711 chat_do_im(gtkconv, who); |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1712 } else if (event->button == 2 && event->type == GDK_BUTTON_PRESS) { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1713 /* Move to user's anchor */ |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1714 GtkTextMark *mark = get_mark_for_user(gtkconv, who); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1715 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1716 if(mark != NULL) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1717 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(gtkconv->imhtml), mark, 0.1, FALSE, 0, 0); |
7398 | 1718 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1719 GtkWidget *menu = create_chat_menu (conv, who, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1720 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1721 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1722 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1723 |
10504 | 1724 g_free(who); |
1725 gtk_tree_path_free(path); | |
1726 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1727 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1728 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1729 |
8133 | 1730 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1731 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1732 { |
10827 | 1733 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1734 GaimGtkWindow *win; |
13714
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1735 int initial, i, total, diff; |
8133 | 1736 |
11581 | 1737 win = gtkconv->win; |
13714
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1738 initial = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1739 gtkconv->tab_cont); |
11581 | 1740 total = gaim_gtk_conv_window_get_gtkconv_count(win); |
13714
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1741 /* By adding total here, the moduli calculated later will always have two |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1742 * positive arguments. x % y where x < 0 is not guaranteed to return a |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1743 * positive number. |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1744 */ |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1745 diff = (forward ? 1 : -1) + total; |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1746 |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1747 for (i = (initial + diff) % total; i != initial; i = (i + diff) % total) { |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1748 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1749 if (next_gtkconv->unseen_state > 0) |
13714
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1750 break; |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1751 } |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1752 |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1753 if (i == initial) { /* no new messages */ |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1754 i = (i + diff) % total; |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1755 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i); |
8133 | 1756 } |
1757 | |
10827 | 1758 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1759 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1760 } |
1761 | |
4359 | 1762 static gboolean |
8105 | 1763 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1764 { |
11581 | 1765 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1766 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1767 GaimGtkConversation *gtkconv; |
8105 | 1768 int curconv; |
1769 | |
10810 | 1770 gtkconv = (GaimGtkConversation *)data; |
10849 | 1771 conv = gtkconv->active_conv; |
11581 | 1772 win = gtkconv->win; |
1773 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1774 |
8105 | 1775 /* If CTRL was held down... */ |
1776 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1777 switch (event->keyval) { |
1778 case GDK_Up: | |
1779 if (!conv->send_history) | |
1780 break; | |
1781 | |
1782 if (!conv->send_history->prev) { | |
1783 GtkTextIter start, end; | |
1784 | |
1785 if (conv->send_history->data) | |
1786 g_free(conv->send_history->data); | |
1787 | |
1788 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1789 &start); | |
1790 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1791 | |
1792 conv->send_history->data = | |
8506 | 1793 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1794 } |
8677 | 1795 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1796 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1797 GObject *object; |
8677 | 1798 GtkTextIter iter; |
1799 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1800 |
1801 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1802 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1803 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1804 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1805 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
|
1806 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1807 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1808 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1809 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1810 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
|
1811 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1812 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1813 |
8061 | 1814 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1815 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1816 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1817 0, NULL); |
8677 | 1818 /* this is mainly just a hack so the formatting at the |
1819 * cursor gets picked up. */ | |
1820 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1821 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1822 } |
1823 | |
8105 | 1824 return TRUE; |
4359 | 1825 break; |
1826 | |
1827 case GDK_Down: | |
1828 if (!conv->send_history) | |
1829 break; | |
1830 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1831 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1832 GObject *object; |
8677 | 1833 GtkTextIter iter; |
1834 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1835 |
4359 | 1836 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1837 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1838 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1839 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1840 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
|
1841 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1842 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1843 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1844 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1845 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
|
1846 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1847 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1848 |
8105 | 1849 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1850 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1851 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1852 0, NULL); |
8677 | 1853 /* this is mainly just a hack so the formatting at the |
1854 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1855 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1856 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1857 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1858 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1859 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1860 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1861 } |
4359 | 1862 } |
1863 | |
8105 | 1864 return TRUE; |
4359 | 1865 break; |
8105 | 1866 |
13354
da2179c099f0
[gaim-migrate @ 15726]
Richard Laager <rlaager@wiktel.com>
parents:
13352
diff
changeset
|
1867 case GDK_Page_Down: |
8143 | 1868 case ']': |
11581 | 1869 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1870 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1871 else |
11581 | 1872 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1873 return TRUE; |
1874 break; | |
1875 | |
13354
da2179c099f0
[gaim-migrate @ 15726]
Richard Laager <rlaager@wiktel.com>
parents:
13352
diff
changeset
|
1876 case GDK_Page_Up: |
8143 | 1877 case '[': |
11581 | 1878 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1879 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1880 else |
11581 | 1881 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1882 return TRUE; |
1883 break; | |
1884 | |
8108 | 1885 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1886 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1887 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1888 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1889 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1890 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1891 } |
8108 | 1892 |
1893 return TRUE; | |
1894 break; | |
1895 | |
11252 | 1896 case GDK_comma: |
11581 | 1897 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1898 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1899 curconv - 1); |
1900 break; | |
1901 | |
1902 case GDK_period: | |
11581 | 1903 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1904 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1905 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1906 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1907 #else |
1908 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1909 #endif | |
11252 | 1910 break; |
1911 | |
8105 | 1912 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1913 } |
8758 | 1914 |
8105 | 1915 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1916 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1917 { |
10864 | 1918 if (event->keyval > '0' && event->keyval <= '9') |
1919 { | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1920 guint switchto = event->keyval - '1'; |
11581 | 1921 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1922 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1923 |
1924 return TRUE; | |
1925 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1926 } |
8758 | 1927 |
8105 | 1928 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1929 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1930 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1931 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1932 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1933 case GDK_Tab: |
9605 | 1934 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1935 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1936 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1937 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1938 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1939 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1940 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1941 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1942 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1943 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1944 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1945 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1946 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1947 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1948 } |
4359 | 1949 return FALSE; |
1950 } | |
1951 | |
1952 /* | |
1953 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1954 * 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
|
1955 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1956 * 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
|
1957 * going all the way down to the notebook. I suspect a bug in |
4359 | 1958 * GtkTextView, but I'm not ready to point any fingers yet. |
1959 */ | |
1960 static gboolean | |
1961 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1962 { | |
1963 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1964 /* Right single click */ | |
1965 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1966 | |
1967 return TRUE; | |
1968 } | |
1969 | |
1970 return FALSE; | |
1971 } | |
1972 | |
8173 | 1973 /* |
1974 * If someone tries to type into the conversation backlog of a | |
1975 * conversation window then we yank focus from the conversation backlog | |
1976 * and give it to the text entry box so that people can type | |
1977 * all the live long day and it will get entered into the entry box. | |
1978 */ | |
6057 | 1979 static gboolean |
8105 | 1980 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1981 { |
1982 GaimGtkConversation *gtkconv = data; | |
1983 | |
8237 | 1984 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1985 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1986 (event->keyval == GDK_F10) || |
1987 (event->keyval == GDK_Shift_L) || | |
1988 (event->keyval == GDK_Shift_R) || | |
1989 (event->keyval == GDK_Escape) || | |
8177 | 1990 (event->keyval == GDK_Up) || |
1991 (event->keyval == GDK_Down) || | |
1992 (event->keyval == GDK_Left) || | |
8191 | 1993 (event->keyval == GDK_Right) || |
1994 (event->keyval == GDK_Home) || | |
9297 | 1995 (event->keyval == GDK_End) || |
1996 (event->keyval == GDK_Tab) || | |
1997 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1998 return FALSE; |
1999 | |
2000 if (event->type == GDK_KEY_RELEASE) | |
2001 gtk_widget_grab_focus(gtkconv->entry); | |
2002 | |
2003 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
2004 | |
2005 return TRUE; | |
6057 | 2006 } |
2007 | |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
2008 void |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
2009 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2010 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2011 GaimGtkConversation *gtkconv; |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2012 GaimConversation *old_conv; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2013 GtkIMHtml *entry; |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2014 const char *protocol_name; |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2015 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2016 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2017 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2018 gtkconv = GAIM_GTK_CONVERSATION(conv); |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2019 old_conv = gtkconv->active_conv; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2020 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2021 if (old_conv == conv) |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2022 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2023 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2024 gaim_conversation_close_logs(old_conv); |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2025 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2026 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2027 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2028 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
|
2029 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2030 entry = GTK_IMHTML(gtkconv->entry); |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2031 protocol_name = gaim_account_get_protocol_name(conv->account); |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2032 gtk_imhtml_set_protocol_name(entry, protocol_name); |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2033 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol_name); |
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2034 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2035 if (!(conv->features & GAIM_CONNECTION_HTML)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2036 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2037 else if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO && |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2038 !(old_conv->features & GAIM_CONNECTION_FORMATTING_WBFO)) |
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 /* The old conversation allowed formatting on parts of the |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2041 * buffer, but the new one only allows it on the whole |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2042 * buffer. This code saves the formatting from the current |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2043 * position of the cursor, clears the formatting, then |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2044 * applies the saved formatting to the entire buffer. */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2045 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2046 gboolean bold; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2047 gboolean italic; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2048 gboolean underline; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2049 char *fontface = gtk_imhtml_get_current_fontface(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2050 char *forecolor = gtk_imhtml_get_current_forecolor(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2051 char *backcolor = gtk_imhtml_get_current_backcolor(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2052 char *background = gtk_imhtml_get_current_background(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2053 gint fontsize = gtk_imhtml_get_current_fontsize(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2054 gboolean bold2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2055 gboolean italic2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2056 gboolean underline2; |
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_get_current_format(entry, &bold, &italic, &underline); |
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 /* Clear existing formatting */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2061 gtk_imhtml_clear_formatting(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2062 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2063 /* Apply saved formatting to the whole buffer. */ |
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 gtk_imhtml_get_current_format(entry, &bold2, &italic2, &underline2); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2066 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2067 if (bold != bold2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2068 gtk_imhtml_toggle_bold(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2069 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2070 if (italic != italic2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2071 gtk_imhtml_toggle_italic(entry); |
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 if (underline != underline2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2074 gtk_imhtml_toggle_underline(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2075 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2076 gtk_imhtml_toggle_fontface(entry, fontface); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2077 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2078 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2079 gtk_imhtml_font_set_size(entry, fontsize); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2080 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2081 gtk_imhtml_toggle_forecolor(entry, forecolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2082 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2083 if (!(conv->features & GAIM_CONNECTION_NO_BGCOLOR)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2084 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2085 gtk_imhtml_toggle_backcolor(entry, backcolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2086 gtk_imhtml_toggle_background(entry, background); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2087 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2088 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2089 g_free(fontface); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2090 g_free(forecolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2091 g_free(backcolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2092 g_free(background); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2093 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2094 else |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2095 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2096 /* 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
|
2097 * 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
|
2098 * 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
|
2099 * 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
|
2100 gtk_imhtml_set_whole_buffer_formatting_only(entry, |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2101 (conv->features & GAIM_CONNECTION_FORMATTING_WBFO)); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2102 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2103 |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
2104 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-switched", conv); |
11604 | 2105 |
2106 gray_stuff_out(gtkconv); | |
2107 update_typing_icon(gtkconv); | |
2108 | |
2109 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
2110 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
2111 } | |
2112 | |
2113 static void | |
4673 | 2114 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 2115 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2116 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 2117 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2118 GaimConversation *conv; |
4359 | 2119 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2120 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2121 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2122 |
11594 | 2123 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 2124 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 2125 } |
2126 | |
2127 static void | |
2128 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
2129 gchar *new_text, gint new_text_length, gpointer user_data) | |
2130 { | |
10810 | 2131 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2132 GaimConversation *conv; | |
2133 | |
2134 g_return_if_fail(gtkconv != NULL); | |
11508 | 2135 |
10810 | 2136 conv = gtkconv->active_conv; |
4359 | 2137 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2138 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2139 return; |
2140 | |
10810 | 2141 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2142 gtk_text_iter_is_end(position))); | |
4359 | 2143 } |
2144 | |
2145 static void | |
2146 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2147 GtkTextIter *end_pos, gpointer user_data) | |
2148 { | |
10810 | 2149 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2150 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2151 GaimConvIm *im; |
4359 | 2152 |
10810 | 2153 g_return_if_fail(gtkconv != NULL); |
11508 | 2154 |
10810 | 2155 conv = gtkconv->active_conv; |
4359 | 2156 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2157 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2158 return; |
2159 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2160 im = GAIM_CONV_IM(conv); |
4359 | 2161 |
2162 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2163 | |
2164 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2165 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2166 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2167 |
2168 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2169 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2170 GAIM_NOT_TYPING); |
4359 | 2171 } |
2172 else { | |
2173 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2174 got_typing_keypress(gtkconv, FALSE); |
4359 | 2175 } |
2176 } | |
2177 | |
8189 | 2178 /************************************************************************** |
2179 * A bunch of buddy icon functions | |
2180 **************************************************************************/ | |
11581 | 2181 GdkPixbuf * |
2182 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2183 { |
10116 | 2184 GaimAccount *account = NULL; |
2185 const char *name = NULL; | |
7143 | 2186 GdkPixbuf *status = NULL; |
2187 | |
10116 | 2188 g_return_val_if_fail(conv != NULL, NULL); |
2189 | |
2190 account = gaim_conversation_get_account(conv); | |
2191 name = gaim_conversation_get_name(conv); | |
2192 | |
2193 g_return_val_if_fail(account != NULL, NULL); | |
2194 g_return_val_if_fail(name != NULL, NULL); | |
2195 | |
13090 | 2196 /* Use the buddy icon, if possible */ |
11338 | 2197 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2198 GaimBuddy *b = gaim_find_buddy(account, name); |
2199 if (b != NULL) { | |
2200 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2201 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2202 } |
2203 } | |
2204 | |
13090 | 2205 /* If they don't have a buddy icon, then use the PRPL icon */ |
2206 if (status == NULL) | |
2207 status = gaim_gtk_create_prpl_icon(account, small_icon ? 0.5 : 1.0); | |
2208 | |
7143 | 2209 return status; |
2210 } | |
2211 | |
8189 | 2212 static void |
2213 update_tab_icon(GaimConversation *conv) | |
2214 { | |
2215 GaimGtkConversation *gtkconv; | |
11581 | 2216 GaimGtkWindow *win; |
8189 | 2217 GdkPixbuf *status = NULL; |
2218 | |
10116 | 2219 g_return_if_fail(conv != NULL); |
2220 | |
8189 | 2221 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2222 win = gtkconv->win; |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2223 if (conv != gtkconv->active_conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2224 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2225 |
11581 | 2226 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2227 |
10116 | 2228 g_return_if_fail(status != NULL); |
2229 | |
8189 | 2230 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2231 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2232 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2233 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2234 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2235 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2236 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2237 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2238 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2239 { |
11581 | 2240 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2241 | |
2242 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2243 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2244 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2245 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2246 } |
8189 | 2247 } |
2248 | |
2249 static gboolean | |
2250 redraw_icon(gpointer data) | |
2251 { | |
10810 | 2252 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2253 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2254 GaimAccount *account; |
2255 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2256 |
2257 GdkPixbuf *buf; | |
2258 GdkPixbuf *scale; | |
2259 gint delay; | |
9318 | 2260 int scale_width, scale_height; |
8189 | 2261 |
2262 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2263 account = gaim_conversation_get_account(conv); |
2264 if(account && account->gc) | |
2265 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2266 |
2267 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2268 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2269 | |
10483 | 2270 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2271 NULL, &scale_width, &scale_height); |
2272 | |
2273 /* this code is ugly, and scares me */ | |
8189 | 2274 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2275 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2276 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2277 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2278 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2279 GDK_INTERP_BILINEAR); |
8189 | 2280 |
13690
6a86f4ec744e
[gaim-migrate @ 16093]
Richard Laager <rlaager@wiktel.com>
parents:
13663
diff
changeset
|
2281 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->u.im->icon), scale); |
8189 | 2282 g_object_unref(G_OBJECT(scale)); |
2283 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2284 | |
9131 | 2285 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2286 |
2287 if (delay < 100) | |
9131 | 2288 delay = 100; |
2289 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2290 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2291 |
2292 return FALSE; | |
2293 } | |
2294 | |
2295 static void | |
10810 | 2296 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2297 { |
2298 int delay; | |
2299 | |
8228 | 2300 if (gtkconv->u.im->anim == NULL) |
2301 return; | |
2302 | |
8202 | 2303 if (gtkconv->u.im->icon_timer != 0) |
2304 return; | |
2305 | |
8189 | 2306 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2307 return; | |
2308 | |
10639 | 2309 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2310 | |
2311 if (delay < 100) | |
2312 delay = 100; | |
2313 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2314 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2315 } |
2316 | |
2317 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2318 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2319 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2320 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2321 GaimGtkWindow *gtkwin; |
2322 | |
2323 g_return_if_fail(conv != NULL); | |
2324 | |
9887 | 2325 if (gtkconv->u.im->icon_container != NULL) |
2326 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2327 |
2328 if (gtkconv->u.im->anim != NULL) | |
2329 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2330 | |
2331 if (gtkconv->u.im->icon_timer != 0) | |
2332 g_source_remove(gtkconv->u.im->icon_timer); | |
2333 | |
2334 if (gtkconv->u.im->iter != NULL) | |
2335 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2336 | |
2337 gtkconv->u.im->icon_timer = 0; | |
2338 gtkconv->u.im->icon = NULL; | |
2339 gtkconv->u.im->anim = NULL; | |
2340 gtkconv->u.im->iter = NULL; | |
10456 | 2341 gtkconv->u.im->icon_container = NULL; |
9687 | 2342 gtkconv->u.im->show_icon = FALSE; |
10456 | 2343 |
11581 | 2344 gtkwin = gtkconv->win; |
10456 | 2345 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2346 } |
2347 | |
9497 | 2348 static void |
9504 | 2349 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2350 { |
10810 | 2351 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2352 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2353 FILE *fp; |
2354 GaimBuddyIcon *icon; | |
2355 const void *data; | |
2356 size_t len; | |
2357 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2358 if ((fp = g_fopen(filename, "wb")) == NULL) { |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
2359 gaim_notify_error(gtkconv, NULL, _("Unable to open file."), NULL); |
9497 | 2360 return; |
2361 } | |
2362 | |
2363 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2364 data = gaim_buddy_icon_get_data(icon, &len); | |
2365 | |
2366 if ((len <= 0) || (data == NULL)) { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
2367 gaim_notify_error(gtkconv, NULL, _("Unable to save icon file to disk."), NULL); |
13405 | 2368 fclose(fp); |
9497 | 2369 return; |
2370 } | |
2371 | |
2372 fwrite(data, 1, len, fp); | |
2373 fclose(fp); | |
2374 } | |
2375 | |
2376 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2377 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2378 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2379 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2380 const gchar *ext; |
9497 | 2381 gchar *buf; |
2382 | |
2383 g_return_if_fail(conv != NULL); | |
9504 | 2384 |
10953 | 2385 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2386 if (ext == NULL) | |
2387 ext = "icon"; | |
2388 | |
2389 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2390 |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
2391 gaim_request_file(gtkconv, _("Save Icon"), buf, TRUE, |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2392 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2393 |
2394 g_free(buf); | |
2395 } | |
2396 | |
11581 | 2397 static void |
2398 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2399 { | |
2400 if (gtkconv->u.im->icon_timer != 0) | |
2401 g_source_remove(gtkconv->u.im->icon_timer); | |
2402 | |
2403 gtkconv->u.im->icon_timer = 0; | |
2404 } | |
2405 | |
2406 | |
2407 static void | |
2408 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2409 { | |
2410 gtkconv->u.im->animate = | |
2411 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2412 | |
2413 if (gtkconv->u.im->animate) | |
2414 start_anim(NULL, gtkconv); | |
2415 else | |
2416 stop_anim(NULL, gtkconv); | |
2417 } | |
2418 | |
8189 | 2419 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2420 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2421 { |
2422 static GtkWidget *menu = NULL; | |
13570
41e4b22c0afb
[gaim-migrate @ 15949]
Richard Laager <rlaager@wiktel.com>
parents:
13536
diff
changeset
|
2423 GtkWidget *item; |
8189 | 2424 |
2425 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2426 return FALSE; | |
2427 | |
2428 /* | |
2429 * If a menu already exists, destroy it before creating a new one, | |
2430 * thus freeing-up the memory it occupied. | |
2431 */ | |
2432 if (menu != NULL) | |
2433 gtk_widget_destroy(menu); | |
2434 | |
2435 menu = gtk_menu_new(); | |
2436 | |
2437 if (gtkconv->u.im->anim && | |
2438 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2439 { | |
2440 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2441 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2442 gtkconv->u.im->icon_timer); |
2443 } | |
2444 | |
13570
41e4b22c0afb
[gaim-migrate @ 15949]
Richard Laager <rlaager@wiktel.com>
parents:
13536
diff
changeset
|
2445 item = gtk_menu_item_new_with_label(_("Hide Icon")); |
41e4b22c0afb
[gaim-migrate @ 15949]
Richard Laager <rlaager@wiktel.com>
parents:
13536
diff
changeset
|
2446 g_signal_connect_swapped(G_OBJECT(item), "activate", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2447 G_CALLBACK(remove_icon), gtkconv); |
13570
41e4b22c0afb
[gaim-migrate @ 15949]
Richard Laager <rlaager@wiktel.com>
parents:
13536
diff
changeset
|
2448 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
41e4b22c0afb
[gaim-migrate @ 15949]
Richard Laager <rlaager@wiktel.com>
parents:
13536
diff
changeset
|
2449 gtk_widget_show(item); |
8189 | 2450 |
2451 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
|
2452 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2453 0, 0, NULL); |
2454 | |
2455 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2456 | |
2457 return TRUE; | |
2458 } | |
10456 | 2459 |
2460 static void | |
2461 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2462 { | |
11581 | 2463 GaimGtkWindow *win = data; |
10456 | 2464 GaimConversation *conv; |
2465 GaimGtkConversation *gtkconv; | |
2466 gboolean active; | |
2467 | |
11581 | 2468 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2469 |
2470 if (!conv) | |
2471 return; | |
2472 | |
11338 | 2473 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2474 |
2475 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2476 | |
2477 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2478 gtkconv->u.im->show_icon = active; | |
2479 if (active) | |
2480 gaim_gtkconv_update_buddy_icon(conv); | |
2481 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2482 remove_icon(gtkconv); |
10456 | 2483 } |
2484 | |
8189 | 2485 /************************************************************************** |
2486 * End of the bunch of buddy icon functions | |
2487 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2488 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2489 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2490 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2491 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2492 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2493 if(gtkconv->win==hidden_convwin) { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
2494 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2495 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2496 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2497 |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
2498 gaim_gtkconv_switch_active_conversation(conv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2499 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2500 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2501 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2502 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2503 GList * |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2504 gaim_gtk_conversations_find_unseen_list(GaimConversationType type, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2505 GaimUnseenState min_state, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2506 gboolean hidden_only, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2507 guint max_count) |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2508 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2509 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2510 GList *r = NULL; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2511 guint c = 0; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2512 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2513 if (type == GAIM_CONV_TYPE_IM) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2514 l = gaim_get_ims(); |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2515 } else if (type == GAIM_CONV_TYPE_CHAT) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2516 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2517 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2518 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2519 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2520 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2521 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
|
2522 GaimConversation *conv = (GaimConversation*)l->data; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2523 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2524 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2525 if(gtkconv->active_conv != conv) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2526 continue; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2527 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2528 if (gtkconv->unseen_state >= min_state |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2529 && (!hidden_only || |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2530 (hidden_only && gtkconv->win == hidden_convwin))) { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2531 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2532 r = g_list_prepend(r, conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2533 c++; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2534 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2535 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2536 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2537 return r; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2538 } |
8189 | 2539 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2540 static void |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2541 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2542 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2543 g_return_if_fail(conv != NULL); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2544 gaim_gtkconv_present_conversation(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2545 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2546 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2547 guint |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2548 gaim_gtk_conversations_fill_menu(GtkWidget *menu, GList *convs) |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2549 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2550 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2551 guint ret=0; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2552 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2553 g_return_val_if_fail(menu != NULL, 0); |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2554 g_return_val_if_fail(convs != NULL, 0); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2555 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2556 for (l = convs; l != NULL ; l = l->next) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2557 GaimConversation *conv = (GaimConversation*)l->data; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2558 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2559 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2560 GtkWidget *icon = gtk_image_new(); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2561 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2562 GtkWidget *item; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2563 gchar *text = g_strdup_printf("%s (%d)", |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2564 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2565 gtkconv->unseen_count); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2566 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2567 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2568 g_object_unref(pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2569 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2570 item = gtk_image_menu_item_new_with_label(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2571 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
|
2572 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
|
2573 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2574 g_free(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2575 ret++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2576 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2577 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2578 return ret; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2579 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2580 |
11581 | 2581 GaimGtkWindow * |
2582 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2583 { | |
2584 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2585 return gtkconv->win; | |
2586 } | |
2587 | |
2588 static GtkItemFactoryEntry menu_items[] = | |
2589 { | |
2590 /* Conversation menu */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2591 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>", NULL }, |
11581 | 2592 |
2593 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2594 0, "<StockItem>", GAIM_STOCK_IM }, | |
2595 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2596 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2597 |
2598 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2599 "<StockItem>", GTK_STOCK_FIND }, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2600 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", GAIM_STOCK_LOG }, |
11581 | 2601 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2602 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
12897
e9b0c90ce58a
[gaim-migrate @ 15250]
Richard Laager <rlaager@wiktel.com>
parents:
12867
diff
changeset
|
2603 { N_("/Conversation/Clea_r Scrollback"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
11581 | 2604 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2605 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2606 |
2607 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2608 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2609 0, "<StockItem>", GAIM_STOCK_POUNCE }, |
11581 | 2610 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2611 "<StockItem>", GAIM_STOCK_INFO }, | |
2612 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2613 "<StockItem>", GAIM_STOCK_INVITE }, | |
2614 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2615 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2616 |
2617 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2618 "<StockItem>", GAIM_STOCK_EDIT }, | |
2619 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2620 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2621 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2622 "<StockItem>", GTK_STOCK_ADD }, | |
2623 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2624 "<StockItem>", GTK_STOCK_REMOVE }, | |
2625 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2626 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2627 |
2628 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2629 "<StockItem>", GAIM_STOCK_LINK }, | |
2630 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2631 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2632 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2633 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2634 |
2635 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2636 "<StockItem>", GTK_STOCK_CLOSE }, | |
2637 | |
2638 /* Options */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2639 { N_("/_Options"), NULL, NULL, 0, "<Branch>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2640 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2641 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2642 { 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
|
2643 { "/Options/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2644 { 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
|
2645 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>", NULL }, |
11581 | 2646 }; |
2647 | |
2648 static const int menu_item_count = | |
2649 sizeof(menu_items) / sizeof(*menu_items); | |
2650 | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2651 static const char * |
11581 | 2652 item_factory_translate_func (const char *path, gpointer func_data) |
2653 { | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2654 return _(path); |
11581 | 2655 } |
2656 | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2657 static void |
12816 | 2658 sound_method_pref_changed_cb(const char *name, GaimPrefType type, |
2659 gconstpointer value, gpointer data) | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2660 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2661 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2662 const char *method = value; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2663 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2664 if (!strcmp(method, "none")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2665 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2666 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
|
2667 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2668 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
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 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2671 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2672 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2673 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2674 if (gtkconv != NULL) |
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 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2677 gtk_widget_set_sensitive(win->menu.sounds, TRUE); |
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 } |
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 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2682 static void |
12816 | 2683 show_buddy_icons_pref_changed_cb(const char *name, GaimPrefType type, |
2684 gconstpointer value, gpointer data) | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2685 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2686 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2687 gboolean show_icons = GPOINTER_TO_INT(value); |
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 if (!show_icons) |
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 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
|
2692 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2693 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
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 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2696 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2697 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2698 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2699 if (gtkconv != NULL) |
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 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2702 gtk_widget_set_sensitive(win->menu.show_icon, TRUE); |
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 } |
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 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2707 |
11581 | 2708 static GtkWidget * |
2709 setup_menubar(GaimGtkWindow *win) | |
2710 { | |
2711 GtkAccelGroup *accel_group; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2712 const char *method; |
11581 | 2713 |
2714 accel_group = gtk_accel_group_new (); | |
2715 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2716 g_object_unref(accel_group); | |
2717 | |
2718 win->menu.item_factory = | |
2719 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2720 | |
2721 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2722 (GtkTranslateFunc)item_factory_translate_func, |
11581 | 2723 NULL, NULL); |
2724 | |
2725 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2726 menu_items, win); | |
2727 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2728 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2729 | |
2730 | |
2731 win->menu.menubar = | |
2732 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2733 | |
2734 | |
2735 win->menu.view_log = | |
2736 gtk_item_factory_get_widget(win->menu.item_factory, | |
2737 N_("/Conversation/View Log")); | |
2738 | |
2739 /* --- */ | |
2740 | |
2741 win->menu.send_file = | |
2742 gtk_item_factory_get_widget(win->menu.item_factory, | |
2743 N_("/Conversation/Send File...")); | |
2744 | |
2745 win->menu.add_pounce = | |
2746 gtk_item_factory_get_widget(win->menu.item_factory, | |
2747 N_("/Conversation/Add Buddy Pounce...")); | |
2748 | |
2749 /* --- */ | |
2750 | |
2751 win->menu.get_info = | |
2752 gtk_item_factory_get_widget(win->menu.item_factory, | |
2753 N_("/Conversation/Get Info")); | |
2754 | |
2755 win->menu.invite = | |
2756 gtk_item_factory_get_widget(win->menu.item_factory, | |
2757 N_("/Conversation/Invite...")); | |
2758 | |
2759 /* --- */ | |
2760 | |
2761 win->menu.alias = | |
2762 gtk_item_factory_get_widget(win->menu.item_factory, | |
2763 N_("/Conversation/Alias...")); | |
2764 | |
2765 win->menu.block = | |
2766 gtk_item_factory_get_widget(win->menu.item_factory, | |
2767 N_("/Conversation/Block...")); | |
2768 | |
2769 win->menu.add = | |
2770 gtk_item_factory_get_widget(win->menu.item_factory, | |
2771 N_("/Conversation/Add...")); | |
2772 | |
2773 win->menu.remove = | |
2774 gtk_item_factory_get_widget(win->menu.item_factory, | |
2775 N_("/Conversation/Remove...")); | |
2776 | |
2777 /* --- */ | |
2778 | |
2779 win->menu.insert_link = | |
2780 gtk_item_factory_get_widget(win->menu.item_factory, | |
2781 N_("/Conversation/Insert Link...")); | |
2782 | |
2783 win->menu.insert_image = | |
2784 gtk_item_factory_get_widget(win->menu.item_factory, | |
2785 N_("/Conversation/Insert Image...")); | |
2786 | |
2787 /* --- */ | |
2788 | |
2789 win->menu.logging = | |
2790 gtk_item_factory_get_widget(win->menu.item_factory, | |
2791 N_("/Options/Enable Logging")); | |
2792 win->menu.sounds = | |
2793 gtk_item_factory_get_widget(win->menu.item_factory, | |
2794 N_("/Options/Enable Sounds")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2795 method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2796 if (!strcmp(method, "none")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2797 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2798 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
|
2799 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2800 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2801 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2802 gaim_prefs_connect_callback(win, "/gaim/gtk/sound/method", |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2803 sound_method_pref_changed_cb, win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2804 |
11581 | 2805 win->menu.show_formatting_toolbar = |
2806 gtk_item_factory_get_widget(win->menu.item_factory, | |
2807 N_("/Options/Show Formatting Toolbars")); | |
2808 win->menu.show_timestamps = | |
2809 gtk_item_factory_get_widget(win->menu.item_factory, | |
2810 N_("/Options/Show Timestamps")); | |
2811 win->menu.show_icon = | |
2812 gtk_item_factory_get_widget(win->menu.item_factory, | |
2813 N_("/Options/Show Buddy Icon")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2814 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
|
2815 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2816 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
|
2817 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2818 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2819 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2820 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
|
2821 show_buddy_icons_pref_changed_cb, win); |
11581 | 2822 |
2823 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2824 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2825 win->menu.tray); | |
2826 gtk_widget_show(win->menu.tray); | |
2827 | |
2828 gtk_widget_show(win->menu.menubar); | |
2829 | |
2830 return win->menu.menubar; | |
2831 } | |
2832 | |
4359 | 2833 |
2834 /************************************************************************** | |
2835 * Utility functions | |
2836 **************************************************************************/ | |
2837 | |
2838 static void | |
10810 | 2839 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2840 { |
10810 | 2841 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2842 GaimConvIm *im; |
4685 | 2843 |
4359 | 2844 /* |
2845 * 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
|
2846 * send GAIM_TYPED any time soon. |
4359 | 2847 */ |
2848 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2849 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2850 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2851 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2852 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2853 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2854 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2855 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2856 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2857 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2858 |
2859 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2860 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2861 GAIM_TYPING); |
4359 | 2862 |
2863 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2864 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2865 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2866 gaim_conv_im_set_type_again(im, 0); |
4359 | 2867 } |
2868 } | |
2869 | |
4736 | 2870 static void |
10810 | 2871 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2872 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2873 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2874 GaimConvIm *im = NULL; |
10810 | 2875 GaimConversation *conv = gtkconv->active_conv; |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2876 char *stock_id; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2877 const char *tooltip; |
11508 | 2878 |
11581 | 2879 gtkwin = gtkconv->win; |
4736 | 2880 |
12008 | 2881 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2882 im = GAIM_CONV_IM(conv); |
4736 | 2883 |
12008 | 2884 if (gtkwin->menu.typing_icon) { |
2885 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2886 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2887 |
12008 | 2888 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2889 return; | |
2890 | |
2891 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2892 stock_id = GAIM_STOCK_TYPING; | |
2893 tooltip = _("User is typing..."); | |
2894 } else { | |
2895 stock_id = GAIM_STOCK_TYPED; | |
2896 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2897 } |
12008 | 2898 |
2899 if (gtkwin->menu.typing_icon == NULL) | |
2900 { | |
2901 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
|
2902 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
|
2903 gtkwin->menu.typing_icon, |
12008 | 2904 tooltip); |
4736 | 2905 } |
12008 | 2906 else |
2907 { | |
2908 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2909 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2910 gtkwin->menu.typing_icon, | |
2911 tooltip); | |
2912 } | |
2913 | |
2914 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2915 } |
2916 | |
4685 | 2917 static gboolean |
11594 | 2918 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2919 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2920 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2921 GaimConversation *conv; |
4359 | 2922 GtkWidget *menu; |
2923 GList *child; | |
11594 | 2924 GaimBuddy *b; |
11581 | 2925 |
2926 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2927 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2928 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2929 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2930 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2931 account = gaim_conversation_get_account(conv); |
11581 | 2932 |
13131 | 2933 if (account == NULL) |
2934 return FALSE; | |
2935 | |
11594 | 2936 if (win->menu.send_to == NULL) |
4685 | 2937 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2938 |
11594 | 2939 if (!(b = gaim_find_buddy(account, conv->name))) |
2940 return FALSE; | |
2941 | |
2942 | |
2943 gtk_widget_show(win->menu.send_to); | |
4359 | 2944 |
2945 menu = gtk_menu_item_get_submenu( | |
11594 | 2946 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2947 |
2948 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2949 child != NULL; | |
2950 child = child->next) { | |
2951 | |
2952 GtkWidget *item = child->data; | |
11594 | 2953 GaimBuddy *item_buddy; |
2954 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2955 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2956 "gaim_buddy_name"); | |
2957 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2958 | |
2959 if (b == item_buddy) { | |
4359 | 2960 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2961 break; | |
2962 } | |
2963 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2964 |
4685 | 2965 return FALSE; |
4359 | 2966 } |
2967 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2968 static gboolean |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2969 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
|
2970 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2971 gtk_widget_set_sensitive(GTK_WIDGET(label), TRUE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2972 return FALSE; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2973 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2974 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2975 static gboolean |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2976 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
|
2977 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2978 gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2979 return FALSE; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2980 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
2981 |
4359 | 2982 static void |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2983 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
|
2984 { |
11594 | 2985 GtkWidget *box; |
2986 GtkWidget *label; | |
2987 GtkWidget *image; | |
2988 GtkWidget *menuitem; | |
11625 | 2989 GdkPixbuf *pixbuf; |
11616 | 2990 gchar *text; |
11594 | 2991 |
2992 /* Create a pixmap for the protocol icon. */ | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2993 if (buddy != NULL) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2994 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
|
2995 else |
13090 | 2996 pixbuf = gaim_gtk_create_prpl_icon(account, 0.5); |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
2997 |
11594 | 2998 /* Now convert it to GtkImage */ |
2999 if (pixbuf == NULL) | |
3000 image = gtk_image_new(); | |
3001 else | |
13090 | 3002 { |
11625 | 3003 image = gtk_image_new_from_pixbuf(pixbuf); |
13090 | 3004 g_object_unref(G_OBJECT(pixbuf)); |
3005 } | |
11594 | 3006 |
3007 gtk_size_group_add_widget(sg, image); | |
3008 | |
3009 /* Make our menu item */ | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3010 text = g_strdup_printf("%s (%s)", name, gaim_account_get_username(account)); |
11616 | 3011 menuitem = gtk_radio_menu_item_new_with_label(*group, text); |
3012 g_free(text); | |
11594 | 3013 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
3014 | |
3015 /* Do some evil, see some evil, speak some evil. */ | |
3016 box = gtk_hbox_new(FALSE, 0); | |
3017 | |
3018 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
3019 g_object_ref(label); | |
3020 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
3021 | |
3022 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
3023 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
3024 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3025 if (buddy != NULL && |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3026 !gaim_presence_is_online(gaim_buddy_get_presence(buddy)) && |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3027 !gaim_account_supports_offline_message(account, buddy)) |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3028 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3029 gtk_widget_set_sensitive(label, FALSE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3030 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3031 /* Set the label sensitive when the menuitem is highlighted and |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3032 * insensitive again when the mouse leaves it. This way, it |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3033 * doesn't appear weird from the highlighting of the embossed |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3034 * (insensitive style) text.*/ |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3035 g_signal_connect(menuitem, "enter-notify-event", |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3036 G_CALLBACK(send_to_item_enter_notify_cb), label); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3037 g_signal_connect(menuitem, "leave-notify-event", |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3038 G_CALLBACK(send_to_item_leave_notify_cb), label); |
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 |
11594 | 3041 g_object_unref(label); |
3042 | |
3043 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
3044 | |
3045 gtk_widget_show(label); | |
3046 gtk_widget_show(image); | |
3047 gtk_widget_show(box); | |
3048 | |
3049 /* Set our data and callbacks. */ | |
3050 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3051 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(name), g_free); |
11594 | 3052 |
3053 g_signal_connect(G_OBJECT(menuitem), "activate", | |
3054 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
3055 | |
3056 gtk_widget_show(menuitem); | |
3057 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3058 } | |
3059 | |
3060 static void | |
3061 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 3062 { |
4359 | 3063 GtkWidget *menu; |
3064 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3065 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 3066 GaimGtkConversation *gtkconv; |
3067 GSList *l, *buds; | |
3068 | |
3069 g_return_if_fail(win != NULL); | |
3070 | |
3071 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
3072 | |
11604 | 3073 g_return_if_fail(gtkconv != NULL); |
3074 | |
11594 | 3075 if (win->menu.send_to != NULL) |
3076 gtk_widget_destroy(win->menu.send_to); | |
3077 | |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12272
diff
changeset
|
3078 /* Build the Send To menu */ |
11594 | 3079 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
3080 gtk_widget_show(win->menu.send_to); | |
4359 | 3081 |
3082 menu = gtk_menu_new(); | |
11581 | 3083 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 3084 win->menu.send_to, 2); |
3085 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 3086 |
3087 gtk_widget_show(menu); | |
3088 | |
11604 | 3089 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
3090 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
|
3091 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3092 if (buds == NULL) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3093 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3094 /* The user isn't on the buddy list. */ |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3095 create_sendto_item(menu, sg, &group, NULL, gtkconv->active_conv->account, gtkconv->active_conv->name); |
11604 | 3096 } |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3097 else |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3098 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3099 GList *list = NULL, *iter; |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3100 for (l = buds; l != NULL; l = l->next) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3101 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3102 GaimBlistNode *node; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3103 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3104 node = (GaimBlistNode *) gaim_buddy_get_contact((GaimBuddy *)l->data); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3105 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3106 for (node = node->child; node != NULL; node = node->next) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3107 { |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
3108 GaimBuddy *buddy = (GaimBuddy *)node; |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3109 GaimAccount *account; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3110 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3111 if (!GAIM_BLIST_NODE_IS_BUDDY(node)) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3112 continue; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3113 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3114 account = gaim_buddy_get_account(buddy); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3115 if (gaim_account_is_connected(account)) |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3116 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3117 /* Use the GaimPresence to get unique buddies. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3118 GaimPresence *presence = gaim_buddy_get_presence(buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3119 if (!g_list_find(list, presence)) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3120 list = g_list_prepend(list, presence); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3121 } |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3122 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3123 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3124 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3125 /* 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
|
3126 * since we did a g_list_prepend() earlier. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3127 for (iter = g_list_last(list); iter != NULL; iter = iter->prev) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3128 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3129 GaimPresence *pre = iter->data; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3130 GaimBuddy *buddy = gaim_presence_get_buddies(pre)->data; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3131 create_sendto_item(menu, sg, &group, buddy, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3132 gaim_buddy_get_account(buddy), gaim_buddy_get_name(buddy)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3133 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3134 g_list_free(list); |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3135 g_slist_free(buds); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3136 } |
4359 | 3137 } |
3138 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3139 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3140 |
11594 | 3141 gtk_widget_show(win->menu.send_to); |
12455 | 3142 /* TODO: This should never be insensitive. Possibly hidden or not. */ |
11594 | 3143 if (!group) |
3144 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
3145 update_send_to_selection(win); | |
4359 | 3146 } |
3147 | |
3148 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3149 generate_invite_user_names(GaimConnection *gc) |
4359 | 3150 { |
6695 | 3151 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 3152 static GList *tmp = NULL; |
3153 | |
3154 if (tmp) | |
3155 g_list_free(tmp); | |
3156 | |
3157 tmp = g_list_append(NULL, ""); | |
3158 | |
3159 if (gc != NULL) { | |
4785 | 3160 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
3161 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
3162 continue; | |
6695 | 3163 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3164 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 3165 continue; |
6695 | 3166 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
3167 GaimBuddy *buddy; | |
3168 | |
3169 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
3170 continue; | |
3171 | |
3172 buddy = (GaimBuddy *)bnode; | |
3173 | |
3174 if (buddy->account == gc->account && | |
3175 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 3176 tmp = g_list_insert_sorted(tmp, buddy->name, |
3177 (GCompareFunc)g_utf8_collate); | |
6695 | 3178 } |
4359 | 3179 } |
3180 } | |
3181 } | |
3182 | |
3183 return tmp; | |
3184 } | |
3185 | |
9498 | 3186 static GdkPixbuf * |
9554 | 3187 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 3188 { |
9554 | 3189 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 3190 char *filename; |
10274 | 3191 const char *image = NULL; |
9554 | 3192 |
3193 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 3194 image = "founder.png"; |
9554 | 3195 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 3196 image = "op.png"; |
9554 | 3197 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 3198 image = "halfop.png"; |
9554 | 3199 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 3200 image = "voice.png"; |
9554 | 3201 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 3202 image = "ignored.png"; |
3203 } else { | |
3204 return NULL; | |
9554 | 3205 } |
10274 | 3206 |
3207 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
3208 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
3209 g_free(filename); | |
3210 | |
3211 if (!pixbuf) | |
3212 return NULL; | |
3213 | |
3214 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
3215 g_object_unref(pixbuf); | |
3216 | |
3217 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
3218 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 3219 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
3220 g_free(filename); | |
10274 | 3221 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 3222 g_object_unref(pixbuf); |
10274 | 3223 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
3224 g_object_unref(scale2); | |
9498 | 3225 } |
3226 | |
10274 | 3227 return scale; |
9498 | 3228 } |
3229 | |
4359 | 3230 static void |
11869 | 3231 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 3232 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3233 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3234 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3235 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3236 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3237 GaimPluginProtocolInfo *prpl_info; |
4359 | 3238 GtkListStore *ls; |
9498 | 3239 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3240 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3241 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3242 gboolean is_buddy; |
4359 | 3243 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3244 chat = GAIM_CONV_CHAT(conv); |
4359 | 3245 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3246 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3247 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3248 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3249 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3250 return; |
4359 | 3251 |
3252 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3253 | |
9554 | 3254 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 3255 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3256 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
|
3257 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3258 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3259 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3260 |
4359 | 3261 gtk_list_store_append(ls, &iter); |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3262 |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3263 if (is_me) |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3264 { |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3265 GdkColor send_color; |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3266 gdk_color_parse(SEND_COLOR, &send_color); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3267 |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3268 gtk_list_store_set(ls, &iter, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3269 CHAT_USERS_ICON_COLUMN, pixbuf, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3270 CHAT_USERS_ALIAS_COLUMN, alias, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3271 CHAT_USERS_NAME_COLUMN, name, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3272 CHAT_USERS_FLAGS_COLUMN, flags, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3273 CHAT_USERS_COLOR_COLUMN, &send_color, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3274 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3275 -1); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3276 } |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3277 else |
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, |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
3284 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, name), |
12358
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 } |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3288 |
9554 | 3289 if (pixbuf) |
3290 g_object_unref(pixbuf); | |
4359 | 3291 } |
3292 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3293 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3294 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
|
3295 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3296 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3297 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3298 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3299 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3300 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3301 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3302 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3303 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3304 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3305 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3306 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3307 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3308 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3309 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3310 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3311 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3312 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3313 char *tmp = g_strdup(name); |
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 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3316 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3317 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3318 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3319 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3320 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3321 (*most_matched)++; |
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 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3324 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3325 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3326 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3327 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3328 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3329 |
9605 | 3330 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3331 tab_complete(GaimConversation *conv) |
4359 | 3332 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3333 GaimGtkConversation *gtkconv; |
4359 | 3334 GtkTextIter cursor, word_start, start_buffer; |
3335 int start; | |
3336 int most_matched = -1; | |
3337 char *entered, *partial = NULL; | |
3338 char *text; | |
8021 | 3339 char *nick_partial; |
9605 | 3340 const char *prefix; |
4359 | 3341 GList *matches = NULL; |
9605 | 3342 gboolean command = FALSE; |
4359 | 3343 |
3344 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3345 | |
3346 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3347 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3348 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3349 | |
3350 word_start = cursor; | |
3351 | |
3352 /* if there's nothing there just return */ | |
3353 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3354 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
|
3355 |
4359 | 3356 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3357 &cursor, FALSE); | |
3358 | |
3359 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3360 start = strlen(text) - 1; | |
3361 | |
8021 | 3362 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3363 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3364 start-=2; |
3365 } | |
4359 | 3366 |
3367 /* find the start of the word that we're tabbing */ | |
3368 while (start >= 0 && text[start] != ' ') { | |
3369 gtk_text_iter_backward_char(&word_start); | |
3370 start--; | |
3371 } | |
3372 | |
9605 | 3373 prefix = gaim_gtk_get_cmd_prefix(); |
3374 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3375 command = TRUE; | |
3376 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3377 } | |
3378 | |
4359 | 3379 g_free(text); |
3380 | |
3381 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3382 &cursor, FALSE); | |
3383 | |
8021 | 3384 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3385 g_free(entered); |
11338 | 3386 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3387 } |
3388 | |
8021 | 3389 nick_partial = g_malloc(strlen(entered)+1); |
3390 | |
9605 | 3391 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3392 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3393 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3394 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3395 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3396 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3397 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3398 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3399 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3400 g_list_free(list); |
11338 | 3401 } 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
|
3402 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3403 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3404 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
|
3405 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3406 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3407 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3408 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3409 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3410 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3411 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3412 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3413 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3414 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3415 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3416 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
|
3417 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3418 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3419 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3420 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3421 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3422 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3423 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3424 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3425 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3426 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3427 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3428 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3429 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3430 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3431 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3432 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3433 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3434 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3435 } |
9605 | 3436 } else { |
3437 g_free(nick_partial); | |
3438 g_free(entered); | |
3439 return FALSE; | |
3440 } | |
3441 | |
8021 | 3442 g_free(nick_partial); |
3443 | |
4359 | 3444 /* we're only here if we're doing new style */ |
3445 | |
3446 /* if there weren't any matches, return */ | |
3447 if (!matches) { | |
3448 /* if matches isn't set partials won't be either */ | |
3449 g_free(entered); | |
11338 | 3450 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3451 } |
3452 | |
3453 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3454 | |
3455 if (!matches->next) { | |
3456 /* there was only one match. fill it in. */ | |
3457 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3458 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3459 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3460 | |
3461 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3462 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3463 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3464 g_free(tmp); | |
3465 } | |
3466 else | |
3467 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3468 matches->data, -1); | |
3469 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3470 g_free(matches->data); |
4359 | 3471 matches = g_list_remove(matches, matches->data); |
3472 } | |
3473 else { | |
3474 /* | |
3475 * there were lots of matches, fill in as much as possible | |
3476 * and display all of them | |
3477 */ | |
3478 char *addthis = g_malloc0(1); | |
3479 | |
3480 while (matches) { | |
3481 char *tmp = addthis; | |
3482 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3483 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3484 g_free(matches->data); |
4359 | 3485 matches = g_list_remove(matches, matches->data); |
3486 } | |
3487 | |
6982 | 3488 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3489 time(NULL)); |
3490 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3491 g_free(addthis); | |
3492 } | |
3493 | |
3494 g_free(entered); | |
3495 g_free(partial); | |
9605 | 3496 |
3497 return TRUE; | |
4359 | 3498 } |
3499 | |
10810 | 3500 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3501 { |
3502 GaimPluginProtocolInfo *prpl_info = NULL; | |
3503 GaimConnection *gc; | |
10810 | 3504 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3505 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3506 char *new_topic; |
8858 | 3507 const char *current_topic; |
7971 | 3508 |
3509 gc = gaim_conversation_get_gc(conv); | |
3510 | |
3511 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3512 return; | |
3513 | |
3514 if(prpl_info->set_chat_topic == NULL) | |
3515 return; | |
3516 | |
3517 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3518 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3519 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3520 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3521 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3522 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3523 g_free(new_topic); |
7971 | 3524 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3525 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3526 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3527 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3528 |
8858 | 3529 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3530 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3531 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3532 g_free(new_topic); |
7971 | 3533 } |
3534 | |
9554 | 3535 static gint |
3536 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3537 { | |
3538 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3539 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3540 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3541 gint ret = 0; |
3542 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3543 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3544 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3545 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3546 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3547 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3548 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3549 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3550 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3551 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3552 -1); |
9554 | 3553 |
3554 if (user1 == NULL || user2 == NULL) { | |
3555 if (!(user1 == NULL && user2 == NULL)) | |
3556 ret = (user1 == NULL) ? -1: 1; | |
3557 } else if (f1 != f2) { | |
3558 /* sort more important users first */ | |
3559 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3560 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3561 ret = buddy1 ? -1 : 1; |
9554 | 3562 } else { |
10904 | 3563 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3564 } |
3565 | |
3566 g_free(user1); | |
3567 g_free(user2); | |
3568 | |
3569 return ret; | |
3570 } | |
3571 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3572 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3573 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
|
3574 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3575 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3576 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3577 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3578 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3579 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3580 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3581 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3582 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3583 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3584 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3585 /* 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
|
3586 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
|
3587 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3588 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
|
3589 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3590 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3591 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
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 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3594 char *name; |
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 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
|
3597 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3598 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3599 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3600 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3601 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3602 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3603 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3604 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3605 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3606 alias = gaim_buddy_get_contact_alias(buddy2); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3607 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3608 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3609 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3610 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3611 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3612 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3613 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3614 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3615 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3616 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3617 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3618 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3619 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3620 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3621 g_free(normalized_name); |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3624 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3625 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
|
3626 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3627 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3628 GaimPluginProtocolInfo *prpl_info; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3629 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3630 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3631 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3632 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3633 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3634 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3635 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3636 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3639 return; |
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 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3642 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3643 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3644 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3645 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3646 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3647 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3648 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3649 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3650 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
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 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3653 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3654 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3657 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3658 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3659 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3660 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3661 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3662 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3663 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3664 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3665 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3666 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3667 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3668 /* 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
|
3669 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3670 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3671 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3672 /* 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
|
3673 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
|
3674 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3675 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
|
3676 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3677 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3678 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3679 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3680 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3681 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3682 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3683 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
|
3684 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3685 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3686 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
|
3687 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3688 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3689 } |
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 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3692 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3693 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3694 } while (f != 0); |
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 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3697 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3698 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3699 } |
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 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3702 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
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 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3705 } |
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 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3708 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3709 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3710 /* 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
|
3711 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3712 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3713 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3714 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3715 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3716 |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3717 static void send_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3718 { |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3719 g_signal_emit_by_name(gtkconv->entry, "message_send"); |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3720 } |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3721 |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3722 static void |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3723 entry_popup_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3724 { |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3725 GtkWidget *menuitem; |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3726 GaimGtkConversation *gtkconv = data; |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3727 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3728 g_return_if_fail(menu != NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3729 g_return_if_fail(gtkconv != NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3730 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3731 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
|
3732 G_CALLBACK(send_menu_cb), gtkconv, |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3733 0, 0, NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3734 if (gtk_text_buffer_get_char_count(imhtml->text_buffer) == 0) |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3735 gtk_widget_set_sensitive(menuitem, FALSE); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3736 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 0); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3737 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3738 menuitem = gtk_separator_menu_item_new(); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3739 gtk_widget_show(menuitem); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3740 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 1); |
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 |
4359 | 3743 static GtkWidget * |
10810 | 3744 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3745 { |
13419
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
3746 GaimPluginProtocolInfo *prpl_info; |
10810 | 3747 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3748 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3749 GaimConnection *gc; |
4359 | 3750 GtkWidget *vpaned, *hpaned; |
10175 | 3751 GtkWidget *vbox, *hbox, *frame; |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3752 GtkWidget *imhtml_sw; |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3753 GtkPolicyType imhtml_sw_hscroll; |
4359 | 3754 GtkWidget *lbox, *bbox; |
3755 GtkWidget *label; | |
3756 GtkWidget *list; | |
3757 GtkWidget *button; | |
7949 | 3758 GtkWidget *sw; |
4359 | 3759 GtkListStore *ls; |
3760 GtkCellRenderer *rend; | |
3761 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3762 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3763 GList *focus_chain = NULL; |
4359 | 3764 |
3765 gtkchat = gtkconv->u.chat; | |
3766 gc = gaim_conversation_get_gc(conv); | |
13424
d52b9874c0de
[gaim-migrate @ 15799]
Richard Laager <rlaager@wiktel.com>
parents:
13419
diff
changeset
|
3767 g_return_val_if_fail(gc != NULL, NULL); |
d52b9874c0de
[gaim-migrate @ 15799]
Richard Laager <rlaager@wiktel.com>
parents:
13419
diff
changeset
|
3768 g_return_val_if_fail(gc->prpl != NULL, NULL); |
13419
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
3769 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
4359 | 3770 |
3771 /* Setup the outer pane. */ | |
3772 vpaned = gtk_vpaned_new(); | |
3773 gtk_widget_show(vpaned); | |
3774 | |
3775 /* Setup the top part of the pane. */ | |
11243 | 3776 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3777 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3778 gtk_widget_show(vbox); |
3779 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3780 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3781 { |
11243 | 3782 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3783 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3784 gtk_widget_show(hbox); |
3785 | |
3786 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3787 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3788 gtk_widget_show(label); |
3789 | |
3790 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3791 |
7971 | 3792 if(prpl_info->set_chat_topic == NULL) { |
3793 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3794 } else { | |
3795 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3796 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3797 } |
3798 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3799 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3800 gtk_widget_show(gtkchat->topic_text); |
3801 } | |
3802 | |
3803 /* Setup the horizontal pane. */ | |
3804 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3805 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3806 gtk_widget_show(hpaned); |
3807 | |
10175 | 3808 /* Setup gtkihmtml. */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3809 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL, &imhtml_sw); |
10175 | 3810 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); |
10389 | 3811 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3812 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3813 gtk_widget_show(frame); | |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3814 gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3815 &imhtml_sw_hscroll, NULL); |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3816 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3817 imhtml_sw_hscroll, GTK_POLICY_ALWAYS); |
10175 | 3818 |
3819 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3820 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3821 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3822 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3823 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3824 |
4359 | 3825 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3826 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3827 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3828 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3829 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3830 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3831 |
3832 /* Build the right pane. */ | |
11243 | 3833 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3834 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3835 gtk_widget_show(lbox); |
3836 | |
3837 /* Setup the label telling how many people are in the room. */ | |
3838 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3839 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3840 gtk_widget_show(gtkchat->count); | |
3841 | |
3842 /* Setup the list of users. */ | |
7949 | 3843 sw = gtk_scrolled_window_new(NULL, NULL); |
3844 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3845 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3846 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3847 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3848 gtk_widget_show(sw); | |
4359 | 3849 |
9554 | 3850 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
|
3851 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
|
3852 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3853 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3854 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3855 GTK_SORT_ASCENDING); |
3856 | |
3857 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3858 | |
9498 | 3859 rend = gtk_cell_renderer_pixbuf_new(); |
3860 | |
4359 | 3861 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3862 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3863 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3864 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3865 |
3866 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3867 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3868 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3869 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3870 |
9498 | 3871 rend = gtk_cell_renderer_text_new(); |
3872 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3873 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3874 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3875 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3876 NULL); |
4359 | 3877 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3878 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3879 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3880 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3881 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3882 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3883 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3884 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3885 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3886 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3887 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3888 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3889 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3890 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3891 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3892 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3893 #endif |
4359 | 3894 |
3895 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3896 | |
3897 gtk_widget_set_size_request(list, 150, -1); | |
3898 | |
3899 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3900 gtk_widget_show(list); | |
3901 | |
3902 gtkchat->list = list; | |
3903 | |
7949 | 3904 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3905 |
3906 /* Setup the user list toolbar. */ | |
11243 | 3907 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3908 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3909 gtk_widget_show(bbox); | |
3910 | |
3911 /* IM */ | |
10221 | 3912 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3913 GAIM_BUTTON_VERTICAL); |
10500 | 3914 gtkchat->userlist_im = button; |
4359 | 3915 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3916 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
|
3917 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3918 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3919 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3920 |
3921 gtk_widget_show(button); | |
3922 | |
3923 /* Ignore */ | |
3924 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3925 GAIM_BUTTON_VERTICAL); | |
10500 | 3926 gtkchat->userlist_ignore = button; |
4359 | 3927 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3928 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
|
3929 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3930 _("Ignore the user"), NULL); |
4359 | 3931 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3932 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3933 gtk_widget_show(button); |
3934 | |
3935 /* Info */ | |
3936 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3937 GAIM_BUTTON_VERTICAL); | |
10500 | 3938 gtkchat->userlist_info = button; |
4359 | 3939 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3940 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3941 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3942 _("Get the user's information"), NULL); |
4359 | 3943 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3944 G_CALLBACK(info_cb), gtkconv); |
4359 | 3945 |
3946 gtk_widget_show(button); | |
3947 | |
10175 | 3948 /* Setup the bottom half of the conversation window */ |
11243 | 3949 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3950 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3951 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3952 |
11243 | 3953 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3954 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3955 gtk_widget_show(gtkconv->lower_hbox); | |
3956 | |
11243 | 3957 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3958 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3959 gtk_widget_show(vbox); | |
3960 | |
10175 | 3961 /* Setup the toolbar, entry widget and all signals */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3962 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar, NULL); |
10080 | 3963 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3964 gtk_widget_show(frame); |
3965 | |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3966 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3967 G_CALLBACK(entry_popup_menu_cb), gtkconv); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3968 |
9005 | 3969 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3970 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3971 gaim_account_get_protocol_name(conv->account)); |
10175 | 3972 gtk_widget_set_size_request(gtkconv->entry, -1, |
3973 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3974 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3975 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3976 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3977 |
3978 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3979 G_CALLBACK(entry_key_press_cb), gtkconv); |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3980 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3981 G_CALLBACK(send_cb), gtkconv); |
4359 | 3982 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3983 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3984 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3985 G_CALLBACK(size_allocate_cb), gtkconv); |
3986 | |
3987 default_formatize(gtkconv); | |
4359 | 3988 |
9080 | 3989 /* |
3990 * Focus for chat windows should be as follows: | |
3991 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3992 * user list buttons -> entry -> buttons at bottom | |
3993 */ | |
9332 | 3994 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3995 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3996 | |
4359 | 3997 return vpaned; |
3998 } | |
3999 | |
4000 static GtkWidget * | |
10810 | 4001 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 4002 { |
10810 | 4003 GaimConversation *conv = gtkconv->active_conv; |
10175 | 4004 GtkWidget *frame; |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4005 GtkWidget *imhtml_sw; |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4006 GtkPolicyType imhtml_sw_hscroll; |
4359 | 4007 GtkWidget *paned; |
10175 | 4008 GtkWidget *vbox; |
4009 GtkWidget *vbox2; | |
9080 | 4010 GList *focus_chain = NULL; |
4359 | 4011 |
10175 | 4012 /* Setup the outer pane */ |
4359 | 4013 paned = gtk_vpaned_new(); |
4014 gtk_widget_show(paned); | |
4015 | |
10175 | 4016 /* Setup the top part of the pane */ |
11243 | 4017 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
4018 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 4019 gtk_widget_show(vbox); |
4020 | |
10175 | 4021 /* Setup the gtkimhtml widget */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4022 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL, &imhtml_sw); |
10175 | 4023 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); |
10389 | 4024 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 4025 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
4026 gtk_widget_show(frame); | |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4027 gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4028 &imhtml_sw_hscroll, NULL); |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4029 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4030 imhtml_sw_hscroll, GTK_POLICY_ALWAYS); |
10175 | 4031 |
4032 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4033 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4034 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 4035 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 4036 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 4037 |
4038 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 4039 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 4040 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 4041 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 4042 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 4043 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 4044 |
10175 | 4045 /* Setup the bottom half of the conversation window */ |
11243 | 4046 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 4047 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4048 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4049 |
11243 | 4050 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 4051 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
4052 gtk_widget_show(gtkconv->lower_hbox); | |
4053 | |
11243 | 4054 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 4055 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
4056 gtk_widget_show(vbox2); | |
8821 | 4057 |
10175 | 4058 /* Setup the toolbar, entry widget and all signals */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4059 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar, NULL); |
10080 | 4060 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 4061 gtk_widget_show(frame); |
4062 | |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4063 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4064 G_CALLBACK(entry_popup_menu_cb), gtkconv); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4065 |
9005 | 4066 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 4067 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 4068 gaim_account_get_protocol_name(conv->account)); |
10175 | 4069 gtk_widget_set_size_request(gtkconv->entry, -1, |
4070 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4071 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4072 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 4073 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
|
4074 |
4359 | 4075 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 4076 G_CALLBACK(entry_key_press_cb), gtkconv); |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4077 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4078 G_CALLBACK(send_cb), gtkconv); |
4359 | 4079 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 4080 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 4081 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 4082 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 4083 |
4084 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 4085 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 4086 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 4087 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 4088 |
8481 | 4089 /* had to move this after the imtoolbar is attached so that the |
4090 * signals get fired to toggle the buttons on the toolbar as well. | |
4091 */ | |
10810 | 4092 default_formatize(gtkconv); |
4359 | 4093 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4094 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4095 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4096 |
8758 | 4097 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 4098 gtkconv->u.im->show_icon = TRUE; |
4359 | 4099 |
9080 | 4100 /* |
4101 * Focus for IM windows should be as follows: | |
10356 | 4102 * Tab title -> conversation scrollback -> entry |
9080 | 4103 */ |
9332 | 4104 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4105 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 4106 |
4359 | 4107 return paned; |
4108 } | |
4109 | |
4110 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4111 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 4112 GtkSelectionData *sd, guint info, guint t, |
4113 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4114 { |
10810 | 4115 GaimConversation *conv = gtkconv->active_conv; |
11581 | 4116 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4117 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4118 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4119 { |
4781 | 4120 GaimBlistNode *n = NULL; |
6695 | 4121 GaimBuddy *b; |
11581 | 4122 GaimGtkConversation *gtkconv = NULL; |
9622 | 4123 |
11812 | 4124 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4125 |
6695 | 4126 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
4127 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
4128 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
4129 b = (GaimBuddy*)n; | |
4130 else | |
4781 | 4131 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4132 |
9622 | 4133 /* |
4134 * If we already have an open conversation with this buddy, then | |
4135 * just move the conv to this window. Otherwise, create a new | |
4136 * conv and add it to this window. | |
4137 */ | |
11338 | 4138 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 4139 if (c != NULL) { |
11581 | 4140 GaimGtkWindow *oldwin; |
4141 gtkconv = GAIM_GTK_CONVERSATION(c); | |
4142 oldwin = gtkconv->win; | |
9622 | 4143 if (oldwin != win) { |
11581 | 4144 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
4145 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 4146 } |
4147 } else { | |
11338 | 4148 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 4149 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 4150 if (gtkconv->win != win) |
4151 { | |
4152 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
4153 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
4154 } | |
9622 | 4155 } |
4156 | |
4157 /* Make this conversation the active conversation */ | |
11581 | 4158 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4159 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4160 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 4161 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4162 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
|
4163 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4164 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4165 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4166 GaimAccount *account; |
11581 | 4167 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4168 |
11137 | 4169 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 4170 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4171 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4172 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4173 { |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
4174 gaim_notify_error(win, NULL, |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4175 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4176 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4177 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4178 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4179 { |
11338 | 4180 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 4181 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 4182 if (gtkconv->win != win) |
4183 { | |
4184 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
4185 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
4186 } | |
7712
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 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4190 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4191 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4192 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4193 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4194 } |
9525 | 4195 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 4196 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 4197 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 4198 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 4199 } |
10145 | 4200 else |
4201 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4202 } |
4359 | 4203 |
4204 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4205 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4206 { |
10145 | 4207 GTK_IMHTML_DND_TARGETS, |
4208 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
4209 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4210 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4211 |
10810 | 4212 static GaimGtkConversation * |
4213 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
4214 { | |
4215 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
4216 GaimContact *c; | |
4217 GaimBlistNode *cn; | |
10935 | 4218 |
10810 | 4219 if (!bud) |
4220 return NULL; | |
10935 | 4221 |
10810 | 4222 if (!(c = gaim_buddy_get_contact(bud))) |
4223 return NULL; | |
10935 | 4224 |
10810 | 4225 cn = (GaimBlistNode *)c; |
4226 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
4227 GaimConversation *conv; | |
11338 | 4228 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 4229 if (conv->ui_data) |
4230 return conv->ui_data; | |
4231 } | |
4232 } | |
10935 | 4233 |
10810 | 4234 return NULL; |
4235 } | |
4236 | |
11855 | 4237 static void |
4238 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
4239 { | |
4240 GList *list; | |
4241 | |
4242 g_return_if_fail(bnode); | |
4243 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
4244 | |
4245 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
4246 { | |
4247 GaimGtkWindow *win = list->data; | |
4248 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4249 | |
4250 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
4251 continue; | |
4252 | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
4253 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_MENU); |
11855 | 4254 } |
4255 } | |
4256 | |
11581 | 4257 /************************************************************************** |
4258 * Conversation UI operations | |
4259 **************************************************************************/ | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4260 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4261 private_gtkconv_new(GaimConversation *conv, gboolean hidden) |
11581 | 4262 { |
4263 GaimGtkConversation *gtkconv; | |
4264 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 4265 GtkWidget *pane = NULL; |
4266 GtkWidget *tab_cont; | |
11581 | 4267 |
4268 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 4269 conv->ui_data = gtkconv; |
4270 if (!g_list_find(gtkconv->convs, conv)) | |
4271 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 4272 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 4273 return; |
4359 | 4274 } |
4275 | |
11581 | 4276 gtkconv = g_new0(GaimGtkConversation, 1); |
4277 conv->ui_data = gtkconv; | |
4278 gtkconv->active_conv = conv; | |
4279 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
4280 | |
4281 /* Setup some initial variables. */ | |
4282 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
4283 gtkconv->tooltips = gtk_tooltips_new(); | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4284 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4285 gtkconv->unseen_count = 0; |
11581 | 4286 |
4287 if (conv_type == GAIM_CONV_TYPE_IM) { | |
4288 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
4289 | |
4290 pane = setup_im_pane(gtkconv); | |
4291 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
4292 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
4293 pane = setup_chat_pane(gtkconv); | |
4294 } | |
4295 | |
12101 | 4296 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
4297 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
4298 | |
11581 | 4299 if (pane == NULL) { |
4300 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
4301 g_free(gtkconv->u.chat); | |
4302 else if (conv_type == GAIM_CONV_TYPE_IM) | |
4303 g_free(gtkconv->u.im); | |
4304 | |
4305 g_free(gtkconv); | |
4306 conv->ui_data = NULL; | |
4307 return; | |
10449 | 4308 } |
11581 | 4309 |
4310 /* Setup drag-and-drop */ | |
4311 gtk_drag_dest_set(pane, | |
4312 GTK_DEST_DEFAULT_MOTION | | |
4313 GTK_DEST_DEFAULT_DROP, | |
4314 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4315 GDK_ACTION_COPY); | |
4316 gtk_drag_dest_set(pane, | |
4317 GTK_DEST_DEFAULT_MOTION | | |
4318 GTK_DEST_DEFAULT_DROP, | |
4319 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4320 GDK_ACTION_COPY); | |
4321 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4322 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4323 GDK_ACTION_COPY); | |
4324 | |
4325 gtk_drag_dest_set(gtkconv->entry, 0, | |
4326 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4327 GDK_ACTION_COPY); | |
4328 | |
4329 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
4330 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4331 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
4332 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4333 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
4334 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4335 | |
4336 /* Setup the container for the tab. */ | |
4337 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
4338 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
4339 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
4340 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
4341 gtk_widget_show(pane); | |
4342 | |
4343 gtkconv->make_sound = TRUE; | |
4344 | |
4345 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
4346 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4347 else |
11581 | 4348 gtk_widget_hide(gtkconv->toolbar); |
4349 | |
12188 | 4350 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), |
4351 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4352 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4353 gaim_account_get_protocol_name(conv->account)); |
11581 | 4354 |
4355 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
4356 G_CALLBACK(gtk_widget_grab_focus), | |
4357 gtkconv->entry); | |
4358 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4359 if (hidden) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4360 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4361 else |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4362 gaim_gtkconv_placement_place(gtkconv); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
4363 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4364 if (nick_colors == NULL) { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4365 nbr_nick_colors = NUM_NICK_COLORS; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4366 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
|
4367 } |
12288
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 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4370 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4371 gaim_gtkconv_new_hidden(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4372 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4373 private_gtkconv_new(conv, TRUE); |
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 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4376 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4377 gaim_gtkconv_new(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4378 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4379 private_gtkconv_new(conv, FALSE); |
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 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4382 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4383 received_im_msg_cb(GaimAccount *account, char *sender, char *message, |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4384 GaimConversation *conv, int flags) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4385 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4386 GaimConversationUiOps *ui_ops = gaim_gtk_conversations_get_conv_ui_ops(); |
12719
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4387 if (conv != NULL) |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4388 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4389 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4390 /* create hidden conv if hide_new pref is always */ |
12719
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4391 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
|
4392 { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4393 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4394 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4395 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4396 return; |
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 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4399 /* 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
|
4400 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
|
4401 !gaim_status_is_available(gaim_account_get_active_status(account))) |
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4402 { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4403 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4404 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4405 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4406 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4407 } |
11581 | 4408 } |
4409 | |
4359 | 4410 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4411 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4412 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4413 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4414 |
10810 | 4415 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4416 /* Don't destroy ourselves until all our convos are gone */ | |
4417 if (gtkconv->convs) | |
4418 return; | |
11508 | 4419 |
11581 | 4420 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4421 | |
9504 | 4422 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
4423 gaim_request_close_with_handle(gtkconv); |
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
4424 gaim_notify_close_with_handle(gtkconv); |
4359 | 4425 |
13721
6a02f71a305a
[gaim-migrate @ 16130]
Richard Laager <rlaager@wiktel.com>
parents:
13714
diff
changeset
|
4426 /* Close the "Find" dialog if it's open */ |
6a02f71a305a
[gaim-migrate @ 16130]
Richard Laager <rlaager@wiktel.com>
parents:
13714
diff
changeset
|
4427 if (gtkconv->dialogs.search) |
6a02f71a305a
[gaim-migrate @ 16130]
Richard Laager <rlaager@wiktel.com>
parents:
13714
diff
changeset
|
4428 gtk_widget_destroy(gtkconv->dialogs.search); |
6a02f71a305a
[gaim-migrate @ 16130]
Richard Laager <rlaager@wiktel.com>
parents:
13714
diff
changeset
|
4429 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4430 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4431 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4432 |
11338 | 4433 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4434 if (gtkconv->u.im->icon_timer != 0) |
4435 g_source_remove(gtkconv->u.im->icon_timer); | |
4436 | |
4359 | 4437 if (gtkconv->u.im->anim != NULL) |
4793 | 4438 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4439 |
4440 g_free(gtkconv->u.im); | |
11581 | 4441 } 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
|
4442 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4443 g_free(gtkconv->u.chat); |
4444 } | |
4445 | |
4633 | 4446 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4447 | |
4359 | 4448 g_free(gtkconv); |
4449 } | |
4450 | |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4451 |
4359 | 4452 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4453 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4454 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4455 time_t mtime) |
4359 | 4456 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4457 GaimGtkConversation *gtkconv; |
4359 | 4458 |
4459 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4460 |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4461 if (conv != gtkconv->active_conv && |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4462 flags & GAIM_MESSAGE_ACTIVE_ONLY) |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4463 { |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4464 /* Plugins that want these messages suppressed should be |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4465 * calling gaim_conv_im_write(), so they get suppressed here, |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4466 * before being written to the log. */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4467 gaim_debug_info("gtkconv", |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4468 "Suppressing message for an inactive conversation in gaim_gtkconv_write_im()\n"); |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4469 return; |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4470 } |
4359 | 4471 |
6982 | 4472 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4473 } |
4474 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4475 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4476 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4477 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4478 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4479 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4480 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4481 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4482 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4483 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4484 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4485 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4486 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4487 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4488 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4489 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4490 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4491 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4492 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4493 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4494 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4495 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4496 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4497 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4498 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4499 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4500 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4501 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4502 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4503 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4504 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4505 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4506 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4507 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4508 |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
4509 menu = create_chat_menu(conv, buddyname, gc); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4510 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4511 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4512 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4513 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4514 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4515 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4516 return TRUE; |
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 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4519 } |
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 return FALSE; |
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 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4525 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4526 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4527 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4528 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4529 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4530 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4531 str[sizeof(str)] = '\0'; |
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 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4534 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4535 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4536 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4537 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4538 buddytag = gtk_text_buffer_create_tag( |
11096 | 4539 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4540 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4541 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4542 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4543 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4544 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4545 return buddytag; |
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 |
4359 | 4548 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4549 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4550 const char *message, GaimMessageFlags flags, |
4359 | 4551 time_t mtime) |
4552 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4553 GaimGtkConversation *gtkconv; |
11581 | 4554 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4555 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4556 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4557 GaimPluginProtocolInfo *prpl_info; |
4359 | 4558 int gtk_font_options = 0; |
12553 | 4559 int gtk_font_options_all = 0; |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4560 int max_scrollback_lines; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4561 int line_count; |
4359 | 4562 char buf2[BUF_LONG]; |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4563 char *mdate; |
4359 | 4564 char color[10]; |
4565 char *str; | |
4566 char *with_font_tag; | |
4896 | 4567 char *sml_attrib = NULL; |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4568 size_t length; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4569 GaimConversationType type; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4570 char *displaying; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4571 gboolean plugin_return; |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4572 struct tm tm; |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4573 |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4574 g_return_if_fail(conv != NULL); |
4359 | 4575 gtkconv = GAIM_GTK_CONVERSATION(conv); |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4576 g_return_if_fail(gtkconv != NULL); |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4577 |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4578 if (conv != gtkconv->active_conv) |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4579 { |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4580 if (flags & GAIM_MESSAGE_ACTIVE_ONLY) |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4581 { |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4582 /* Unless this had GAIM_MESSAGE_NO_LOG, this message |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4583 * was logged. Plugin writers: if this isn't what |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4584 * you wanted, call gaim_conv_im_write() instead of |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4585 * gaim_conversation_write(). */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4586 gaim_debug_info("gtkconv", |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4587 "Suppressing message for an inactive conversation in gaim_gtkconv_write_conv()\n"); |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4588 return; |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4589 } |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4590 |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4591 /* Set the active conversation to the one that just messaged us. */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4592 /* TODO: consider not doing this if the account is offline or something */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4593 if (flags & (GAIM_MESSAGE_SEND | GAIM_MESSAGE_RECV)) |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4594 gaim_gtkconv_switch_active_conversation(conv); |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4595 } |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4596 |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4597 type = gaim_conversation_get_type(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4598 account = gaim_conversation_get_account(conv); |
13419
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
4599 g_return_if_fail(account != NULL); |
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
4600 gc = gaim_account_get_connection(account); |
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
4601 g_return_if_fail(gc != NULL); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4602 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4603 displaying = g_strdup(message); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4604 plugin_return = GPOINTER_TO_INT(gaim_signal_emit_return_1( |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4605 gaim_gtk_conversations_get_handle(), (type == GAIM_CONV_TYPE_IM ? |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4606 "displaying-im-msg" : "displaying-chat-msg"), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
4607 account, name, &displaying, conv, flags)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4608 if (plugin_return) |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4609 { |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4610 g_free(displaying); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4611 return; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4612 } |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4613 message = displaying; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4614 length = strlen(message) + 1; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4615 |
11581 | 4616 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4617 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4618 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4619 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4620 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4621 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4622 |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4623 max_scrollback_lines = gaim_prefs_get_int( |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4624 "/gaim/gtk/conversations/scrollback_lines"); |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4625 /* 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
|
4626 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4627 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4628 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4629 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4630 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4631 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4632 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4633 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4634 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4635 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4636 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4637 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4638 |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4639 if (type == GAIM_CONV_TYPE_CHAT) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4640 { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4641 /* Create anchor for user */ |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4642 GtkTextIter iter; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4643 char *tmp = g_strconcat("user:", name, NULL); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4644 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4645 gtk_text_buffer_get_end_iter(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)), &iter); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4646 gtk_text_buffer_create_mark(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)), |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4647 tmp, &iter, TRUE); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4648 g_free(tmp); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4649 } |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4650 |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4651 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_smooth_scrolling")) |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4652 gtk_font_options_all |= GTK_IMHTML_USE_SMOOTHSCROLLING; |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4653 |
8677 | 4654 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
12553 | 4655 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", gtk_font_options_all); |
8677 | 4656 |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4657 tm = *(localtime(&mtime)); |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4658 mdate = gaim_signal_emit_return_1(gaim_gtk_conversations_get_handle(), |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4659 "conversation-timestamp", |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4660 conv, &tm); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4661 if (mdate == NULL) |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4662 { |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4663 if (time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
4664 mdate = g_strdup(gaim_date_format_long(&tm)); |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4665 else |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
4666 mdate = g_strdup(gaim_time_format(&tm)); |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4667 } |
4359 | 4668 |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4669 sml_attrib = g_strdup_printf("sml=\"%s\"", gaim_account_get_protocol_name(account)); |
7440 | 4670 |
10503 | 4671 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4672 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4673 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4674 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4675 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4676 |
7956 | 4677 /* this is gonna crash one day, I can feel it. */ |
4678 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4679 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4680 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4681 } |
4359 | 4682 |
12553 | 4683 |
10737 | 4684 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4685 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4686 g_snprintf(buf2, sizeof(buf2), |
8690 | 4687 "<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
|
4688 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4689 |
12553 | 4690 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
7440 | 4691 |
8722 | 4692 } else if (flags & GAIM_MESSAGE_ERROR) { |
4693 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4694 "<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
|
4695 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4696 |
12553 | 4697 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
8962 | 4698 |
7431 | 4699 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4700 g_snprintf(buf2, BUF_LONG, |
8690 | 4701 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4702 sml_attrib ? sml_attrib : "", message); |
7440 | 4703 |
12553 | 4704 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
10346 | 4705 } else if (flags & GAIM_MESSAGE_RAW) { |
12553 | 4706 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, gtk_font_options_all); |
10346 | 4707 } else { |
4895 | 4708 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4709 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
|
4710 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4711 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4712 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
|
4713 int tag_end_offset = 0; |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4714 GtkSmileyTree *tree = NULL; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4715 GHashTable *smiley_data = NULL; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4716 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4717 if (flags & GAIM_MESSAGE_SEND) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4718 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4719 /* Temporarily revert to the original smiley-data to avoid showing up |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4720 * custom smileys of the buddy when sending message |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4721 */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4722 tree = GTK_IMHTML(gtkconv->imhtml)->default_smilies; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4723 GTK_IMHTML(gtkconv->imhtml)->default_smilies = |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4724 GTK_IMHTML(gtkconv->entry)->default_smilies; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4725 smiley_data = GTK_IMHTML(gtkconv->imhtml)->smiley_data; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4726 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
|
4727 } |
7440 | 4728 |
6621 | 4729 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4730 str = g_malloc(1024); |
7440 | 4731 |
4359 | 4732 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4733 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4734 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4735 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4736 tag_start_offset += 3; |
4359 | 4737 } |
4738 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4739 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4740 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4741 tag_end_offset = 2; |
4359 | 4742 strcpy(color, "#00FF00"); |
4743 } | |
7440 | 4744 } |
4359 | 4745 else { |
10504 | 4746 if (gaim_message_meify(new_message, -1)) { |
4359 | 4747 str = g_malloc(1024); |
7440 | 4748 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4749 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4750 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
|
4751 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4752 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4753 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4754 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4755 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4756 } |
7440 | 4757 |
6621 | 4758 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4759 strcpy(color, HIGHLIGHT_COLOR); |
4359 | 4760 else |
4761 strcpy(color, "#062585"); | |
4762 } | |
4763 else { | |
4764 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4765 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4766 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
|
4767 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4768 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4769 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4770 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4771 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4772 } |
6621 | 4773 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4774 strcpy(color, HIGHLIGHT_COLOR); |
6621 | 4775 else if (flags & GAIM_MESSAGE_RECV) { |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4776 if (type == GAIM_CONV_TYPE_CHAT) { |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
4777 GdkColor *col = get_nick_color(gtkconv, name); |
10346 | 4778 |
10108 | 4779 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4780 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4781 } else |
7854 | 4782 strcpy(color, RECV_COLOR); |
4359 | 4783 } |
6621 | 4784 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4785 strcpy(color, SEND_COLOR); |
10892 | 4786 else { |
4787 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4788 strcpy(color, "#000000"); | |
4789 } | |
4359 | 4790 } |
4791 } | |
10892 | 4792 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4793 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4794 g_free(alias_escaped); |
11508 | 4795 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4796 /* 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
|
4797 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4798 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4799 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4800 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4801 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4802 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4803 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4804 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4805 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4806 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4807 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4808 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4809 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4810 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4811 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4812 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4813 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4814 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4815 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4816 /* 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
|
4817 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4818 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4819 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4820 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4821 } |
7440 | 4822 |
12553 | 4823 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
|
4824 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4825 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4826 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4827 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4828 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4829 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4830 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4831 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4832 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4833 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4834 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4835 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4836 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4837 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4838 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4839 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4840 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4841 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4842 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4843 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4844 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4845 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4846 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4847 |
4359 | 4848 g_free(str); |
4849 | |
4895 | 4850 if(gc){ |
4896 | 4851 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4852 char *post = "</font>"; |
4853 int pre_len = strlen(pre); | |
4854 int post_len = strlen(post); | |
7440 | 4855 |
4895 | 4856 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4857 |
4895 | 4858 strcpy(with_font_tag, pre); |
4859 memcpy(with_font_tag + pre_len, new_message, length); | |
4860 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4861 |
4895 | 4862 length += pre_len + post_len; |
4863 g_free(pre); | |
4864 } | |
4608 | 4865 else |
4895 | 4866 with_font_tag = g_memdup(new_message, length); |
7440 | 4867 |
8962 | 4868 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
12553 | 4869 with_font_tag, gtk_font_options | gtk_font_options_all); |
7440 | 4870 |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4871 if (flags & GAIM_MESSAGE_SEND) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4872 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4873 /* Restore the smiley-data */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4874 GTK_IMHTML(gtkconv->imhtml)->default_smilies = tree; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4875 GTK_IMHTML(gtkconv->imhtml)->smiley_data = smiley_data; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4876 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4877 |
7440 | 4878 g_free(with_font_tag); |
7447 | 4879 g_free(new_message); |
7440 | 4880 } |
4881 | |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4882 g_free(mdate); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4883 g_free(sml_attrib); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4884 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4885 /* Tab highlighting stuff */ |
13138
277c7a62650b
[gaim-migrate @ 15500]
Richard Laager <rlaager@wiktel.com>
parents:
13131
diff
changeset
|
4886 if (!(flags & GAIM_MESSAGE_SEND) && !gaim_gtkconv_has_focus(conv)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4887 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4888 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4889 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4890 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4891 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4892 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4893 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4894 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4895 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
|
4896 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4897 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4898 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4899 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4900 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4901 } |
12902
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4902 |
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4903 gaim_signal_emit(gaim_gtk_conversations_get_handle(), |
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4904 (type == GAIM_CONV_TYPE_IM ? "displayed-im-msg" : "displayed-chat-msg"), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
4905 account, name, message, conv, flags); |
12902
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4906 g_free(displaying); |
4359 | 4907 } |
4908 | |
4909 static void | |
12463
b1717befbb26
[gaim-migrate @ 14773]
Richard Laager <rlaager@wiktel.com>
parents:
12455
diff
changeset
|
4910 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
|
4911 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4912 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4913 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4914 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4915 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4916 GList *ll; |
11869 | 4917 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4918 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4919 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4920 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4921 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4922 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4923 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4924 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4925 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
|
4926 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4927 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4928 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4929 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4930 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4931 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4932 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4933 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4934 l = users; |
11869 | 4935 ll = flags; |
4936 lll = aliases; | |
4937 while (l != NULL && ll != NULL && lll != NULL) { | |
4938 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
|
4939 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4940 ll = ll->next; |
11869 | 4941 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4942 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4943 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4944 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4945 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4946 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
|
4947 const char *new_name, const char *new_alias) |
4359 | 4948 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4949 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4950 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4951 GaimGtkChatPane *gtkchat; |
11869 | 4952 GaimConvChatBuddyFlags flags; |
4359 | 4953 GtkTreeIter iter; |
4954 GtkTreeModel *model; | |
4955 int f = 1; | |
4956 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4957 chat = GAIM_CONV_CHAT(conv); |
4359 | 4958 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4959 gtkchat = gtkconv->u.chat; | |
4960 | |
9554 | 4961 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4962 | |
4963 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4964 return; | |
4965 | |
4966 while (f != 0) { | |
4967 char *val; | |
4968 | |
11869 | 4969 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4970 |
4971 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4972 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4973 g_free(val); | |
4359 | 4974 break; |
4975 } | |
9554 | 4976 |
4977 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4978 | |
4979 g_free(val); | |
4359 | 4980 } |
4981 | |
9554 | 4982 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4983 return; |
4984 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4985 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4986 |
11869 | 4987 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4988 } |
4989 | |
4990 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4991 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4992 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4993 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4994 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4995 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4996 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4997 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4998 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4999 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5000 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5001 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5002 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5003 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5004 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5005 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5006 |
12982 | 5007 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
|
5008 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5009 for (l = users; l != NULL; l = l->next) { |
9554 | 5010 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5011 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
5012 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 5013 continue; |
5014 | |
5015 do { | |
5016 char *val; | |
5017 | |
5018 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
5019 CHAT_USERS_NAME_COLUMN, &val, -1); | |
5020 | |
9696 | 5021 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
5022 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 5023 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 5024 #else |
5025 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5026 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5027 #endif | |
5028 } | |
9554 | 5029 else |
5030 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5031 | |
5032 g_free(val); | |
5033 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5034 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5035 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5036 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5037 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5038 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5039 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5040 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5041 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5042 |
9554 | 5043 static void |
5044 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
5045 { | |
5046 GaimConvChat *chat; | |
11869 | 5047 GaimConvChatBuddyFlags flags; |
9554 | 5048 GaimGtkConversation *gtkconv; |
5049 GaimGtkChatPane *gtkchat; | |
5050 GtkTreeIter iter; | |
5051 GtkTreeModel *model; | |
5052 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5053 char *alias = NULL; |
9554 | 5054 |
5055 chat = GAIM_CONV_CHAT(conv); | |
5056 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5057 gtkchat = gtkconv->u.chat; | |
5058 | |
5059 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
5060 | |
5061 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5062 return; | |
5063 | |
5064 while (f != 0) { | |
5065 char *val; | |
5066 | |
5067 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5068 | |
5069 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
5070 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 5071 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
5072 g_free(val); | |
5073 break; | |
5074 } | |
5075 | |
5076 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5077 | |
5078 g_free(val); | |
5079 } | |
5080 | |
5081 if (!gaim_conv_chat_find_user(chat, user)) | |
12982 | 5082 { |
5083 g_free(alias); | |
9554 | 5084 return; |
12982 | 5085 } |
9554 | 5086 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5087 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5088 |
11869 | 5089 flags = gaim_conv_chat_user_get_flags(chat, user); |
5090 | |
5091 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5092 g_free(alias); |
9554 | 5093 } |
5094 | |
11581 | 5095 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5096 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5097 { |
11581 | 5098 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
5099 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5100 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5101 |
11581 | 5102 win = gtkconv->win; |
5103 | |
5104 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
|
5105 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5106 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5107 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5108 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
5109 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5110 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5111 |
12335 | 5112 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data) |
5113 { | |
5114 GtkIMHtmlSmiley *smiley; | |
12682 | 5115 |
12335 | 5116 smiley = (GtkIMHtmlSmiley *)user_data; |
5117 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
12682 | 5118 |
12335 | 5119 if (smiley->icon) |
5120 g_object_ref(G_OBJECT(smiley->icon)); | |
12682 | 5121 #ifdef DEBUG_CUSTOM_SMILEY |
5122 gaim_debug_info("custom-smiley", "gaim_gtkconv_custom_smiley_allocated(): got GdkPixbufAnimation %p for smiley '%s'\n", smiley->icon, smiley->smile); | |
12335 | 5123 #endif |
5124 } | |
5125 | |
5126 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data) | |
5127 { | |
5128 GtkIMHtmlSmiley *smiley; | |
5129 GtkWidget *icon = NULL; | |
5130 GtkTextChildAnchor *anchor = NULL; | |
5131 GSList *current = NULL; | |
12682 | 5132 |
12335 | 5133 smiley = (GtkIMHtmlSmiley *)user_data; |
5134 if (!smiley->imhtml) { | |
5135 #ifdef DEBUG_CUSTOM_SMILEY | |
12682 | 5136 gaim_debug_error("custom-smiley", "gaim_gtkconv_custom_smiley_closed(): orphan smiley found: %p\n", smiley); |
12335 | 5137 #endif |
5138 g_object_unref(G_OBJECT(loader)); | |
5139 smiley->loader = NULL; | |
5140 return; | |
5141 } | |
5142 | |
5143 for (current = smiley->anchors; current; current = g_slist_next(current)) { | |
5144 | |
5145 icon = gtk_image_new_from_animation(smiley->icon); | |
5146 | |
12682 | 5147 #ifdef DEBUG_CUSTOM_SMILEY |
5148 gaim_debug_info("custom-smiley", "gaim_gtkconv_custom_smiley_closed(): got GtkImage %p from GtkPixbufAnimation %p for smiley '%s'\n", | |
5149 icon, smiley->icon, smiley->smile); | |
12335 | 5150 #endif |
5151 if (icon) { | |
5152 gtk_widget_show(icon); | |
12682 | 5153 |
12335 | 5154 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
5155 | |
13518
cd21f1738063
[gaim-migrate @ 15894]
Richard Laager <rlaager@wiktel.com>
parents:
13505
diff
changeset
|
5156 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", gaim_unescape_html(smiley->smile), g_free); |
12335 | 5157 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley->smile), g_free); |
12682 | 5158 |
12335 | 5159 if (smiley->imhtml) |
5160 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(smiley->imhtml), icon, anchor); | |
5161 } | |
5162 | |
5163 } | |
5164 | |
5165 g_slist_free(smiley->anchors); | |
5166 smiley->anchors = NULL; | |
12682 | 5167 |
12335 | 5168 g_object_unref(G_OBJECT(loader)); |
5169 smiley->loader = NULL; | |
5170 } | |
5171 | |
10526 | 5172 static gboolean |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5173 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
|
5174 { |
10526 | 5175 GtkIMHtmlSmiley *smiley; |
5176 GdkPixbufLoader *loader; | |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5177 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5178 smiley = gtk_imhtml_smiley_get(imhtml, sml, smile); |
10526 | 5179 |
5180 if (smiley) { | |
11525 | 5181 |
5182 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
5183 return FALSE; | |
5184 } | |
5185 | |
5186 /* Close the old GdkPixbufAnimation, then create a new one for | |
5187 * the smiley we are about to receive */ | |
5188 g_object_unref(G_OBJECT(smiley->icon)); | |
5189 | |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5190 /* XXX: Is it necessary to _unref the loader first? */ |
11525 | 5191 smiley->loader = gdk_pixbuf_loader_new(); |
12335 | 5192 smiley->icon = NULL; |
5193 | |
5194 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); | |
5195 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
5196 | |
11525 | 5197 return TRUE; |
10526 | 5198 } |
5199 | |
5200 loader = gdk_pixbuf_loader_new(); | |
5201 | |
5202 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
5203 /* 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
|
5204 GtkIMHtmlSmiley by opaque */ |
10526 | 5205 smiley = g_new0(GtkIMHtmlSmiley, 1); |
5206 smiley->file = NULL; | |
5207 smiley->smile = g_strdup(smile); | |
5208 smiley->loader = loader; | |
11525 | 5209 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 5210 |
12335 | 5211 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); |
5212 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
11525 | 5213 |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5214 gtk_imhtml_associate_smiley(imhtml, sml, smiley); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5215 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5216 return TRUE; |
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 static gboolean |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5220 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
|
5221 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5222 GaimGtkConversation *gtkconv; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5223 struct smiley_list *list; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5224 const char *sml = NULL, *conv_sml; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5225 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5226 if (!conv || !smile || !*smile) { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5227 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5228 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5229 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5230 /* If smileys are off, return false */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5231 if (gaim_gtkthemes_smileys_disabled()) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5232 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5233 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5234 /* If possible add this smiley to the current theme. |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5235 * 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
|
5236 conv_sml = gaim_account_get_protocol_name(conv->account); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5237 gtkconv = GAIM_GTK_CONVERSATION(conv); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5238 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5239 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
|
5240 if (!strcmp(list->sml, conv_sml)) { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5241 sml = list->sml; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5242 break; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5243 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5244 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5245 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5246 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
|
5247 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5248 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5249 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
|
5250 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
|
5251 return FALSE; |
10537 | 5252 |
10526 | 5253 return TRUE; |
5254 } | |
5255 | |
10537 | 5256 static void |
10526 | 5257 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 5258 const guchar *data, gsize size) |
10526 | 5259 { |
5260 GaimGtkConversation *gtkconv; | |
5261 GtkIMHtmlSmiley *smiley; | |
10537 | 5262 GdkPixbufLoader *loader; |
10526 | 5263 const char *sml; |
5264 | |
5265 sml = gaim_account_get_protocol_name(conv->account); | |
5266 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5267 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5268 | |
10537 | 5269 if (!smiley) |
10526 | 5270 return; |
10537 | 5271 |
10526 | 5272 loader = smiley->loader; |
10537 | 5273 if (!loader) |
10526 | 5274 return; |
5275 | |
5276 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
5277 } | |
5278 | |
5279 static void | |
5280 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
5281 { | |
5282 GaimGtkConversation *gtkconv; | |
5283 GtkIMHtmlSmiley *smiley; | |
5284 GdkPixbufLoader *loader; | |
5285 const char *sml; | |
5286 | |
5287 g_return_if_fail(conv != NULL); | |
5288 g_return_if_fail(smile != NULL); | |
5289 | |
5290 sml = gaim_account_get_protocol_name(conv->account); | |
5291 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5292 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5293 | |
10537 | 5294 if (!smiley) |
10526 | 5295 return; |
5296 | |
5297 loader = smiley->loader; | |
5298 | |
10537 | 5299 if (!loader) |
10526 | 5300 return; |
10537 | 5301 |
12335 | 5302 |
11525 | 5303 |
10526 | 5304 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
5305 | |
5306 gdk_pixbuf_loader_close(loader, NULL); | |
12335 | 5307 |
10526 | 5308 } |
5309 | |
11581 | 5310 /* |
5311 * Makes sure all the menu items and all the buttons are hidden/shown and | |
5312 * sensitive/insensitive. This is called after changing tabs and when an | |
5313 * account signs on or off. | |
5314 */ | |
5315 static void | |
5316 gray_stuff_out(GaimGtkConversation *gtkconv) | |
5317 { | |
5318 GaimGtkWindow *win; | |
5319 GaimConversation *conv = gtkconv->active_conv; | |
5320 GaimConnection *gc; | |
5321 GaimPluginProtocolInfo *prpl_info = NULL; | |
5322 GdkPixbuf *window_icon = NULL; | |
5323 GtkIMHtmlButtons buttons; | |
5324 GaimAccount *account; | |
5325 | |
5326 win = gaim_gtkconv_get_window(gtkconv); | |
5327 gc = gaim_conversation_get_gc(conv); | |
5328 account = gaim_conversation_get_account(conv); | |
5329 | |
5330 if (gc != NULL) | |
5331 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
5332 | |
11594 | 5333 if (win->menu.send_to != NULL) |
11734 | 5334 update_send_to_selection(win); |
11581 | 5335 |
5336 /* | |
5337 * Handle hiding and showing stuff based on what type of conv this is. | |
5338 * Stuff that Gaim IMs support in general should be shown for IM | |
5339 * conversations. Stuff that Gaim chats support in general should be | |
5340 * shown for chat conversations. It doesn't matter whether the PRPL | |
5341 * supports it or not--that only affects if the button or menu item | |
5342 * is sensitive or not. | |
5343 */ | |
5344 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
5345 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
5346 | |
5347 /* Deal with menu items */ | |
5348 gtk_widget_show(win->menu.view_log); | |
5349 gtk_widget_show(win->menu.send_file); | |
5350 gtk_widget_show(win->menu.add_pounce); | |
5351 gtk_widget_show(win->menu.get_info); | |
5352 gtk_widget_hide(win->menu.invite); | |
5353 gtk_widget_show(win->menu.alias); | |
5354 gtk_widget_show(win->menu.block); | |
5355 | |
13131 | 5356 if ((account == NULL) || gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { |
11581 | 5357 gtk_widget_show(win->menu.add); |
5358 gtk_widget_hide(win->menu.remove); | |
5359 } else { | |
5360 gtk_widget_show(win->menu.remove); | |
5361 gtk_widget_hide(win->menu.add); | |
5362 } | |
5363 | |
5364 gtk_widget_show(win->menu.insert_link); | |
5365 gtk_widget_show(win->menu.insert_image); | |
5366 gtk_widget_show(win->menu.show_icon); | |
5367 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
5368 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
5369 | |
5370 /* Deal with menu items */ | |
5371 gtk_widget_show(win->menu.view_log); | |
5372 gtk_widget_hide(win->menu.send_file); | |
5373 gtk_widget_hide(win->menu.add_pounce); | |
5374 gtk_widget_hide(win->menu.get_info); | |
5375 gtk_widget_show(win->menu.invite); | |
5376 gtk_widget_show(win->menu.alias); | |
5377 gtk_widget_hide(win->menu.block); | |
5378 gtk_widget_hide(win->menu.show_icon); | |
5379 | |
13131 | 5380 if ((account == NULL) || gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { |
11581 | 5381 /* If the chat is NOT in the buddy list */ |
5382 gtk_widget_show(win->menu.add); | |
5383 gtk_widget_hide(win->menu.remove); | |
5384 } else { | |
5385 /* If the chat IS in the buddy list */ | |
5386 gtk_widget_hide(win->menu.add); | |
5387 gtk_widget_show(win->menu.remove); | |
5388 } | |
5389 | |
5390 gtk_widget_show(win->menu.insert_link); | |
5391 gtk_widget_hide(win->menu.insert_image); | |
5392 } | |
5393 | |
5394 /* | |
5395 * Handle graying stuff out based on whether an account is connected | |
5396 * and what features that account supports. | |
5397 */ | |
5398 if ((gc != NULL) && | |
12012 | 5399 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
5400 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
5401 { | |
11581 | 5402 /* Account is online */ |
5403 /* Deal with the toolbar */ | |
12012 | 5404 if (conv->features & GAIM_CONNECTION_HTML) |
5405 { | |
5406 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
5407 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
5408 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
5409 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
5410 { | |
5411 buttons &= ~GTK_IMHTML_GROW; | |
5412 buttons &= ~GTK_IMHTML_SHRINK; | |
5413 } | |
5414 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
5415 buttons &= ~GTK_IMHTML_LINKDESC; | |
5416 } else { | |
12216 | 5417 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
12012 | 5418 } |
12216 | 5419 |
5420 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
5421 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
5422 buttons &= ~GTK_IMHTML_IMAGE; | |
5423 | |
12012 | 5424 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); |
13131 | 5425 if (account != NULL) |
5426 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 5427 |
5428 /* Deal with menu items */ | |
12012 | 5429 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5430 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5431 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
5432 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
5433 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 5434 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 5435 |
5436 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
5437 { | |
5438 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
5439 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
5440 gtk_widget_set_sensitive(win->menu.send_file, | |
5441 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
5442 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
5443 gtk_widget_set_sensitive(win->menu.alias, | |
13131 | 5444 (account != NULL) && |
12012 | 5445 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); |
5446 } | |
5447 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5448 { | |
5449 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
5450 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
5451 gtk_widget_set_sensitive(win->menu.alias, | |
13131 | 5452 (account != NULL) && |
12012 | 5453 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); |
5454 } | |
11581 | 5455 |
5456 /* Deal with chat userlist buttons */ | |
12012 | 5457 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5458 { | |
5459 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
5460 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
5461 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
5462 } | |
5463 } else { | |
11581 | 5464 /* Account is offline */ |
5465 /* Or it's a chat that we've left. */ | |
5466 | |
5467 /* Then deal with menu items */ | |
12012 | 5468 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5469 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
5470 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5471 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
5472 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
5473 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
5474 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
5475 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
5476 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
5477 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 5478 |
5479 /* Deal with chat userlist buttons */ | |
12012 | 5480 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5481 { | |
5482 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5483 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5484 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5485 } | |
5486 } | |
11581 | 5487 |
5488 /* | |
5489 * Update the window's icon | |
5490 */ | |
12171 | 5491 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5492 { |
12171 | 5493 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
5494 (gtkconv->u.im->anim)) | |
5495 { | |
5496 window_icon = | |
5497 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5498 g_object_ref(window_icon); | |
5499 } else { | |
5500 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5501 } | |
5502 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5503 if (window_icon != NULL) | |
5504 g_object_unref(G_OBJECT(window_icon)); | |
5505 } | |
11581 | 5506 } |
5507 | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5508 static void |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5509 gaim_gtkconv_update_fields(GaimConversation *conv, GaimGtkConvFields fields) |
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 GaimGtkConversation *gtkconv; |
11581 | 5512 GaimGtkWindow *win; |
10116 | 5513 |
4359 | 5514 gtkconv = GAIM_GTK_CONVERSATION(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5515 if (!gtkconv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5516 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5517 win = gaim_gtkconv_get_window(gtkconv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5518 if (!win) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5519 return; |
13090 | 5520 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5521 if (fields & GAIM_GTKCONV_SET_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5522 { |
4359 | 5523 gaim_conversation_autoset_title(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5524 } |
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 if (fields & GAIM_GTKCONV_BUDDY_ICON) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5527 { |
11338 | 5528 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5529 gaim_gtkconv_update_buddy_icon(conv); |
12797
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 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5532 if (fields & GAIM_GTKCONV_MENU) |
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 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5535 generate_send_to_items(win); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5536 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5537 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5538 if (fields & GAIM_GTKCONV_TAB_ICON) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5539 { |
6395 | 5540 update_tab_icon(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5541 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
|
5542 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5543 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5544 if ((fields & GAIM_GTKCONV_TOPIC) && |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5545 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5546 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5547 const char *topic; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5548 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5549 GaimGtkChatPane *gtkchat = gtkconv->u.chat; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5550 |
13350
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5551 if (gtkchat->topic_text != NULL) |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5552 { |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5553 topic = gaim_conv_chat_get_topic(chat); |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5554 |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5555 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5556 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5557 topic ? topic : "", NULL); |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5558 } |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5559 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5560 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5561 if (fields & GAIM_GTKCONV_SMILEY_THEME) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5562 gaim_gtkthemes_smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5563 |
13131 | 5564 if ((fields & GAIM_GTKCONV_COLORIZE_TITLE) || |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5565 (fields & GAIM_GTKCONV_SET_TITLE)) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5566 { |
9472 | 5567 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5568 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5569 GaimAccount *account = gaim_conversation_get_account(conv); |
13521
d593b7d4f29c
[gaim-migrate @ 15897]
Richard Laager <rlaager@wiktel.com>
parents:
13519
diff
changeset
|
5570 AtkObject *accessibility_obj; |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5571 /* 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
|
5572 char style[51]; |
4736 | 5573 |
11338 | 5574 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5575 im = GAIM_CONV_IM(conv); |
4359 | 5576 |
13131 | 5577 if ((account == NULL) || |
5578 !gaim_account_is_connected(account) || | |
5579 ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5580 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) | |
9472 | 5581 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); |
5582 else | |
5583 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5584 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5585 *style = '\0'; |
4359 | 5586 |
5587 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5588 gtk_widget_realize(gtkconv->tab_label); | |
5589 | |
13521
d593b7d4f29c
[gaim-migrate @ 15897]
Richard Laager <rlaager@wiktel.com>
parents:
13519
diff
changeset
|
5590 accessibility_obj = gtk_widget_get_accessible(gtkconv->tab_cont); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5591 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5592 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5593 { |
13521
d593b7d4f29c
[gaim-migrate @ 15897]
Richard Laager <rlaager@wiktel.com>
parents:
13519
diff
changeset
|
5594 atk_object_set_description(accessibility_obj, _("Typing")); |
11759 | 5595 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5596 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5597 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5598 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5599 { |
13536
977714c5e8a6
[gaim-migrate @ 15913]
Richard Laager <rlaager@wiktel.com>
parents:
13525
diff
changeset
|
5600 atk_object_set_description(accessibility_obj, _("Stopped Typing")); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5601 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5602 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5603 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5604 { |
13536
977714c5e8a6
[gaim-migrate @ 15913]
Richard Laager <rlaager@wiktel.com>
parents:
13525
diff
changeset
|
5605 atk_object_set_description(accessibility_obj, _("Nick Said")); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5606 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5607 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5608 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5609 { |
13521
d593b7d4f29c
[gaim-migrate @ 15897]
Richard Laager <rlaager@wiktel.com>
parents:
13519
diff
changeset
|
5610 atk_object_set_description(accessibility_obj, _("Unread Messages")); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5611 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5612 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5613 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5614 { |
13536
977714c5e8a6
[gaim-migrate @ 15913]
Richard Laager <rlaager@wiktel.com>
parents:
13525
diff
changeset
|
5615 atk_object_set_description(accessibility_obj, _("New Event")); |
11758 | 5616 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5617 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5618 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5619 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5620 { |
8536 | 5621 char *html_title,*label; |
5622 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5623 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5624 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5625 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5626 style, html_title); |
8536 | 5627 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5628 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5629 g_free(label); |
4359 | 5630 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5631 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5632 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5633 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5634 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5635 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5636 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5637 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5638 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5639 gtk_window_set_title(GTK_WINDOW(win->window), title); |
9472 | 5640 |
5641 g_free(title); | |
4359 | 5642 } |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5643 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5644 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5645 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5646 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5647 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5648 GaimGtkConvFields flags = 0; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5649 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5650 g_return_if_fail(conv != NULL); |
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 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5653 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5654 flags = GAIM_GTKCONV_ALL; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5655 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5656 else if (type == GAIM_CONV_UPDATE_TYPING || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5657 type == GAIM_CONV_UPDATE_UNSEEN || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5658 type == GAIM_CONV_UPDATE_TITLE) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5659 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5660 flags = GAIM_GTKCONV_COLORIZE_TITLE; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5661 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5662 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5663 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5664 flags = GAIM_GTKCONV_TOPIC; |
4359 | 5665 } |
5666 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5667 type == GAIM_CONV_ACCOUNT_OFFLINE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5668 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5669 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
|
5670 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5671 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5672 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5673 flags = GAIM_GTKCONV_TAB_ICON; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5674 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5675 else if (type == GAIM_CONV_UPDATE_ADD || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5676 type == GAIM_CONV_UPDATE_REMOVE || |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5677 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5678 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5679 flags = GAIM_GTKCONV_SET_TITLE | GAIM_GTKCONV_MENU; |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5680 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5681 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5682 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5683 flags = GAIM_GTKCONV_BUDDY_ICON; |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5684 } |
10665 | 5685 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5686 { | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5687 flags = GAIM_GTKCONV_MENU; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5688 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5689 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5690 gaim_gtkconv_update_fields(conv, flags); |
4359 | 5691 } |
5692 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5693 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5694 { |
11581 | 5695 gaim_gtkconv_new, |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5696 gaim_gtkconv_destroy, /* destroy_conversation */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5697 NULL, /* write_chat */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5698 gaim_gtkconv_write_im, /* write_im */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5699 gaim_gtkconv_write_conv, /* write_conv */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5700 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5701 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5702 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5703 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5704 gaim_gtkconv_present_conversation, /* present */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5705 gaim_gtkconv_has_focus, /* has_focus */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5706 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5707 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5708 gaim_gtkconv_custom_smiley_close /* custom_smiley_close */ |
4359 | 5709 }; |
5710 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5711 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5712 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5713 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5714 return &conversation_ui_ops; |
4359 | 5715 } |
5716 | |
5717 /************************************************************************** | |
5718 * Public conversation utility functions | |
5719 **************************************************************************/ | |
5720 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5721 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5722 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5723 GaimGtkConversation *gtkconv; |
11581 | 5724 GaimGtkWindow *win; |
4359 | 5725 |
10381 | 5726 GdkPixbufLoader *loader; |
5727 GdkPixbufAnimation *anim; | |
4359 | 5728 GError *err = NULL; |
5729 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5730 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5731 size_t len; |
4359 | 5732 |
5733 GdkPixbuf *buf; | |
5734 | |
5735 GtkWidget *event; | |
5736 GtkWidget *frame; | |
5737 GdkPixbuf *scale; | |
9318 | 5738 int scale_width, scale_height; |
5739 | |
5740 GaimAccount *account; | |
5741 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5742 |
9324 | 5743 GaimBuddyIcon *icon; |
5744 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5745 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5746 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5747 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5748 |
5749 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5750 win = gtkconv->win; |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5751 if (conv != gtkconv->active_conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5752 return; |
10175 | 5753 |
9687 | 5754 if (!gtkconv->u.im->show_icon) |
5755 return; | |
5756 | |
9318 | 5757 account = gaim_conversation_get_account(conv); |
5758 if(account && account->gc) | |
5759 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5760 |
9845 | 5761 /* Remove the current icon stuff */ |
9885 | 5762 if (gtkconv->u.im->icon_container != NULL) |
5763 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5764 gtkconv->u.im->icon_container = NULL; | |
9845 | 5765 |
5766 if (gtkconv->u.im->anim != NULL) | |
5767 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5768 | |
9887 | 5769 gtkconv->u.im->anim = NULL; |
5770 | |
9845 | 5771 if (gtkconv->u.im->icon_timer != 0) |
5772 g_source_remove(gtkconv->u.im->icon_timer); | |
5773 | |
5774 gtkconv->u.im->icon_timer = 0; | |
5775 | |
5776 if (gtkconv->u.im->iter != NULL) | |
5777 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5778 |
10116 | 5779 gtkconv->u.im->iter = NULL; |
5780 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5781 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5782 return; |
5783 | |
5784 if (gaim_conversation_get_gc(conv) == NULL) | |
5785 return; | |
5786 | |
9324 | 5787 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5788 | |
5789 if (icon == NULL) | |
5790 return; | |
5791 | |
5792 data = gaim_buddy_icon_get_data(icon, &len); | |
5793 | |
10381 | 5794 loader = gdk_pixbuf_loader_new(); |
5795 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
12601
e63fb8e9f4ac
[gaim-migrate @ 14935]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
5796 gdk_pixbuf_loader_close(loader, &err); |
10381 | 5797 anim = gdk_pixbuf_loader_get_animation(loader); |
5798 if (anim) | |
5799 g_object_ref(G_OBJECT(anim)); | |
5800 g_object_unref(loader); | |
5801 | |
5802 if (!anim) | |
9324 | 5803 return; |
10381 | 5804 gtkconv->u.im->anim = anim; |
9324 | 5805 |
4359 | 5806 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5807 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5808 "Buddy icon error: %s\n", err->message); |
4359 | 5809 g_error_free(err); |
5810 } | |
5811 | |
5812 if (!gtkconv->u.im->anim) | |
5813 return; | |
5814 | |
5815 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5816 gtkconv->u.im->iter = NULL; | |
5817 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5818 } else { | |
5819 gtkconv->u.im->iter = | |
8496 | 5820 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5821 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5822 if (gtkconv->u.im->animate) |
10810 | 5823 start_anim(NULL, gtkconv); |
4359 | 5824 } |
5825 | |
10483 | 5826 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5827 NULL, &scale_width, &scale_height); |
4359 | 5828 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5829 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5830 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5831 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5832 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5833 GDK_INTERP_BILINEAR); |
4359 | 5834 |
9885 | 5835 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5836 |
4359 | 5837 frame = gtk_frame_new(NULL); |
13690
6a86f4ec744e
[gaim-migrate @ 16093]
Richard Laager <rlaager@wiktel.com>
parents:
13663
diff
changeset
|
5838 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); |
9885 | 5839 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5840 FALSE, FALSE, 0); | |
8821 | 5841 |
4359 | 5842 event = gtk_event_box_new(); |
5843 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5844 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5845 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5846 gtk_widget_show(event); |
5847 | |
13690
6a86f4ec744e
[gaim-migrate @ 16093]
Richard Laager <rlaager@wiktel.com>
parents:
13663
diff
changeset
|
5848 gtkconv->u.im->icon = gtk_image_new_from_pixbuf(scale); |
9318 | 5849 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5850 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5851 gtk_widget_show(gtkconv->u.im->icon); | |
5852 | |
13690
6a86f4ec744e
[gaim-migrate @ 16093]
Richard Laager <rlaager@wiktel.com>
parents:
13663
diff
changeset
|
5853 g_object_unref(G_OBJECT(scale)); |
7143 | 5854 |
10356 | 5855 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5856 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5857 |
9885 | 5858 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5859 gtk_widget_show(frame); |
5860 | |
7143 | 5861 /* The buddy icon code needs badly to be fixed. */ |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5862 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
5863 { |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
5864 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); |
11581 | 5865 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
5866 } |
4359 | 5867 } |
5868 | |
5869 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5870 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5871 { |
11581 | 5872 GaimGtkWindow *win; |
4359 | 5873 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5874 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5875 return; |
5876 | |
11581 | 5877 win = GAIM_GTK_CONVERSATION(conv)->win; |
5878 | |
5879 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5880 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5881 } |
5882 | |
5883 int | |
11614 | 5884 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5885 { |
4359 | 5886 gint nb_x, nb_y, x_rel, y_rel; |
5887 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5888 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5889 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5890 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5891 gboolean horiz; |
4359 | 5892 |
11614 | 5893 if (to_right) |
5894 *to_right = FALSE; | |
5895 | |
11581 | 5896 notebook = GTK_NOTEBOOK(win->notebook); |
5897 | |
5898 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5899 x_rel = x - nb_x; |
5900 y_rel = y - nb_y; | |
5901 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5902 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5903 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5904 |
11780 | 5905 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5906 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5907 #else |
5908 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5909 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5910 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5911 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5912 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5913 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5914 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5915 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5916 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5917 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5918 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5919 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
|
5920 page_num = i; |
11614 | 5921 |
5922 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5923 *to_right = TRUE; | |
5924 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5925 break; |
4359 | 5926 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5927 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5928 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5929 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
|
5930 page_num = i; |
11614 | 5931 |
5932 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5933 *to_right = TRUE; | |
5934 | |
4359 | 5935 break; |
5936 } | |
5937 } | |
5938 } | |
5939 | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5940 if (page_num == -1) { |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5941 /* Add after the last tab */ |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5942 page_num = count - 1; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5943 } |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5944 |
4359 | 5945 return page_num; |
5946 } | |
5947 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5948 static void |
12816 | 5949 close_on_tabs_pref_cb(const char *name, GaimPrefType type, |
5950 gconstpointer value, gpointer data) | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5951 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5952 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5953 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5954 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5955 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5956 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5957 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5958 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5959 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5960 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5961 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5962 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5963 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5964 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5965 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5966 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5967 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5968 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5969 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5970 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5971 static void |
12816 | 5972 spellcheck_pref_cb(const char *name, GaimPrefType type, |
5973 gconstpointer value, gpointer data) | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5974 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5975 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5976 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5977 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5978 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5979 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5980 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5981 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5982 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5983 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5984 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5985 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5986 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5987 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5988 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5989 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5990 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5991 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5992 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5993 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5994 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5995 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5996 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5997 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5998 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5999 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6000 static void |
12816 | 6001 tab_side_pref_cb(const char *name, GaimPrefType type, |
6002 gconstpointer value, gpointer data) | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6003 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6004 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6005 GtkPositionType pos; |
11581 | 6006 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6007 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6008 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6009 |
11581 | 6010 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
6011 win = l->data; | |
6012 | |
11619 | 6013 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
|
6014 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6015 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6016 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6017 static void |
12188 | 6018 show_timestamps_pref_cb(const char *name, GaimPrefType type, |
12816 | 6019 gconstpointer value, gpointer data) |
12188 | 6020 { |
6021 GList *l; | |
6022 GaimConversation *conv; | |
6023 GaimGtkConversation *gtkconv; | |
6024 GaimGtkWindow *win; | |
6025 | |
6026 for (l = gaim_get_conversations(); l != NULL; l = l->next) | |
6027 { | |
6028 conv = (GaimConversation *)l->data; | |
6029 | |
6030 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
6031 continue; | |
6032 | |
6033 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6034 win = gtkconv->win; | |
6035 | |
6036 gtk_check_menu_item_set_active( | |
6037 GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
6038 (gboolean)GPOINTER_TO_INT(value)); | |
6039 | |
6040 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
6041 (gboolean)GPOINTER_TO_INT(value)); | |
6042 } | |
6043 } | |
6044 | |
6045 static void | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6046 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
12816 | 6047 gconstpointer value, gpointer data) |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6048 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6049 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6050 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6051 GaimGtkConversation *gtkconv; |
11581 | 6052 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6053 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6054 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6055 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6056 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6057 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6058 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6059 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6060 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6061 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 6062 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6063 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6064 gtk_check_menu_item_set_active( |
11581 | 6065 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
6066 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 6067 |
6068 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 6069 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6070 else |
8317 | 6071 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6072 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6073 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6074 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6075 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6076 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
12816 | 6077 gconstpointer value, gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6078 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6079 GList *l; |
8189 | 6080 GaimConversation *conv; |
6081 GaimGtkConversation *gtkconv; | |
11581 | 6082 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6083 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6084 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
|
6085 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6086 |
8189 | 6087 /* Set the "animate" flag for each icon based on the new preference */ |
6088 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
6089 conv = (GaimConversation *)l->data; | |
6090 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 6091 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6092 } |
8189 | 6093 |
6094 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 6095 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
6096 win = l->data; | |
6097 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 6098 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6099 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6100 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6101 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6102 static void |
12816 | 6103 show_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
6104 gconstpointer value, gpointer data) | |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6105 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6106 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6107 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6108 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6109 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6110 |
11338 | 6111 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 6112 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6113 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6114 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6115 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
6116 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6117 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
12816 | 6118 gconstpointer value, gpointer data) |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6119 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6120 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6121 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6122 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6123 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6124 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6125 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6126 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6127 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6128 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6129 GaimGtkConversation *gtkconv; |
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(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
|
6132 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6133 |
12310 | 6134 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
|
6135 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6136 |
13139
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6137 while ((l = hidden_convwin->gtkconvs) != NULL) |
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6138 { |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6139 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6140 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6141 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6142 |
13525 | 6143 while(l && !gaim_status_is_available( |
12310 | 6144 gaim_account_get_active_status( |
6145 gaim_conversation_get_account(conv)))) | |
13525 | 6146 l = l->next; |
6147 if (!l) | |
6148 break; | |
12116
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 static void |
12816 | 6156 hide_new_pref_cb(const char *name, GaimPrefType type, |
6157 gconstpointer value, gpointer data) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6158 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6159 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6160 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6161 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6162 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6163 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6164 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6165 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6166 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6167 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
|
6168 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6169 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6170 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
|
6171 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6172 |
13139
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6173 while ((l = hidden_convwin->gtkconvs) != NULL) |
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6174 { |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6175 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6176 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6177 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6178 |
12310 | 6179 if(when_away && !gaim_status_is_available( |
6180 gaim_account_get_active_status( | |
6181 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6182 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6183 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6184 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6185 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6186 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6187 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6188 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6189 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6190 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6191 conv_placement_pref_cb(const char *name, GaimPrefType type, |
12816 | 6192 gconstpointer value, gpointer data) |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6193 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6194 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6195 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6196 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6197 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6198 |
11581 | 6199 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6200 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6201 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6202 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6203 |
11581 | 6204 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6205 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6206 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6207 static GaimGtkConversation * |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6208 get_gtkconv_with_contact(GaimContact *contact) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6209 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6210 GaimBlistNode *node; |
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 node = ((GaimBlistNode*)contact)->child; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6213 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6214 for (; node; node = node->next) |
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 GaimBuddy *buddy = (GaimBuddy*)node; |
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 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
|
6219 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6220 return GAIM_GTK_CONVERSATION(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6221 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6222 return NULL; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6223 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6224 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6225 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6226 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6227 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6228 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6229 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6230 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6231 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6232 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6233 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6234 /* 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
|
6235 * case of this account matching one of the other buddies in |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6236 * one of the contacts containing the buddy corresponding to |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6237 * a conversation. It's easier to just update them all. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6238 /* if (gaim_conversation_get_account(conv) == account) */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6239 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON | |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6240 GAIM_GTKCONV_MENU | GAIM_GTKCONV_COLORIZE_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6241 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6242 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6243 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6244 static gboolean |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6245 update_buddy_status_timeout(GaimBuddy *buddy) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6246 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6247 /* To remove the signing-on/off door icon */ |
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 return FALSE; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6255 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6256 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6257 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6258 update_buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *newstatus) |
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 GaimGtkConversation *gtkconv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6261 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6262 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6263 gtkconv = get_gtkconv_with_contact(gaim_buddy_get_contact(buddy)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6264 if (gtkconv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6265 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6266 conv = gtkconv->active_conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6267 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
|
6268 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
|
6269 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_MENU); |
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 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6272 /* 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
|
6273 g_timeout_add(11000, (GSourceFunc)update_buddy_status_timeout, buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6274 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6275 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6276 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6277 update_buddy_idle_changed(GaimBuddy *buddy, gboolean old, gboolean newidle) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6278 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6279 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6280 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6281 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
|
6282 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6283 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6284 } |
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 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6287 update_buddy_icon(GaimBuddy *buddy) |
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 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6290 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6291 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
|
6292 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6293 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_BUDDY_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6294 } |
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 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6297 update_buddy_sign(GaimBuddy *buddy, const char *which) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6298 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6299 GaimPresence *presence; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6300 GaimStatus *on, *off; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6301 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6302 presence = gaim_buddy_get_presence(buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6303 if (!presence) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6304 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6305 off = gaim_presence_get_status(presence, "offline"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6306 on = gaim_presence_get_status(presence, "available"); |
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 if (*(which+1) == 'f') |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6309 update_buddy_status_changed(buddy, on, off); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6310 else |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6311 update_buddy_status_changed(buddy, off, on); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6312 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6313 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6314 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6315 update_conversation_switched(GaimConversation *conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6316 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6317 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
|
6318 GAIM_GTKCONV_MENU | GAIM_GTKCONV_BUDDY_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6319 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6320 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6321 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6322 update_buddy_typing(GaimAccount *account, const char *who) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6323 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6324 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6325 GaimGtkConversation *gtkconv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6326 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6327 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
|
6328 if (!conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6329 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6330 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6331 gtkconv = GAIM_GTK_CONVERSATION(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6332 if (gtkconv && gtkconv->active_conv == conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6333 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_COLORIZE_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6334 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6335 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6336 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6337 update_chat(GaimConversation *conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6338 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6339 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TOPIC | |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6340 GAIM_GTKCONV_MENU | GAIM_GTKCONV_SET_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6341 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6342 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6343 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6344 update_chat_topic(GaimConversation *conv, const char *old, const char *new) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6345 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6346 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TOPIC); |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6347 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6348 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6349 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6350 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6351 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6352 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6353 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6354 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6355 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6356 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6357 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
6358 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6359 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6360 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6361 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6362 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6363 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6364 gaim_prefs_add_none("/gaim/gtk/conversations"); |
12553 | 6365 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
|
6366 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6367 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6368 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6369 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6370 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
6371 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
6372 |
12264 | 6373 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6374 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 6375 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 6376 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6377 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 6378 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 6379 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
6380 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6381 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6382 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6383 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6384 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
|
6385 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6386 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6387 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6388 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6389 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6390 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6391 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6392 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6393 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6394 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 6395 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6396 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 6397 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6398 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6399 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6400 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 6401 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
|
6402 |
12616
eee2042ad4f4
[gaim-migrate @ 14952]
Richard Laager <rlaager@wiktel.com>
parents:
12604
diff
changeset
|
6403 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
|
6404 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6405 /* Connect callbacks. */ |
10087 | 6406 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
|
6407 close_on_tabs_pref_cb, NULL); |
12188 | 6408 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
6409 show_timestamps_pref_cb, NULL); | |
10087 | 6410 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
|
6411 show_formatting_toolbar_pref_cb, NULL); |
10087 | 6412 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6413 spellcheck_pref_cb, NULL); |
10087 | 6414 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6415 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6416 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6417 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6418 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6419 |
10087 | 6420 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6421 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6422 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6423 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6424 /* IM callbacks */ |
10087 | 6425 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
|
6426 animate_buddy_icons_pref_cb, NULL); |
10087 | 6427 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
|
6428 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6429 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6430 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6431 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6432 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6433 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6434 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6435 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6436 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
6437 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6438 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
12837
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6439 gaim_value_new(GAIM_TYPE_BOXED, |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6440 "GaimGtkWindow *"), |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6441 gaim_value_new(GAIM_TYPE_BOXED, |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6442 "GaimGtkWindow *")); |
9167 | 6443 |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6444 gaim_signal_register(handle, "conversation-timestamp", |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6445 gaim_marshal_POINTER__POINTER_POINTER, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6446 gaim_value_new(GAIM_TYPE_POINTER), 2, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6447 gaim_value_new(GAIM_TYPE_SUBTYPE, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6448 GAIM_SUBTYPE_CONVERSATION), |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6449 gaim_value_new(GAIM_TYPE_POINTER)); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6450 |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6451 gaim_signal_register(handle, "displaying-im-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6452 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6453 gaim_value_new(GAIM_TYPE_BOOLEAN), 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6454 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6455 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6456 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6457 gaim_value_new_outgoing(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6458 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6459 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6460 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6461 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6462 gaim_signal_register(handle, "displayed-im-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6463 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6464 NULL, 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6465 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6466 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6467 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6468 gaim_value_new(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6469 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6470 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6471 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6472 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6473 gaim_signal_register(handle, "displaying-chat-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6474 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6475 gaim_value_new(GAIM_TYPE_BOOLEAN), 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6476 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6477 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6478 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6479 gaim_value_new_outgoing(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6480 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6481 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6482 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6483 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6484 gaim_signal_register(handle, "displayed-chat-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6485 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6486 NULL, 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6487 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6488 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6489 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6490 gaim_value_new(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6491 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6492 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6493 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6494 |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6495 gaim_signal_register(handle, "conversation-switched", |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6496 gaim_marshal_VOID__POINTER_POINTER, NULL, 1, |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6497 gaim_value_new(GAIM_TYPE_SUBTYPE, |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6498 GAIM_SUBTYPE_CONVERSATION)); |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6499 |
9167 | 6500 /********************************************************************** |
6501 * Register commands | |
6502 **********************************************************************/ | |
9829 | 6503 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
6504 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
6505 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 6506 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
6507 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6508 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 6509 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
6510 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6511 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
|
6512 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6513 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6514 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 6515 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 6516 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
6517 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 6518 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6519 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6520 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6521 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6522 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6523 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6524 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6525 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6526 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6527 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6528 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6529 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6530 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6531 handle, G_CALLBACK(received_im_msg_cb), NULL); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6532 |
11581 | 6533 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6534 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6535 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6536 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6537 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6538 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6539 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6540 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6541 /* Callbacks to update a conversation */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6542 gaim_signal_connect(blist_handle, "buddy-added", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6543 G_CALLBACK(buddy_update_cb), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6544 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6545 G_CALLBACK(buddy_update_cb), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6546 gaim_signal_connect(blist_handle, "buddy-signed-on", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6547 handle, GAIM_CALLBACK(update_buddy_sign), "on"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6548 gaim_signal_connect(blist_handle, "buddy-signed-off", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6549 handle, GAIM_CALLBACK(update_buddy_sign), "off"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6550 gaim_signal_connect(blist_handle, "buddy-status-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6551 handle, GAIM_CALLBACK(update_buddy_status_changed), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6552 gaim_signal_connect(blist_handle, "buddy-idle-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6553 handle, GAIM_CALLBACK(update_buddy_idle_changed), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6554 gaim_signal_connect(blist_handle, "buddy-icon-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6555 handle, GAIM_CALLBACK(update_buddy_icon), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6556 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6557 handle, GAIM_CALLBACK(update_buddy_typing), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6558 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing-stopped", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6559 handle, GAIM_CALLBACK(update_buddy_typing), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6560 gaim_signal_connect(gaim_gtk_conversations_get_handle(), "conversation-switched", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6561 handle, GAIM_CALLBACK(update_conversation_switched), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6562 gaim_signal_connect(gaim_conversations_get_handle(), "chat-left", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6563 GAIM_CALLBACK(update_chat), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6564 gaim_signal_connect(gaim_conversations_get_handle(), "chat-joined", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6565 GAIM_CALLBACK(update_chat), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6566 gaim_signal_connect(gaim_conversations_get_handle(), "chat-topic-changed", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6567 GAIM_CALLBACK(update_chat_topic), NULL); |
12806
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6568 gaim_signal_connect_priority(gaim_conversations_get_handle(), "conversation-updated", handle, |
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6569 GAIM_CALLBACK(gaim_gtkconv_updated), NULL, |
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6570 GAIM_SIGNAL_PRIORITY_LOWEST); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6571 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6572 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6573 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6574 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6575 { |
10443 | 6576 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 6577 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6578 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6579 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6580 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6581 } |
11581 | 6582 |
6583 | |
6584 | |
6585 | |
6586 | |
6587 | |
6588 | |
6589 | |
6590 | |
6591 | |
6592 | |
6593 | |
6594 | |
6595 | |
6596 | |
6597 | |
6598 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
6599 * and touch each others' private members all day long */ | |
6600 | |
6601 /** | |
6602 * @file gtkconvwin.c GTK+ Conversation Window API | |
6603 * @ingroup gtkui | |
6604 * | |
6605 * gaim | |
6606 * | |
6607 * Gaim is the legal property of its developers, whose names are too numerous | |
6608 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6609 * source distribution. | |
6610 * | |
6611 * This program is free software; you can redistribute it and/or modify | |
6612 * it under the terms of the GNU General Public License as published by | |
6613 * the Free Software Foundation; either version 2 of the License, or | |
6614 * (at your option) any later version. | |
6615 * | |
6616 * This program is distributed in the hope that it will be useful, | |
6617 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
6618 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
6619 * GNU General Public License for more details. | |
6620 * | |
6621 * You should have received a copy of the GNU General Public License | |
6622 * along with this program; if not, write to the Free Software | |
6623 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
6624 * | |
6625 */ | |
6626 #include "internal.h" | |
6627 #include "gtkgaim.h" | |
6628 | |
6629 | |
6630 #include <gdk/gdkkeysyms.h> | |
6631 | |
6632 #include "account.h" | |
6633 #include "cmds.h" | |
6634 #include "debug.h" | |
6635 #include "imgstore.h" | |
6636 #include "log.h" | |
6637 #include "notify.h" | |
6638 #include "prpl.h" | |
6639 #include "request.h" | |
6640 #include "util.h" | |
6641 | |
6642 #include "gtkdnd-hints.h" | |
6643 #include "gtkblist.h" | |
6644 #include "gtkconv.h" | |
6645 #include "gtkdialogs.h" | |
6646 #include "gtkmenutray.h" | |
6647 #include "gtkpounce.h" | |
6648 #include "gtkprefs.h" | |
6649 #include "gtkprivacy.h" | |
6650 #include "gtkutils.h" | |
6651 #include "gtkstock.h" | |
6652 #include "gtkimhtml.h" | |
6653 #include "gtkimhtmltoolbar.h" | |
6654 | |
6655 static void | |
6656 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
6657 { | |
6658 gtk_widget_destroy(warn_close_dialog); | |
6659 warn_close_dialog = NULL; | |
6660 | |
6661 if (resp == GTK_RESPONSE_OK) | |
6662 gaim_gtk_conv_window_destroy(win); | |
6663 } | |
6664 | |
6665 static void | |
6666 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
6667 { | |
6668 GtkWidget *label; | |
6669 GtkWidget *vbox, *hbox; | |
6670 GtkWidget *img; | |
6671 | |
6672 g_return_if_fail(warn_close_dialog == NULL); | |
6673 | |
6674 | |
6675 warn_close_dialog = gtk_dialog_new_with_buttons( | |
12660 | 6676 _("Confirm close"), |
6677 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
6678 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
6679 GAIM_STOCK_CLOSE_TABS, GTK_RESPONSE_OK, NULL); | |
11581 | 6680 |
6681 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
6682 GTK_RESPONSE_OK); | |
6683 | |
6684 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
6685 6); | |
6686 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
6687 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
6688 FALSE); | |
6689 | |
6690 /* Setup the outside spacing. */ | |
6691 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
6692 | |
6693 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
6694 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
6695 | |
6696 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
6697 GTK_ICON_SIZE_DIALOG); | |
6698 /* Setup the inner hbox and put the dialog's icon in it. */ | |
6699 hbox = gtk_hbox_new(FALSE, 12); | |
6700 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
6701 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
6702 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
6703 | |
6704 /* Setup the right vbox. */ | |
6705 vbox = gtk_vbox_new(FALSE, 12); | |
6706 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
6707 | |
6708 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
6709 gtk_widget_set_size_request(label, 350, -1); | |
6710 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
6711 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
6712 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
6713 | |
6714 /* Connect the signals. */ | |
6715 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
6716 G_CALLBACK(do_close), gtkwin); | |
6717 | |
6718 } | |
6719 | |
6720 /************************************************************************** | |
6721 * Callbacks | |
6722 **************************************************************************/ | |
6723 | |
6724 static gboolean | |
6725 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
6726 { | |
6727 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6728 GList *l; |
11581 | 6729 |
6730 /* If there are unread messages then show a warning dialog */ | |
6731 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
6732 l != NULL; l = l->next) | |
6733 { | |
6734 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6735 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
|
6736 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6737 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6738 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6739 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6740 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6741 return TRUE; |
11581 | 6742 } |
6743 } | |
6744 | |
6745 gaim_gtk_conv_window_destroy(win); | |
6746 | |
6747 return TRUE; | |
6748 } | |
6749 | |
11604 | 6750 static void |
6751 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
6752 { | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6753 if (state == GAIM_UNSEEN_NONE) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6754 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6755 gtkconv->unseen_count = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6756 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6757 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6758 else |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6759 { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6760 if (state >= GAIM_UNSEEN_TEXT) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6761 gtkconv->unseen_count++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6762 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6763 if (state > gtkconv->unseen_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6764 gtkconv->unseen_state = state; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6765 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6766 |
12806
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6767 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
|
6768 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6769 |
11581 | 6770 /* |
6771 * When a conversation window is focused, we know the user | |
6772 * has looked at it so we know there are no longer unseen | |
6773 * messages. | |
6774 */ | |
6775 static gint | |
6776 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6777 { | |
6778 GaimGtkWindow *win = d; | |
11604 | 6779 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6780 | |
6781 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6782 |
6783 return FALSE; | |
6784 } | |
6785 | |
11851 | 6786 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6787 /* Courtesy of Galeon! */ |
6788 static void | |
6789 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6790 { | |
6791 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6792 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6793 } | |
11851 | 6794 #endif |
11581 | 6795 |
6796 static void | |
6797 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6798 { | |
6799 static GdkCursor *cursor = NULL; | |
6800 | |
6801 gtkwin->in_drag = TRUE; | |
6802 | |
6803 if (gtkwin->drag_leave_signal) { | |
6804 g_signal_handler_disconnect(G_OBJECT(widget), | |
6805 gtkwin->drag_leave_signal); | |
6806 gtkwin->drag_leave_signal = 0; | |
6807 } | |
6808 | |
6809 if (cursor == NULL) | |
6810 cursor = gdk_cursor_new(GDK_FLEUR); | |
6811 | |
6812 /* Grab the pointer */ | |
6813 gtk_grab_add(gtkwin->notebook); | |
6814 #ifndef _WIN32 | |
6815 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6816 always be true after a button press. */ | |
6817 if (!gdk_pointer_is_grabbed()) | |
6818 #endif | |
6819 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6820 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6821 NULL, cursor, GDK_CURRENT_TIME); | |
6822 } | |
6823 | |
6824 static gboolean | |
6825 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6826 { | |
6827 | |
6828 /* | |
6829 * Make sure the user moved the mouse far enough for the | |
6830 * drag to be initiated. | |
6831 */ | |
6832 if (win->in_predrag) { | |
6833 if (e->x_root < win->drag_min_x || | |
6834 e->x_root >= win->drag_max_x || | |
6835 e->y_root < win->drag_min_y || | |
6836 e->y_root >= win->drag_max_y) { | |
6837 | |
6838 win->in_predrag = FALSE; | |
6839 notebook_init_grab(win, widget); | |
6840 } | |
6841 } | |
6842 else { /* Otherwise, draw the arrows. */ | |
6843 GaimGtkWindow *dest_win; | |
6844 GtkNotebook *dest_notebook; | |
6845 GtkWidget *tab; | |
6846 gint nb_x, nb_y, page_num; | |
6847 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6848 gboolean horiz_tabs = FALSE; | |
11614 | 6849 GaimGtkConversation *gtkconv; |
6850 gboolean to_right = FALSE; | |
11581 | 6851 |
6852 /* Get the window that the cursor is over. */ | |
6853 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6854 | |
6855 if (dest_win == NULL) { | |
6856 dnd_hints_hide_all(); | |
6857 | |
6858 return TRUE; | |
6859 } | |
6860 | |
6861 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6862 | |
6863 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6864 | |
6865 arrow1_x = arrow2_x = nb_x; | |
6866 arrow1_y = arrow2_y = nb_y; | |
6867 | |
6868 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6869 e->x_root, e->y_root, &to_right); |
6870 to_right = to_right && (win != dest_win); | |
11581 | 6871 |
6872 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6873 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6874 | |
6875 horiz_tabs = TRUE; | |
6876 } | |
6877 | |
11614 | 6878 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6879 tab = gtkconv->tabby; | |
11581 | 6880 |
6881 if (horiz_tabs) { | |
6882 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6883 | |
11614 | 6884 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6885 arrow1_x += tab->allocation.width; |
6886 arrow2_x += tab->allocation.width; | |
6887 } | |
6888 | |
6889 arrow1_y = nb_y + tab->allocation.y; | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6890 arrow2_y = nb_y + tab->allocation.y + tab->allocation.height; |
11581 | 6891 } else { |
6892 arrow1_x = nb_x + tab->allocation.x; | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6893 arrow2_x = nb_x + tab->allocation.x + tab->allocation.width; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6894 arrow1_y = arrow2_y = nb_y + tab->allocation.y; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6895 |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6896 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6897 arrow1_y += tab->allocation.height; |
6898 arrow2_y += tab->allocation.height; | |
6899 } | |
6900 } | |
6901 | |
6902 if (horiz_tabs) { | |
6903 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6904 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6905 } else { | |
6906 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6907 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6908 } | |
6909 } | |
6910 | |
6911 return TRUE; | |
6912 } | |
6913 | |
6914 static gboolean | |
6915 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6916 { | |
6917 if (win->in_drag) | |
6918 return FALSE; | |
6919 | |
6920 if (e->x_root < win->drag_min_x || | |
6921 e->x_root >= win->drag_max_x || | |
6922 e->y_root < win->drag_min_y || | |
6923 e->y_root >= win->drag_max_y) { | |
6924 | |
6925 win->in_predrag = FALSE; | |
6926 notebook_init_grab(win, widget); | |
6927 } | |
6928 | |
6929 return TRUE; | |
6930 } | |
6931 | |
6932 /* | |
6933 * THANK YOU GALEON! | |
6934 */ | |
6935 static gboolean | |
6936 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6937 { | |
6938 gint nb_x, nb_y, x_rel, y_rel; | |
6939 int tab_clicked; | |
6940 GtkWidget *page; | |
6941 GtkWidget *tab; | |
6942 | |
6943 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6944 return FALSE; | |
6945 | |
6946 | |
6947 if (win->in_drag) { | |
6948 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6949 "Already in the middle of a window drag at tab_press_cb\n"); | |
6950 return TRUE; | |
6951 } | |
6952 | |
6953 /* | |
6954 * Make sure a tab was actually clicked. The arrow buttons | |
6955 * mess things up. | |
6956 */ | |
11614 | 6957 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6958 |
6959 if (tab_clicked == -1) | |
6960 return FALSE; | |
6961 | |
6962 /* | |
6963 * Get the relative position of the press event, with regards to | |
6964 * the position of the notebook. | |
6965 */ | |
6966 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6967 | |
6968 x_rel = e->x_root - nb_x; | |
6969 y_rel = e->y_root - nb_y; | |
6970 | |
6971 /* Reset the min/max x/y */ | |
6972 win->drag_min_x = 0; | |
6973 win->drag_min_y = 0; | |
6974 win->drag_max_x = 0; | |
6975 win->drag_max_y = 0; | |
6976 | |
6977 /* Find out which tab was dragged. */ | |
6978 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6979 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6980 | |
6981 win->drag_min_x = tab->allocation.x + nb_x; | |
6982 win->drag_min_y = tab->allocation.y + nb_y; | |
6983 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6984 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6985 | |
6986 /* Make sure the click occurred in the tab. */ | |
6987 if (e->x_root < win->drag_min_x || | |
6988 e->x_root >= win->drag_max_x || | |
6989 e->y_root < win->drag_min_y || | |
6990 e->y_root >= win->drag_max_y) { | |
6991 | |
6992 return FALSE; | |
6993 } | |
6994 | |
6995 win->in_predrag = TRUE; | |
6996 win->drag_tab = tab_clicked; | |
6997 | |
6998 /* Connect the new motion signals. */ | |
6999 win->drag_motion_signal = | |
7000 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
7001 G_CALLBACK(notebook_motion_cb), win); | |
7002 | |
7003 win->drag_leave_signal = | |
7004 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
7005 G_CALLBACK(notebook_leave_cb), win); | |
7006 | |
7007 return FALSE; | |
7008 } | |
7009 | |
7010 static gboolean | |
7011 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
7012 { | |
7013 GaimGtkWindow *dest_win; | |
7014 GaimConversation *conv; | |
7015 GaimGtkConversation *gtkconv; | |
7016 gint dest_page_num = 0; | |
7017 gboolean new_window = FALSE; | |
11614 | 7018 gboolean to_right = FALSE; |
11581 | 7019 |
7020 /* | |
7021 * Don't check to make sure that the event's window matches the | |
7022 * widget's, because we may be getting an event passed on from the | |
7023 * close button. | |
7024 */ | |
7025 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
7026 return FALSE; | |
7027 | |
7028 if (gdk_pointer_is_grabbed()) { | |
7029 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
7030 gtk_grab_remove(widget); | |
7031 } | |
7032 | |
7033 if (!win->in_predrag && !win->in_drag) | |
7034 return FALSE; | |
7035 | |
7036 /* Disconnect the motion signal. */ | |
7037 if (win->drag_motion_signal) { | |
7038 g_signal_handler_disconnect(G_OBJECT(widget), | |
7039 win->drag_motion_signal); | |
7040 | |
7041 win->drag_motion_signal = 0; | |
7042 } | |
7043 | |
7044 /* | |
7045 * If we're in a pre-drag, we'll also need to disconnect the leave | |
7046 * signal. | |
7047 */ | |
7048 if (win->in_predrag) { | |
7049 win->in_predrag = FALSE; | |
7050 | |
7051 if (win->drag_leave_signal) { | |
7052 g_signal_handler_disconnect(G_OBJECT(widget), | |
7053 win->drag_leave_signal); | |
7054 | |
7055 win->drag_leave_signal = 0; | |
7056 } | |
7057 } | |
7058 | |
7059 /* If we're not in drag... */ | |
7060 /* We're perfectly normal people! */ | |
7061 if (!win->in_drag) | |
7062 return FALSE; | |
7063 | |
7064 win->in_drag = FALSE; | |
7065 | |
7066 dnd_hints_hide_all(); | |
7067 | |
7068 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
7069 | |
7070 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
7071 | |
7072 if (dest_win == NULL) { | |
7073 /* If the current window doesn't have any other conversations, | |
7074 * there isn't much point transferring the conv to a new window. */ | |
7075 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
7076 /* Make a new window to stick this to. */ | |
7077 dest_win = gaim_gtk_conv_window_new(); | |
7078 new_window = TRUE; | |
7079 } | |
7080 } | |
7081 | |
7082 if (dest_win == NULL) | |
7083 return FALSE; | |
7084 | |
7085 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
7086 "conversation-dragging", win, dest_win); | |
7087 | |
7088 /* Get the destination page number. */ | |
7089 if (!new_window) | |
7090 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 7091 e->x_root, e->y_root, &to_right); |
11581 | 7092 |
7093 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7094 | |
7095 if (win == dest_win) { | |
7096 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
7097 } else { | |
7098 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
7099 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 7100 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 7101 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
7102 if (new_window) { | |
7103 gint win_width, win_height; | |
7104 | |
7105 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
7106 &win_width, &win_height); | |
7107 | |
7108 gtk_window_move(GTK_WINDOW(dest_win->window), | |
7109 e->x_root - (win_width / 2), | |
7110 e->y_root - (win_height / 2)); | |
7111 | |
7112 gaim_gtk_conv_window_show(dest_win); | |
7113 } | |
7114 } | |
7115 | |
7116 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
7117 | |
7118 return TRUE; | |
7119 } | |
7120 | |
7121 | |
7122 static void | |
7123 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
7124 gpointer user_data) | |
7125 { | |
7126 GaimGtkWindow *win; | |
7127 GaimConversation *conv; | |
7128 GaimGtkConversation *gtkconv; | |
7129 | |
7130 win = user_data; | |
7131 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
7132 | |
7133 g_return_if_fail(conv != NULL); | |
7134 | |
7135 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
7136 return; | |
7137 | |
7138 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7139 | |
7140 stop_anim(NULL, gtkconv); | |
7141 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7142 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7143 close_window(GtkWidget *w, GaimGtkWindow *win) |
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 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7146 } |
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 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7149 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7150 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7151 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7152 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7153 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7154 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7155 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7156 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7157 return; |
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 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7160 /* 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
|
7161 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7162 return; |
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 gaim_gtk_conv_window_remove_gtkconv(win, 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 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7167 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7168 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7169 } |
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 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7172 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7173 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7174 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7175 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7176 GaimGtkWindow *win; |
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 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7179 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7180 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7181 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7182 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7183 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7184 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7185 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7186 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7187 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7188 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7189 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7190 if (gconv != 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 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7193 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7194 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7195 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7196 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7197 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7198 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7199 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7200 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7201 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7202 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7203 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7204 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7205 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7206 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7207 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7208 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7209 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7210 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7211 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7212 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7213 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7214 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7215 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7216 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
7217 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
|
7218 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7219 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
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 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7222 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7223 } |
12188 | 7224 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7225 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7226 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7227 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7228 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7229 |
13326 | 7230 item = gtk_menu_item_new_with_label(_("Close other tabs")); |
12824
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7231 gtk_widget_show(item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7232 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7233 g_signal_connect(G_OBJECT(item), "activate", |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7234 G_CALLBACK(close_others_cb), menu); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7235 |
13326 | 7236 item = gtk_menu_item_new_with_label(_("Close all tabs")); |
12824
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7237 gtk_widget_show(item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7238 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7239 g_signal_connect(G_OBJECT(item), "activate", |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7240 G_CALLBACK(close_window), win); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7241 |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7242 gaim_separator(menu); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7243 |
13326 | 7244 item = gtk_menu_item_new_with_label(_("Detach this tab")); |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7245 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7246 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7247 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7248 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7249 |
13326 | 7250 item = gtk_menu_item_new_with_label(_("Close this tab")); |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7251 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7252 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7253 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7254 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7255 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7256 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7257 } |
11581 | 7258 |
7259 static void | |
7260 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
7261 gpointer user_data) | |
7262 { | |
7263 GaimGtkWindow *win; | |
7264 GaimConversation *conv; | |
7265 GaimGtkConversation *gtkconv; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7266 const char *sound_method; |
11581 | 7267 |
7268 win = user_data; | |
7269 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
7270 conv = gtkconv->active_conv; | |
7271 | |
7272 g_return_if_fail(conv != NULL); | |
7273 | |
7274 /* | |
7275 * Only set "unseen" to "none" if the window has focus | |
7276 */ | |
7277 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 7278 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 7279 |
7280 /* Update the menubar */ | |
7281 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
7282 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
|
7283 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
7284 |
11594 | 7285 generate_send_to_items(win); |
7286 | |
11604 | 7287 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 7288 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7289 sound_method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7290 if (strcmp(sound_method, "none") != 0) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7291 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
|
7292 gtkconv->make_sound); |
11581 | 7293 |
7294 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
7295 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
7296 | |
7297 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
12188 | 7298 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
11581 | 7299 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7300 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM && |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7301 gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7302 { |
11581 | 7303 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
7304 gtkconv->u.im->show_icon); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7305 } |
11604 | 7306 |
11581 | 7307 /* |
7308 * We pause icons when they are not visible. If this icon should | |
7309 * be animated then start it back up again. | |
7310 */ | |
7311 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
7312 (gtkconv->u.im->animate)) | |
7313 start_anim(NULL, gtkconv); | |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
7314 |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
7315 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-switched", conv); |
11581 | 7316 } |
7317 | |
7318 /************************************************************************** | |
7319 * GTK+ window ops | |
7320 **************************************************************************/ | |
7321 | |
7322 GList * | |
7323 gaim_gtk_conv_windows_get_list() | |
7324 { | |
7325 return window_list; | |
7326 } | |
7327 | |
7328 GaimGtkWindow * | |
7329 gaim_gtk_conv_window_new() | |
7330 { | |
7331 GaimGtkWindow *win; | |
7332 GtkPositionType pos; | |
7333 GtkWidget *testidea; | |
7334 GtkWidget *menubar; | |
7335 | |
7336 win = g_malloc0(sizeof(GaimGtkWindow)); | |
7337 | |
7338 window_list = g_list_append(window_list, win); | |
7339 | |
7340 /* Create the window. */ | |
7341 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
7342 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
7343 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
7344 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
7345 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
7346 | |
7347 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
7348 G_CALLBACK(close_win_cb), win); | |
7349 | |
7350 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
7351 G_CALLBACK(focus_win_cb), win); | |
7352 | |
7353 /* Create the notebook. */ | |
7354 win->notebook = gtk_notebook_new(); | |
7355 | |
7356 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
7357 | |
7358 #if 0 | |
7359 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
7360 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
7361 #endif | |
7362 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
7363 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
7364 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
7365 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
7366 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
7367 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7368 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7369 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7370 |
11581 | 7371 gtk_widget_show(win->notebook); |
7372 | |
7373 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
7374 G_CALLBACK(before_switch_conv_cb), win); | |
7375 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
7376 G_CALLBACK(switch_conv_cb), win); | |
7377 | |
7378 /* Setup the tab drag and drop signals. */ | |
7379 gtk_widget_add_events(win->notebook, | |
7380 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
7381 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
7382 G_CALLBACK(notebook_press_cb), win); | |
7383 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
7384 G_CALLBACK(notebook_release_cb), win); | |
7385 | |
7386 testidea = gtk_vbox_new(FALSE, 0); | |
7387 | |
7388 /* Setup the menubar. */ | |
7389 menubar = setup_menubar(win); | |
7390 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
7391 | |
7392 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
7393 | |
7394 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
7395 | |
7396 gtk_widget_show(testidea); | |
7397 | |
7398 return win; | |
7399 } | |
7400 | |
7401 void | |
7402 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
7403 { | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7404 gaim_prefs_disconnect_by_handle(win); |
11581 | 7405 window_list = g_list_remove(window_list, win); |
7406 | |
11611 | 7407 if (win->gtkconvs) { |
7408 while (win->gtkconvs) { | |
7409 GList *nextgtk = win->gtkconvs->next; | |
7410 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
7411 GList *nextcore = gtkconv->convs->next; | |
7412 GaimConversation *conv = gtkconv->convs->data; | |
7413 gaim_conversation_destroy(conv); | |
7414 if (!nextgtk && !nextcore) | |
7415 /* we'll end up invoking ourselves when we destroy our last child */ | |
7416 /* so don't destroy ourselves right now */ | |
7417 return; | |
7418 } | |
7419 return; | |
7420 } | |
11581 | 7421 gtk_widget_destroy(win->window); |
7422 | |
7423 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
7424 | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
7425 gaim_notify_close_with_handle(win); |
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
7426 |
11581 | 7427 g_free(win); |
7428 } | |
7429 | |
7430 void | |
7431 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
7432 { | |
7433 gtk_widget_show(win->window); | |
7434 } | |
7435 | |
7436 void | |
7437 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
7438 { | |
7439 gtk_widget_hide(win->window); | |
7440 } | |
7441 | |
7442 void | |
7443 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
7444 { | |
13750 | 7445 gdk_window_raise(GDK_WINDOW(win->window->window)); |
11581 | 7446 } |
7447 | |
7448 void | |
7449 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
7450 { | |
7451 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
7452 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
7453 gtkconv->tab_cont)); | |
7454 } | |
7455 | |
7456 void | |
7457 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
7458 { | |
7459 GaimConversation *conv = gtkconv->active_conv; | |
7460 GaimGtkConversation *focus_gtkconv; | |
7461 GtkWidget *tabby, *menu_tabby; | |
7462 GtkWidget *tab_cont = gtkconv->tab_cont; | |
7463 GtkWidget *close_image; | |
7464 GaimConversationType conv_type; | |
7465 const gchar *tmp_lab; | |
7466 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 7467 gboolean tabs_side = FALSE; |
7468 gint angle = 0; | |
11581 | 7469 |
7470 conv_type = gaim_conversation_get_type(conv); | |
7471 | |
7472 | |
7473 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
7474 gtkconv->win = win; | |
7475 | |
11619 | 7476 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
7477 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
7478 tabs_side = TRUE; | |
7479 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
7480 angle = 90; | |
7481 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
7482 angle = 270; | |
7483 | |
7484 if (angle) | |
7485 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
7486 else | |
7487 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 7488 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
7489 | |
7490 /* Close button. */ | |
7491 gtkconv->close = gtk_button_new(); | |
7492 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
7493 if (gtk_check_version(2, 4, 2) == NULL) { | |
7494 /* Need to account for extra padding around the gtkbutton */ | |
7495 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
7496 "focus-line-width", &focus_width, | |
7497 "focus-padding", &focus_pad, | |
7498 NULL); | |
7499 close_button_width += (focus_width + focus_pad) * 2; | |
7500 close_button_height += (focus_width + focus_pad) * 2; | |
7501 } | |
7502 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
7503 close_button_width, close_button_height); | |
7504 | |
7505 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
7506 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
7507 gtk_widget_show(close_image); | |
7508 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
7509 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
7510 _("Close conversation"), NULL); | |
7511 | |
7512 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
7513 G_CALLBACK(close_conv_cb), gtkconv); | |
7514 | |
11851 | 7515 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 7516 /* |
7517 * I love Galeon. They have a fix for that stupid annoying visible | |
7518 * border bug. I love you guys! -- ChipX86 | |
7519 */ | |
11851 | 7520 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 7521 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
7522 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 7523 #endif |
11581 | 7524 |
7525 /* Status icon. */ | |
7526 gtkconv->icon = gtk_image_new(); | |
7527 gtkconv->menu_icon = gtk_image_new(); | |
7528 update_tab_icon(conv); | |
7529 | |
7530 /* Tab label. */ | |
7531 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 7532 |
11581 | 7533 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 7534 if (!angle) |
7535 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 7536 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 7537 if (tabs_side) { |
13769
1afc1b0c4fb3
[gaim-migrate @ 16181]
Richard Laager <rlaager@wiktel.com>
parents:
13750
diff
changeset
|
7538 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 12)); |
11619 | 7539 } |
7540 if (angle) | |
7541 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 7542 #endif |
7543 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
7544 #if 0 | |
7545 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
7546 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
7547 #endif | |
7548 | |
7549 /* Pack it all together. */ | |
11619 | 7550 if (angle == 90) |
7551 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
7552 else | |
7553 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 7554 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
7555 FALSE, FALSE, 0); | |
7556 | |
7557 gtk_widget_show_all(gtkconv->icon); | |
7558 gtk_widget_show_all(gtkconv->menu_icon); | |
7559 | |
7560 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
7561 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
7562 gtk_widget_show(gtkconv->tab_label); | |
7563 gtk_widget_show(gtkconv->menu_label); | |
7564 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
7565 | |
11619 | 7566 if (angle == 90) |
7567 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
7568 else | |
7569 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 7570 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
7571 gtk_widget_show(gtkconv->close); | |
7572 | |
7573 gtk_widget_show(tabby); | |
7574 gtk_widget_show(menu_tabby); | |
7575 | |
7576 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
7577 gaim_gtkconv_update_buddy_icon(conv); | |
7578 | |
7579 /* Add this pane to the conversation's notebook. */ | |
7580 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 7581 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 7582 |
7583 | |
7584 gtk_widget_show(tab_cont); | |
7585 | |
7586 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
7587 /* Er, bug in notebooks? Switch to the page manually. */ | |
7588 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
7589 | |
7590 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7591 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7592 } else | |
7593 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
7594 | |
7595 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
7596 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
7597 gtk_widget_grab_focus(focus_gtkconv->entry); | |
7598 | |
7599 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 7600 update_send_to_selection(win); |
11581 | 7601 } |
7602 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7603 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7604 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
11581 | 7605 { |
7606 unsigned int index; | |
7607 GaimConversationType conv_type; | |
7608 | |
7609 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
7610 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
7611 | |
7612 g_object_ref(gtkconv->tab_cont); | |
7613 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
7614 | |
7615 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
7616 | |
7617 /* go back to tabless if need be */ | |
7618 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
7619 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7620 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7621 } | |
7622 | |
7623 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 7624 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7625 if (!win->gtkconvs && win != hidden_convwin) |
11582 | 7626 gaim_gtk_conv_window_destroy(win); |
11581 | 7627 } |
7628 | |
7629 GaimGtkConversation * | |
7630 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
7631 { | |
7632 GtkWidget *tab_cont; | |
7633 | |
7634 if (index == -1) | |
7635 index = 0; | |
7636 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 7637 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 7638 } |
7639 | |
7640 GaimGtkConversation * | |
7641 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
7642 { | |
7643 int index; | |
7644 GtkWidget *tab_cont; | |
7645 | |
7646 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
7647 if (index == -1) | |
7648 index = 0; | |
7649 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
7650 if (!tab_cont) | |
7651 return NULL; | |
7652 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
7653 } | |
7654 | |
7655 | |
7656 GaimConversation * | |
7657 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
7658 { | |
7659 GaimGtkConversation *gtkconv; | |
7660 | |
7661 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
7662 return gtkconv ? gtkconv->active_conv : NULL; | |
7663 } | |
7664 | |
7665 gboolean | |
7666 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
7667 { | |
7668 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
7669 } | |
7670 | |
7671 gboolean | |
7672 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
7673 { | |
7674 gboolean has_focus = FALSE; | |
7675 | |
7676 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
7677 | |
7678 return has_focus; | |
7679 } | |
7680 | |
7681 GaimGtkWindow * | |
7682 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
7683 { | |
7684 GaimGtkWindow *win; | |
7685 GdkWindow *gdkwin; | |
7686 GList *l; | |
7687 | |
7688 gdkwin = gdk_window_at_pointer(&x, &y); | |
7689 | |
7690 if (gdkwin) | |
7691 gdkwin = gdk_window_get_toplevel(gdkwin); | |
7692 | |
7693 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
7694 win = l->data; | |
7695 | |
7696 if (gdkwin == win->window->window) | |
7697 return win; | |
7698 } | |
7699 | |
7700 return NULL; | |
7701 } | |
7702 | |
7703 GList * | |
7704 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
7705 { | |
7706 return win->gtkconvs; | |
7707 } | |
7708 | |
7709 guint | |
7710 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
7711 { | |
7712 return g_list_length(win->gtkconvs); | |
7713 } | |
7714 | |
7715 GaimGtkWindow * | |
7716 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
7717 { | |
7718 GList *wins, *convs; | |
7719 GaimGtkWindow *win; | |
7720 GaimGtkConversation *conv; | |
7721 | |
7722 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7723 return NULL; | |
7724 | |
7725 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7726 win = wins->data; | |
7727 | |
7728 for (convs = win->gtkconvs; | |
7729 convs != NULL; | |
7730 convs = convs->next) { | |
7731 | |
7732 conv = convs->data; | |
7733 | |
7734 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7735 return win; | |
7736 } | |
7737 } | |
7738 | |
7739 return NULL; | |
7740 } | |
7741 | |
7742 GaimGtkWindow * | |
7743 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
7744 { | |
7745 GList *wins, *convs; | |
7746 GaimGtkWindow *win; | |
7747 GaimGtkConversation *conv; | |
7748 | |
7749 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7750 return NULL; | |
7751 | |
7752 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7753 wins != NULL; | |
7754 wins = wins->prev) { | |
7755 | |
7756 win = wins->data; | |
7757 | |
7758 for (convs = win->gtkconvs; | |
7759 convs != NULL; | |
7760 convs = convs->next) { | |
7761 | |
7762 conv = convs->data; | |
7763 | |
7764 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7765 return win; | |
7766 } | |
7767 } | |
7768 | |
7769 return NULL; | |
7770 } | |
7771 | |
7772 | |
7773 /************************************************************************** | |
7774 * Conversation placement functions | |
7775 **************************************************************************/ | |
7776 typedef struct | |
7777 { | |
7778 char *id; | |
7779 char *name; | |
7780 GaimConvPlacementFunc fnc; | |
7781 | |
7782 } ConvPlacementData; | |
7783 | |
7784 static GList *conv_placement_fncs = NULL; | |
7785 static GaimConvPlacementFunc place_conv = NULL; | |
7786 | |
7787 /* This one places conversations in the last made window. */ | |
7788 static void | |
7789 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7790 { | |
7791 GaimGtkWindow *win; | |
7792 | |
7793 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7794 win = l ? l->data : NULL;; | |
7795 | |
7796 if (win == NULL) { | |
7797 win = gaim_gtk_conv_window_new(); | |
7798 | |
7799 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7800 gaim_gtk_conv_window_show(win); | |
7801 } else { | |
7802 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7803 } | |
7804 } | |
7805 | |
7806 /* This one places conversations in the last made window of the same type. */ | |
7807 static void | |
7808 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7809 { | |
7810 GaimGtkWindow *win; | |
7811 | |
7812 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7813 | |
7814 if (win == NULL) { | |
7815 win = gaim_gtk_conv_window_new(); | |
7816 | |
7817 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7818 gaim_gtk_conv_window_show(win); | |
7819 } else | |
7820 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7821 } | |
7822 | |
7823 /* This one places each conversation in its own window. */ | |
7824 static void | |
7825 conv_placement_new_window(GaimGtkConversation *conv) | |
7826 { | |
7827 GaimGtkWindow *win; | |
7828 | |
7829 win = gaim_gtk_conv_window_new(); | |
7830 | |
7831 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7832 | |
7833 gaim_gtk_conv_window_show(win); | |
7834 } | |
7835 | |
7836 static GaimGroup * | |
7837 conv_get_group(GaimGtkConversation *conv) | |
7838 { | |
7839 GaimGroup *group = NULL; | |
7840 | |
7841 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7842 GaimBuddy *buddy; | |
7843 | |
7844 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7845 gaim_conversation_get_name(conv->active_conv)); | |
7846 | |
7847 if (buddy != NULL) | |
12088 | 7848 group = gaim_buddy_get_group(buddy); |
11581 | 7849 |
7850 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7851 GaimChat *chat; | |
7852 | |
7853 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7854 gaim_conversation_get_name(conv->active_conv)); | |
7855 | |
7856 if (chat != NULL) | |
7857 group = gaim_chat_get_group(chat); | |
7858 } | |
7859 | |
7860 return group; | |
7861 } | |
7862 | |
7863 /* | |
7864 * This groups things by, well, group. Buddies from groups will always be | |
7865 * grouped together, and a buddy from a group not belonging to any currently | |
7866 * open windows will get a new window. | |
7867 */ | |
7868 static void | |
7869 conv_placement_by_group(GaimGtkConversation *conv) | |
7870 { | |
7871 GaimConversationType type; | |
7872 GaimGroup *group = NULL; | |
7873 GList *wl, *cl; | |
7874 | |
7875 type = gaim_conversation_get_type(conv->active_conv); | |
7876 | |
7877 group = conv_get_group(conv); | |
7878 | |
7879 /* Go through the list of IMs and find one with this group. */ | |
7880 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7881 GaimGtkWindow *win2; | |
7882 GaimGtkConversation *conv2; | |
7883 GaimGroup *group2 = NULL; | |
7884 | |
7885 win2 = wl->data; | |
7886 | |
7887 for (cl = win2->gtkconvs; | |
7888 cl != NULL; | |
7889 cl = cl->next) { | |
7890 conv2 = cl->data; | |
7891 | |
7892 group2 = conv_get_group(conv2); | |
7893 | |
7894 if (group == group2) { | |
7895 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7896 | |
7897 return; | |
7898 } | |
7899 } | |
7900 } | |
7901 | |
7902 /* Make a new window. */ | |
7903 conv_placement_new_window(conv); | |
7904 } | |
7905 | |
7906 /* This groups things by account. Otherwise, the same semantics as above */ | |
7907 static void | |
7908 conv_placement_by_account(GaimGtkConversation *conv) | |
7909 { | |
7910 GaimConversationType type; | |
7911 GList *wins, *convs; | |
7912 GaimAccount *account; | |
7913 | |
7914 account = gaim_conversation_get_account(conv->active_conv); | |
7915 type = gaim_conversation_get_type(conv->active_conv); | |
7916 | |
7917 /* Go through the list of IMs and find one with this group. */ | |
7918 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7919 GaimGtkWindow *win2; | |
7920 GaimGtkConversation *conv2; | |
7921 | |
7922 win2 = wins->data; | |
7923 | |
7924 for (convs = win2->gtkconvs; | |
7925 convs != NULL; | |
7926 convs = convs->next) { | |
7927 conv2 = convs->data; | |
7928 | |
7929 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7930 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7931 return; | |
7932 } | |
7933 } | |
7934 } | |
7935 | |
7936 /* Make a new window. */ | |
7937 conv_placement_new_window(conv); | |
7938 } | |
7939 | |
7940 static ConvPlacementData * | |
7941 get_conv_placement_data(const char *id) | |
7942 { | |
7943 ConvPlacementData *data = NULL; | |
7944 GList *n; | |
7945 | |
7946 for (n = conv_placement_fncs; n; n = n->next) { | |
7947 data = n->data; | |
7948 if (!strcmp(data->id, id)) | |
7949 return data; | |
7950 } | |
7951 | |
7952 return NULL; | |
7953 } | |
7954 | |
7955 static void | |
7956 add_conv_placement_fnc(const char *id, const char *name, | |
7957 GaimConvPlacementFunc fnc) | |
7958 { | |
7959 ConvPlacementData *data; | |
7960 | |
7961 data = g_new(ConvPlacementData, 1); | |
7962 | |
7963 data->id = g_strdup(id); | |
7964 data->name = g_strdup(name); | |
7965 data->fnc = fnc; | |
7966 | |
7967 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7968 } | |
7969 | |
7970 static void | |
7971 ensure_default_funcs(void) | |
7972 { | |
7973 if (conv_placement_fncs == NULL) { | |
7974 add_conv_placement_fnc("last", _("Last created window"), | |
7975 conv_placement_last_created_win); | |
7976 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7977 conv_placement_last_created_win_type); | |
7978 add_conv_placement_fnc("new", _("New window"), | |
7979 conv_placement_new_window); | |
7980 add_conv_placement_fnc("group", _("By group"), | |
7981 conv_placement_by_group); | |
7982 add_conv_placement_fnc("account", _("By account"), | |
7983 conv_placement_by_account); | |
7984 } | |
7985 } | |
7986 | |
7987 GList * | |
7988 gaim_gtkconv_placement_get_options(void) | |
7989 { | |
7990 GList *n, *list = NULL; | |
7991 ConvPlacementData *data; | |
7992 | |
7993 ensure_default_funcs(); | |
7994 | |
7995 for (n = conv_placement_fncs; n; n = n->next) { | |
7996 data = n->data; | |
7997 list = g_list_append(list, data->name); | |
7998 list = g_list_append(list, data->id); | |
7999 } | |
8000 | |
8001 return list; | |
8002 } | |
8003 | |
8004 | |
8005 void | |
8006 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
8007 GaimConvPlacementFunc fnc) | |
8008 { | |
8009 g_return_if_fail(id != NULL); | |
8010 g_return_if_fail(name != NULL); | |
8011 g_return_if_fail(fnc != NULL); | |
8012 | |
8013 ensure_default_funcs(); | |
8014 | |
8015 add_conv_placement_fnc(id, name, fnc); | |
8016 } | |
8017 | |
8018 void | |
8019 gaim_gtkconv_placement_remove_fnc(const char *id) | |
8020 { | |
8021 ConvPlacementData *data = get_conv_placement_data(id); | |
8022 | |
8023 if (data == NULL) | |
8024 return; | |
8025 | |
8026 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
8027 | |
8028 g_free(data->id); | |
8029 g_free(data->name); | |
8030 g_free(data); | |
8031 } | |
8032 | |
8033 const char * | |
8034 gaim_gtkconv_placement_get_name(const char *id) | |
8035 { | |
8036 ConvPlacementData *data; | |
8037 | |
8038 ensure_default_funcs(); | |
8039 | |
8040 data = get_conv_placement_data(id); | |
8041 | |
8042 if (data == NULL) | |
8043 return NULL; | |
8044 | |
8045 return data->name; | |
8046 } | |
8047 | |
8048 GaimConvPlacementFunc | |
8049 gaim_gtkconv_placement_get_fnc(const char *id) | |
8050 { | |
8051 ConvPlacementData *data; | |
8052 | |
8053 ensure_default_funcs(); | |
8054 | |
8055 data = get_conv_placement_data(id); | |
8056 | |
8057 if (data == NULL) | |
8058 return NULL; | |
8059 | |
8060 return data->fnc; | |
8061 } | |
8062 | |
8063 void | |
8064 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
8065 { | |
8066 g_return_if_fail(func != NULL); | |
8067 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8068 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8069 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8070 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8071 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8072 place_conv = NULL; |
11581 | 8073 } |
8074 | |
8075 GaimConvPlacementFunc | |
8076 gaim_gtkconv_placement_get_current_func(void) | |
8077 { | |
8078 return place_conv; | |
8079 } | |
8080 | |
8081 void | |
8082 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
8083 { | |
8084 if (place_conv) | |
8085 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8086 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8087 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8088 } |
12239 | 8089 |
8090 gboolean | |
8091 gaim_gtkconv_is_hidden(GaimGtkConversation *gtkconv) | |
8092 { | |
8093 g_return_val_if_fail(gtkconv != NULL, FALSE); | |
8094 | |
8095 return (gtkconv->win == hidden_convwin); | |
8096 } | |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8097 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8098 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8099 /* Algorithm from http://www.w3.org/TR/AERT#color-contrast */ |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
8100 static gboolean |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8101 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
|
8102 { |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8103 gulong fg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8104 gulong bg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8105 gulong br_diff; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8106 gulong col_diff; |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8107 int fred, fgreen, fblue, bred, bgreen, bblue; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8108 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8109 /* 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
|
8110 * GTK on the other hand has values between 0 and 65535 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8111 * Err suggested I >> 8, which grabbed the high bits. |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8112 */ |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8113 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8114 fred = foreground.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8115 fgreen = foreground.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8116 fblue = foreground.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8117 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8118 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8119 bred = background.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8120 bgreen = background.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8121 bblue = background.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8122 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8123 fg_brightness = (fred * 299 + fgreen * 587 + fblue * 114) / 1000; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8124 bg_brightness = (bred * 299 + bgreen * 587 + bblue * 114) / 1000; |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8125 br_diff = abs(fg_brightness - bg_brightness); |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8126 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8127 col_diff = abs(fred - bred) + abs(fgreen - bgreen) + abs(fblue - bblue); |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8128 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8129 return ((col_diff > color_contrast) && (br_diff > brightness_contrast)); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8130 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8131 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8132 |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
8133 static GdkColor* |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8134 generate_nick_colors(guint *color_count, GdkColor background) |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8135 { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8136 guint numcolors = *color_count; |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8137 guint i = 0, j = 0; |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8138 GdkColor *colors = g_new(GdkColor, numcolors); |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8139 GdkColor nick_highlight; |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8140 GdkColor send_color; |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8141 time_t breakout_time; |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8142 |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8143 gdk_color_parse(HIGHLIGHT_COLOR, &nick_highlight); |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8144 gdk_color_parse(SEND_COLOR, &send_color); |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8145 |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8146 srand(background.red + background.green + background.blue + 1); |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8147 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8148 breakout_time = time(NULL) + 3; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8149 |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8150 /* 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
|
8151 * 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
|
8152 * numcolors of them that do |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8153 */ |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8154 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
|
8155 { |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8156 GdkColor color = nick_seed_colors[j]; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8157 |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8158 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
|
8159 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8160 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8161 { |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8162 colors[i] = color; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8163 i++; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8164 } |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8165 j++; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8166 } |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8167 |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8168 /* 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
|
8169 * 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
|
8170 * 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
|
8171 * conflict with each other. |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8172 */ |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8173 while(i < numcolors && time(NULL) < breakout_time) |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8174 { |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8175 GdkColor color = { 0, rand() % 65536, rand() % 65536, rand() % 65536 }; |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8176 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8177 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
|
8178 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8179 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8180 { |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8181 colors[i] = color; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8182 i++; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8183 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8184 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8185 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8186 if (i < numcolors) { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8187 GdkColor *c = colors; |
13519 | 8188 gaim_debug_warning("gtkconv", "Unable to generate enough random colors before timeout. %u colors found.\n", i); |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8189 colors = g_memdup(c, i * sizeof(GdkColor)); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8190 g_free(c); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8191 *color_count = i; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8192 } |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8193 |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8194 return colors; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8195 } |