Mercurial > pidgin.yaz
annotate src/gtkconv.c @ 13369:d34730f73777
[gaim-migrate @ 15742]
/debug version is really a debugging message, and as such should
really not be translated. This corrects that.
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Wed, 01 Mar 2006 12:51:36 +0000 |
parents | da2179c099f0 |
children | b0dd97098699 |
rev | line source |
---|---|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
1 /** |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
2 * @file gtkconv.c GTK+ Conversation API |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
3 * @ingroup gtkui |
4359 | 4 * |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
5 * gaim |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
6 * |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
10 * |
4359 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
9791 | 26 #include "internal.h" |
27 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
28 |
4359 | 29 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
30 # include <X11/Xlib.h> |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
31 #endif |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
32 |
4359 | 33 #ifdef USE_GTKSPELL |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
34 # include <gtkspell/gtkspell.h> |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
35 # ifdef _WIN32 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
36 # include "wspell.h" |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
37 # endif |
4359 | 38 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
39 |
4359 | 40 #include <gdk/gdkkeysyms.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
41 |
9699 | 42 #include "account.h" |
9130 | 43 #include "cmds.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
44 #include "debug.h" |
12272 | 45 #include "idle.h" |
6982 | 46 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
47 #include "log.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5402
diff
changeset
|
48 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
49 #include "prpl.h" |
6038 | 50 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
51 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
52 |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
53 #include "gtkdnd-hints.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
54 #include "gtkblist.h" |
5717 | 55 #include "gtkconv.h" |
11583 | 56 #include "gtkconvwin.h" |
9709 | 57 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
58 #include "gtkimhtml.h" |
8317 | 59 #include "gtkimhtmltoolbar.h" |
7431 | 60 #include "gtklog.h" |
11554
f8443218b7fe
[gaim-migrate @ 13814]
Gary Kramlich <grim@reaperworld.com>
parents:
11552
diff
changeset
|
61 #include "gtkmenutray.h" |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
62 #include "gtkpounce.h" |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
63 #include "gtkprefs.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
64 #include "gtkprivacy.h" |
11525 | 65 #include "gtkthemes.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
66 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
67 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
68 |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
69 #include "gtknickcolors.h" |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
70 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
71 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
72 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
73 typedef enum |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
74 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
75 GAIM_GTKCONV_SET_TITLE = 1 << 0, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
76 GAIM_GTKCONV_BUDDY_ICON = 1 << 1, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
77 GAIM_GTKCONV_MENU = 1 << 2, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
78 GAIM_GTKCONV_TAB_ICON = 1 << 3, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
79 GAIM_GTKCONV_TOPIC = 1 << 4, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
80 GAIM_GTKCONV_SMILEY_THEME = 1 << 5, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
81 GAIM_GTKCONV_COLORIZE_TITLE = 1 << 6 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
82 }GaimGtkConvFields; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
83 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
84 #define GAIM_GTKCONV_ALL ((1 << 7) - 1) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
85 |
12359
cbf9f2e26916
[gaim-migrate @ 14663]
Richard Laager <rlaager@wiktel.com>
parents:
12358
diff
changeset
|
86 #define SEND_COLOR "#204a87" |
cbf9f2e26916
[gaim-migrate @ 14663]
Richard Laager <rlaager@wiktel.com>
parents:
12358
diff
changeset
|
87 #define RECV_COLOR "#cc0000" |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
88 #define HIGHLIGHT_COLOR "#AF7F00" |
7854 | 89 |
12335 | 90 /* Undef this to turn off "custom-smiley" debug messages */ |
91 #define DEBUG_CUSTOM_SMILEY | |
92 | |
10108 | 93 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
94 | |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
95 #if 0 |
10108 | 96 /* These colors come from the default GNOME palette */ |
97 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
98 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
99 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
100 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
101 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
102 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
103 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
104 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
105 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
106 {0, 34816, 17920, 12544}, /* Red Dark */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
107 {0, 49408, 14336, 8704}, /* Red Shadow */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
108 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
109 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
110 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
111 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
112 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
113 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
114 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
115 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
116 {0, 57088, 16896, 7680}, /* Accent Red */ |
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
117 {0, 39168, 0, 0}, /* Accent Red Dark */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
118 {0, 17920, 40960, 17920}, /* Accent Green */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
119 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 120 }; |
6291 | 121 |
4359 | 122 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
123 #endif |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
124 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
125 /* From http://www.w3.org/TR/AERT#color-contrast */ |
12354
709548d845a1
[gaim-migrate @ 14658]
Luke Schierer <lschiere@pidgin.im>
parents:
12353
diff
changeset
|
126 #define MIN_BRIGHTNESS_CONTRAST 75 |
709548d845a1
[gaim-migrate @ 14658]
Luke Schierer <lschiere@pidgin.im>
parents:
12353
diff
changeset
|
127 #define MIN_COLOR_CONTRAST 200 |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
128 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
129 #define NUM_NICK_COLORS 220 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
130 static GdkColor *nick_colors = NULL; |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
131 static guint nbr_nick_colors; |
4359 | 132 |
11581 | 133 typedef struct { |
4359 | 134 GtkWidget *window; |
135 | |
136 GtkWidget *entry; | |
137 GtkWidget *message; | |
138 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
139 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
140 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
141 } InviteBuddyInfo; |
4359 | 142 |
143 static GtkWidget *invite_dialog = NULL; | |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
144 static GtkWidget *warn_close_dialog = NULL; |
4359 | 145 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
146 static GaimGtkWindow *hidden_convwin = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
147 static GList *window_list = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
148 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
149 |
11594 | 150 static gboolean update_send_to_selection(GaimGtkWindow *win); |
151 static void generate_send_to_items(GaimGtkWindow *win); | |
11581 | 152 |
4359 | 153 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
10810 | 154 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
11604 | 155 static void gray_stuff_out(GaimGtkConversation *gtkconv); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
156 static GList *generate_invite_user_names(GaimConnection *gc); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
157 static void add_chat_buddy_common(GaimConversation *conv, const char *name, |
11869 | 158 GaimConvChatBuddyFlags flags, const char *alias, const char *old_name); |
9605 | 159 static gboolean tab_complete(GaimConversation *conv); |
11604 | 160 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); |
11613 | 161 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); |
10810 | 162 static void update_typing_icon(GaimGtkConversation *gtkconv); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
163 static const char *item_factory_translate_func (const char *path, gpointer func_data); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
164 gboolean gaim_gtkconv_has_focus(GaimConversation *conv); |
12335 | 165 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data); |
166 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data); | |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
167 static GdkColor* generate_nick_colors(guint *numcolors, GdkColor background); |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
168 static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
169 static void gaim_gtkconv_update_fields(GaimConversation *conv, GaimGtkConvFields fields); |
4359 | 170 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
171 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
172 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
173 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
174 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
175 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
176 col = nick_colors[g_str_hash(name) % nbr_nick_colors]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
177 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
178 (LUMINANCE(style->white)/MAX(MAX(col.red, col.blue), col.green))); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
179 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
180 /* The colors are chosen to look fine on white; we should never have to darken */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
181 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
182 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
183 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
184 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
185 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
186 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
187 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
188 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
189 |
4359 | 190 /************************************************************************** |
191 * Callbacks | |
192 **************************************************************************/ | |
10971 | 193 |
4359 | 194 static gint |
10810 | 195 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 196 { |
10810 | 197 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 198 |
10810 | 199 l = list; |
200 while (l) { | |
201 GaimConversation *conv = l->data; | |
202 gaim_conversation_destroy(conv); | |
203 l = l->next; | |
204 } | |
11508 | 205 |
10810 | 206 g_list_free(list); |
11508 | 207 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
208 return TRUE; |
4359 | 209 } |
210 | |
8914 | 211 static gboolean |
10810 | 212 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 213 { |
10810 | 214 GaimConversation *conv = gtkconv->active_conv; |
11508 | 215 |
8914 | 216 if (!GTK_WIDGET_VISIBLE(w)) |
217 return FALSE; | |
218 | |
219 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
220 return FALSE; | |
221 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
222 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
223 * tab bar will fit, but then I don't want new windows taking up the entire screen. I check to see |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
224 * if there is only one conversation in the window. This way we'll be setting new windows to the |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
225 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
226 /* I think that the above justification is not the majority, and that the new tab resizing should |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
227 * negate it anyway. --luke */ |
11338 | 228 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 229 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
230 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
231 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_width", allocation->width); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
232 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_height", allocation->height); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
233 } |
8914 | 234 if (w == gtkconv->entry) |
235 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
236 } | |
11338 | 237 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 238 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
239 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
240 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_width", allocation->width); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
241 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_height", allocation->height); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
242 } |
8914 | 243 if (w == gtkconv->entry) |
244 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
245 } | |
246 | |
247 return FALSE; | |
248 } | |
249 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
250 static void |
10810 | 251 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
252 { |
10810 | 253 GaimConversation *conv = c->active_conv; |
11508 | 254 |
10665 | 255 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
256 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
259 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold") != GTK_IMHTML(c->entry)->edit.bold) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
261 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
262 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic") != GTK_IMHTML(c->entry)->edit.italic) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
264 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
266 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline") != GTK_IMHTML(c->entry)->edit.underline) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
267 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
268 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
269 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
270 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
271 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
272 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
273 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
274 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
275 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
276 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
277 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
278 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
279 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
280 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
281 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
282 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
283 fg_color.blue / 256); |
8061 | 284 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
285 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
286 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
287 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
288 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
289 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
290 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
291 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
292 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
293 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
294 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
295 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
296 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
297 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
298 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
299 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
300 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
301 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
302 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
303 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
304 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
305 g_free(color); |
8677 | 306 |
9025 | 307 |
10665 | 308 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 309 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
310 else | |
311 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 312 } |
313 } | |
9130 | 314 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
315 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
316 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
317 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
318 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
319 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
320 |
9130 | 321 static const char * |
322 gaim_gtk_get_cmd_prefix(void) | |
323 { | |
324 return "/"; | |
325 } | |
326 | |
9167 | 327 static GaimCmdRet |
9829 | 328 say_command_cb(GaimConversation *conv, |
329 const char *cmd, char **args, char **error, void *data) | |
330 { | |
11338 | 331 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 332 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 333 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 334 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
335 | |
336 return GAIM_CMD_RET_OK; | |
337 } | |
338 | |
339 static GaimCmdRet | |
9167 | 340 me_command_cb(GaimConversation *conv, |
9597 | 341 const char *cmd, char **args, char **error, void *data) |
9167 | 342 { |
343 char *tmp; | |
344 | |
345 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 346 |
11338 | 347 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 348 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 349 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 350 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
351 | |
352 g_free(tmp); | |
353 return GAIM_CMD_RET_OK; | |
354 } | |
355 | |
9212 | 356 static GaimCmdRet |
357 debug_command_cb(GaimConversation *conv, | |
9597 | 358 const char *cmd, char **args, char **error, void *data) |
9212 | 359 { |
360 char *tmp, *markup; | |
361 GaimCmdStatus status; | |
362 | |
363 if (!g_ascii_strcasecmp(args[0], "version")) { | |
13369 | 364 tmp = g_strdup_printf("me is using Gaim v%s.", VERSION); |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
365 markup = g_markup_escape_text(tmp, -1); |
9212 | 366 |
367 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
368 | |
369 g_free(tmp); | |
370 g_free(markup); | |
371 return status; | |
372 } else { | |
373 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
374 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
375 return GAIM_CMD_STATUS_OK; | |
376 } | |
377 } | |
378 | |
9213 | 379 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
380 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
381 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
382 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
383 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
384 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
385 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
386 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
387 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
388 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
389 } |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
390 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
391 static GaimCmdRet |
9213 | 392 help_command_cb(GaimConversation *conv, |
9597 | 393 const char *cmd, char **args, char **error, void *data) |
9213 | 394 { |
9597 | 395 GList *l, *text; |
9213 | 396 GString *s; |
9597 | 397 |
398 if (args[0] != NULL) { | |
399 s = g_string_new(""); | |
400 text = gaim_cmd_help(conv, args[0]); | |
401 | |
402 if (text) { | |
403 for (l = text; l; l = l->next) | |
404 if (l->next) | |
9816 | 405 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 406 else |
9816 | 407 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 408 } else { |
409 g_string_append(s, _("No such command (in this context).")); | |
410 } | |
411 } else { | |
412 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
413 "The following commands are available in this context:\n")); | |
414 | |
415 text = gaim_cmd_list(conv); | |
416 for (l = text; l; l = l->next) | |
9213 | 417 if (l->next) |
9597 | 418 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 419 else |
9597 | 420 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 421 } |
422 | |
423 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
424 g_string_free(s, TRUE); | |
425 | |
426 return GAIM_CMD_STATUS_OK; | |
427 } | |
428 | |
4359 | 429 static void |
9374 | 430 send_history_add(GaimConversation *conv, const char *message) |
431 { | |
432 GList *first; | |
433 | |
434 first = g_list_first(conv->send_history); | |
435 | |
436 if (first->data) | |
437 g_free(first->data); | |
438 | |
439 first->data = g_strdup(message); | |
440 | |
441 conv->send_history = g_list_prepend(first, NULL); | |
442 } | |
443 | |
9832 | 444 static gboolean |
445 check_for_and_do_command(GaimConversation *conv) | |
446 { | |
447 GaimGtkConversation *gtkconv; | |
448 char *cmd; | |
449 const char *prefix; | |
450 GaimAccount *account; | |
451 GtkTextIter start; | |
452 | |
453 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
454 account = gaim_conversation_get_account(conv); | |
455 prefix = gaim_gtk_get_cmd_prefix(); | |
456 | |
457 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
458 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
459 | |
460 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
461 && !gtk_text_iter_get_child_anchor(&start)) { | |
462 GaimCmdStatus status; | |
463 char *error, *cmdline, *markup, *send_history; | |
464 GtkTextIter end; | |
465 | |
466 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
467 send_history_add(conv, send_history); | |
468 g_free(send_history); | |
469 | |
470 cmdline = cmd + strlen(prefix); | |
471 | |
472 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
473 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
474 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
475 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
476 g_free(cmd); | |
477 g_free(markup); | |
478 | |
479 switch (status) { | |
480 case GAIM_CMD_STATUS_OK: | |
481 return TRUE; | |
482 case GAIM_CMD_STATUS_NOT_FOUND: | |
483 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
484 gaim_conversation_write(conv, "", _("No such command."), | |
485 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
486 | |
487 return TRUE; | |
488 } | |
489 return FALSE; | |
490 case GAIM_CMD_STATUS_WRONG_ARGS: | |
491 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
492 "to that command."), | |
493 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
494 return TRUE; | |
495 case GAIM_CMD_STATUS_FAILED: | |
496 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
497 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
498 if(error) | |
499 g_free(error); | |
500 return TRUE; | |
501 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 502 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 503 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 504 GAIM_MESSAGE_NO_LOG, time(NULL)); |
505 else | |
10843 | 506 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 507 GAIM_MESSAGE_NO_LOG, time(NULL)); |
508 return TRUE; | |
509 case GAIM_CMD_STATUS_WRONG_PRPL: | |
510 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
511 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
512 return TRUE; | |
513 } | |
514 } | |
515 | |
516 g_free(cmd); | |
517 return FALSE; | |
518 } | |
519 | |
9374 | 520 static void |
10810 | 521 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 522 { |
10810 | 523 GaimConversation *conv = gtkconv->active_conv; |
8655 | 524 GaimAccount *account; |
8677 | 525 GaimConnection *gc; |
12216 | 526 GaimMessageFlags flags = 0; |
8448 | 527 char *buf, *clean; |
4359 | 528 |
8655 | 529 account = gaim_conversation_get_account(conv); |
9130 | 530 |
9471 | 531 if (!gaim_account_is_connected(account)) |
532 return; | |
533 | |
11338 | 534 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 535 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 536 return; |
537 | |
9832 | 538 if (check_for_and_do_command(conv)) { |
539 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
540 return; | |
9130 | 541 } |
542 | |
8442 | 543 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 544 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 545 |
4359 | 546 gtk_widget_grab_focus(gtkconv->entry); |
547 | |
8448 | 548 if (strlen(clean) == 0) { |
549 g_free(clean); | |
4359 | 550 return; |
551 } | |
552 | |
12272 | 553 gaim_idle_touch(); |
554 | |
12216 | 555 /* XXX: is there a better way to tell if the message has images? */ |
556 if (GTK_IMHTML(gtkconv->entry)->im_images != NULL) | |
557 flags |= GAIM_MESSAGE_IMAGES; | |
558 | |
8677 | 559 gc = gaim_account_get_connection(account); |
10665 | 560 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 561 char **bufs; |
562 int i; | |
563 | |
564 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
565 for (i = 0; bufs[i]; i++) { | |
9374 | 566 send_history_add(conv, bufs[i]); |
11338 | 567 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 568 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), bufs[i], flags); |
11338 | 569 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 570 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), bufs[i], flags); |
8677 | 571 } |
572 | |
573 g_strfreev(bufs); | |
574 | |
575 } else { | |
9374 | 576 send_history_add(conv, buf); |
11338 | 577 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 578 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), buf, flags); |
11338 | 579 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 580 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), buf, flags); |
8677 | 581 } |
4359 | 582 |
8677 | 583 g_free(clean); |
4359 | 584 g_free(buf); |
585 | |
8061 | 586 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 587 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 588 } |
589 | |
590 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
591 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 592 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
593 GaimAccount *account; |
4359 | 594 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
595 GaimConversation *conv = gtkconv->active_conv; |
4359 | 596 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
597 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
598 name = gaim_conversation_get_name(conv); |
7879 | 599 |
11338 | 600 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 601 GaimBuddy *b; |
602 | |
603 b = gaim_find_buddy(account, name); | |
604 if (b != NULL) | |
9730 | 605 gaim_gtkdialogs_remove_buddy(b); |
7859 | 606 else if (account != NULL && gaim_account_is_connected(account)) |
607 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 608 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 609 GaimChat *c; |
610 | |
611 c = gaim_blist_find_chat(account, name); | |
612 if (c != NULL) | |
9730 | 613 gaim_gtkdialogs_remove_chat(c); |
7859 | 614 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 615 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 616 } |
4359 | 617 |
618 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
619 } | |
620 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
621 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 622 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
623 GaimConversation *conv = gtkconv->active_conv; |
7975 | 624 GaimPluginProtocolInfo *prpl_info = NULL; |
625 GaimConnection *gc; | |
626 | |
627 if ((gc = gaim_conversation_get_gc(conv))) { | |
628 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
629 | |
630 /* | |
631 * If there are special needs for getting info on users in | |
632 * buddy chat "rooms"... | |
633 */ | |
634 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
635 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
636 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
637 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
638 } |
7975 | 639 else |
640 prpl_info->get_info(gc, who); | |
641 } | |
642 } | |
643 | |
644 | |
4359 | 645 static void |
10810 | 646 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 647 { |
10810 | 648 GaimConversation *conv = gtkconv->active_conv; |
4359 | 649 |
11338 | 650 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 651 serv_get_info(gaim_conversation_get_gc(conv), |
652 gaim_conversation_get_name(conv)); | |
653 | |
654 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 655 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 656 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
657 GaimGtkChatPane *gtkchat; |
4359 | 658 GtkTreeIter iter; |
659 GtkTreeModel *model; | |
660 GtkTreeSelection *sel; | |
9554 | 661 char *name; |
4359 | 662 |
663 gtkchat = gtkconv->u.chat; | |
664 | |
665 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
666 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
667 | |
668 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 669 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 670 else |
671 return; | |
672 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
673 chat_do_info(gtkconv, name); |
9554 | 674 g_free(name); |
4359 | 675 } |
676 } | |
677 | |
678 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
679 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 680 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
681 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
682 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
683 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
684 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
685 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
686 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
687 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 688 |
689 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
690 } | |
691 | |
692 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
693 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 694 { |
695 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
696 GaimGtkConversation *gtkconv; |
4359 | 697 |
698 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
699 | |
700 if (resp == GTK_RESPONSE_OK) { | |
701 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
702 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
703 | |
10113 | 704 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 705 return; |
706 | |
707 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
708 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 709 message, buddy); |
710 } | |
711 | |
712 gtk_widget_destroy(invite_dialog); | |
713 invite_dialog = NULL; | |
714 | |
715 g_free(info); | |
716 } | |
717 | |
718 static void | |
9909 | 719 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
720 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
721 { | |
722 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
723 const char *convprotocol; | |
724 | |
725 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
726 | |
727 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
728 { | |
729 GaimBlistNode *node = NULL; | |
730 GaimBuddy *buddy; | |
731 | |
732 memcpy(&node, sd->data, sizeof(node)); | |
733 | |
734 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
735 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
736 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
737 buddy = (GaimBuddy *)node; | |
738 else | |
739 return; | |
740 | |
741 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
742 { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
743 gaim_notify_error(GAIM_GTK_CONVERSATION(info->conv), NULL, |
9909 | 744 _("That buddy is not on the same protocol as this " |
10843 | 745 "chat."), NULL); |
9909 | 746 } |
747 else | |
748 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
749 | |
750 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
751 } | |
752 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
753 { | |
754 char *protocol = NULL; | |
755 char *username = NULL; | |
756 GaimAccount *account; | |
757 | |
11137 | 758 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 759 &protocol, &username, NULL)) |
760 { | |
761 if (account == NULL) | |
762 { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
763 gaim_notify_error(GAIM_GTK_CONVERSATION(info->conv), NULL, |
9909 | 764 _("You are not currently signed on with an account that " |
765 "can invite that buddy."), NULL); | |
766 } | |
767 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
768 { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
769 gaim_notify_error(GAIM_GTK_CONVERSATION(info->conv), NULL, |
9909 | 770 _("That buddy is not on the same protocol as this " |
10843 | 771 "chat."), NULL); |
9909 | 772 } |
773 else | |
774 { | |
775 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
776 } | |
777 } | |
778 | |
779 if (username != NULL) g_free(username); | |
780 if (protocol != NULL) g_free(protocol); | |
781 | |
782 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
783 } | |
784 } | |
785 | |
786 static const GtkTargetEntry dnd_targets[] = | |
787 { | |
788 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
789 {"application/x-im-contact", 0, 1} | |
790 }; | |
791 | |
792 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
793 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 794 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
795 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
796 InviteBuddyInfo *info = NULL; |
4359 | 797 |
798 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
799 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
800 GaimGtkWindow *gtkwin; |
4359 | 801 GtkWidget *label; |
802 GtkWidget *vbox, *hbox; | |
803 GtkWidget *table; | |
804 GtkWidget *img; | |
805 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
806 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 807 GTK_ICON_SIZE_DIALOG); |
4359 | 808 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
809 info = g_new0(InviteBuddyInfo, 1); |
4359 | 810 info->conv = conv; |
811 | |
11581 | 812 gc = gaim_conversation_get_gc(conv); |
813 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 814 |
815 /* Create the new dialog. */ | |
816 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 817 _("Invite Buddy Into Chat Room"), |
7879 | 818 GTK_WINDOW(gtkwin->window), 0, |
819 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
820 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 821 |
822 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 823 GTK_RESPONSE_OK); |
11243 | 824 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 825 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
826 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
827 | |
9909 | 828 info->window = GTK_WIDGET(invite_dialog); |
829 | |
4359 | 830 /* Setup the outside spacing. */ |
831 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
832 | |
11243 | 833 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
834 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 835 |
836 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 837 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 838 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
839 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
840 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
841 | |
842 /* Setup the right vbox. */ | |
843 vbox = gtk_vbox_new(FALSE, 0); | |
844 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
845 | |
846 /* Put our happy label in it. */ | |
847 label = gtk_label_new(_("Please enter the name of the user you wish " | |
848 "to invite, along with an optional invite " | |
849 "message.")); | |
850 gtk_widget_set_size_request(label, 350, -1); | |
851 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
852 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
853 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
854 | |
855 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 856 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 857 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
858 | |
859 /* Setup the table we're going to use to lay stuff out. */ | |
860 table = gtk_table_new(2, 2, FALSE); | |
11243 | 861 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
862 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
863 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 864 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
865 | |
866 /* Now the Buddy label */ | |
867 label = gtk_label_new(NULL); | |
868 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
869 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
870 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
871 | |
872 /* Now the Buddy drop-down entry field. */ | |
873 info->entry = gtk_combo_new(); | |
874 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
875 gtk_entry_set_activates_default( | |
876 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
877 | |
878 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
879 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
880 | |
881 /* Fill in the names. */ | |
882 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
883 generate_invite_user_names(gc)); | |
884 | |
885 | |
886 /* Now the label for "Message" */ | |
887 label = gtk_label_new(NULL); | |
888 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
889 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
890 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
891 | |
892 | |
893 /* And finally, the Message entry field. */ | |
894 info->message = gtk_entry_new(); | |
895 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
896 | |
897 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
898 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
899 | |
900 /* Connect the signals. */ | |
901 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
902 G_CALLBACK(do_invite), info); | |
9909 | 903 /* Setup drag-and-drop */ |
904 gtk_drag_dest_set(info->window, | |
905 GTK_DEST_DEFAULT_MOTION | | |
906 GTK_DEST_DEFAULT_DROP, | |
907 dnd_targets, | |
908 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
909 GDK_ACTION_COPY); | |
910 gtk_drag_dest_set(info->entry, | |
911 GTK_DEST_DEFAULT_MOTION | | |
912 GTK_DEST_DEFAULT_DROP, | |
913 dnd_targets, | |
914 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
915 GDK_ACTION_COPY); | |
916 | |
917 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
918 G_CALLBACK(invite_dnd_recv), info); | |
919 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
920 G_CALLBACK(invite_dnd_recv), info); | |
921 | |
4359 | 922 } |
923 | |
924 gtk_widget_show_all(invite_dialog); | |
925 | |
926 if (info != NULL) | |
927 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
928 } | |
929 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
930 static void |
7748 | 931 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
932 { | |
9714 | 933 gaim_gtkdialogs_im(); |
7748 | 934 } |
935 | |
936 static void | |
9504 | 937 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 938 { |
9504 | 939 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 940 FILE *fp; |
941 const char *name; | |
10849 | 942 gchar *text; |
9489 | 943 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
944 if ((fp = g_fopen(filename, "w+")) == NULL) { |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
945 gaim_notify_error(GAIM_GTK_CONVERSATION(conv), NULL, _("Unable to open file."), NULL); |
9489 | 946 return; |
947 } | |
948 | |
949 name = gaim_conversation_get_name(conv); | |
10849 | 950 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 951 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 952 |
953 text = gtk_imhtml_get_markup( | |
954 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
955 fprintf(fp, "%s", text); | |
956 g_free(text); | |
957 | |
958 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 959 fclose(fp); |
960 } | |
961 | |
10849 | 962 /* |
963 * It would be kinda cool if this gave the option of saving a | |
964 * plaintext v. HTML file. | |
965 */ | |
9489 | 966 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
967 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
968 { |
11581 | 969 GaimGtkWindow *win = data; |
970 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 971 gchar *buf; |
972 | |
973 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 974 |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
975 gaim_request_file(GAIM_GTK_CONVERSATION(conv), _("Save Conversation"), |
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
976 gaim_escape_filename(buf), |
10849 | 977 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); |
9489 | 978 |
979 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
980 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
981 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
982 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
983 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
984 { |
11581 | 985 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
986 GaimConversation *conv; |
9917 | 987 GaimLogType type; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
988 GaimGtkBuddyList *gtkblist; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
989 GdkCursor *cursor; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
990 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
991 GaimAccount *account; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
992 GSList *buddies; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
993 GSList *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
994 |
11581 | 995 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
996 |
11338 | 997 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 998 type = GAIM_LOG_IM; |
11338 | 999 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 1000 type = GAIM_LOG_CHAT; |
1001 else | |
1002 return; | |
1003 | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1004 gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1005 cursor = gdk_cursor_new(GDK_WATCH); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1006 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1007 gdk_window_set_cursor(gtkblist->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1008 gdk_window_set_cursor(win->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1009 gdk_cursor_unref(cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1010 while (gtk_events_pending()) |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1011 gtk_main_iteration(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1012 |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1013 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1014 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1015 |
10845 | 1016 buddies = gaim_find_buddies(account, name); |
1017 for (cur = buddies; cur != NULL; cur = cur->next) | |
1018 { | |
1019 GaimBlistNode *node = cur->data; | |
10846 | 1020 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 1021 { |
1022 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
1023 g_slist_free(buddies); | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1024 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1025 gdk_window_set_cursor(win->window->window, NULL); |
10845 | 1026 return; |
1027 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1028 } |
10845 | 1029 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1030 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1031 gaim_gtk_log_show(type, name, account); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1032 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1033 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1034 gdk_window_set_cursor(win->window->window, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1035 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1036 |
8974 | 1037 static void |
1038 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
1039 { | |
11581 | 1040 GaimGtkWindow *win = data; |
8974 | 1041 GaimConversation *conv; |
1042 GaimGtkConversation *gtkconv; | |
1043 | |
11581 | 1044 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 1045 gtkconv = GAIM_GTK_CONVERSATION(conv); |
1046 | |
1047 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1048 } | |
1049 | |
7295 | 1050 struct _search { |
1051 GaimGtkConversation *gtkconv; | |
1052 GtkWidget *entry; | |
1053 }; | |
1054 | |
7929 | 1055 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 1056 { |
7929 | 1057 switch (resp) { |
1058 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1059 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1060 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1061 break; |
1062 | |
1063 case GTK_RESPONSE_DELETE_EVENT: | |
1064 case GTK_RESPONSE_CLOSE: | |
1065 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1066 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1067 s->gtkconv->dialogs.search = NULL; | |
1068 g_free(s); | |
1069 break; | |
1070 } | |
7295 | 1071 } |
1072 | |
1073 static void | |
7751 | 1074 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1075 { |
11581 | 1076 GaimGtkWindow *gtkwin = data; |
1077 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1078 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1079 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1080 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1081 GTK_ICON_SIZE_DIALOG); |
7929 | 1082 GtkWidget *label; |
7295 | 1083 struct _search *s; |
1084 | |
7798 | 1085 if (gtkconv->dialogs.search) { |
1086 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1087 return; |
7798 | 1088 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1089 |
7295 | 1090 s = g_malloc(sizeof(struct _search)); |
1091 s->gtkconv = gtkconv; | |
7929 | 1092 |
1093 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1094 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1095 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1096 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1097 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1098 GTK_RESPONSE_OK); |
7929 | 1099 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1100 G_CALLBACK(do_search_cb), s); | |
1101 | |
11243 | 1102 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1103 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1104 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1105 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BORDER); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1106 gtk_container_set_border_width( |
11243 | 1107 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1108 | |
1109 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1110 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1111 hbox); |
7929 | 1112 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1113 | |
1114 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1115 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1116 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1117 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1118 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1119 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1120 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1121 | |
1122 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1123 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1124 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1125 g_signal_connect(G_OBJECT(s->entry), "changed", |
1126 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1127 gtkconv->dialogs.search); | |
1128 gtk_box_pack_start(GTK_BOX(hbox), s->entry, FALSE, FALSE, 0); | |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1129 |
7295 | 1130 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1131 gtk_widget_grab_focus(s->entry); |
7295 | 1132 } |
1133 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1134 static void |
9468 | 1135 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1136 { | |
11581 | 1137 GaimGtkWindow *win = data; |
1138 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1139 |
11338 | 1140 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1141 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1142 } | |
1143 | |
1144 } | |
1145 | |
1146 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1147 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1148 { |
11581 | 1149 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1150 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1151 |
11581 | 1152 conv = gaim_gtk_conv_window_get_active_gtkconv(win)->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1153 |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1154 gaim_gtk_pounce_editor_show(gaim_conversation_get_account(conv), |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1155 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1156 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1157 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1159 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1160 { |
11581 | 1161 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1162 GaimGtkConversation *gtkconv; |
8756 | 1163 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1164 |
11581 | 1165 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1166 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1167 | |
1168 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1169 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1170 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1171 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1172 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1173 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1174 { |
11581 | 1175 GaimGtkWindow *win = data; |
8756 | 1176 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1177 GaimGtkConversation *gtkconv; |
8756 | 1178 GtkIMHtmlToolbar *toolbar; |
1179 | |
11581 | 1180 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1181 conv = gtkconv->active_conv; | |
8756 | 1182 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1183 | |
1184 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1185 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1186 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1187 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1188 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1189 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1190 { |
11581 | 1191 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1192 GaimConversation *conv; |
7879 | 1193 GaimAccount *account; |
1194 const char *name; | |
1195 | |
11581 | 1196 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1197 account = gaim_conversation_get_account(conv); |
1198 name = gaim_conversation_get_name(conv); | |
1199 | |
11338 | 1200 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1201 GaimBuddy *b; |
1202 | |
1203 b = gaim_find_buddy(account, name); | |
1204 if (b != NULL) | |
9730 | 1205 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1206 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1207 GaimChat *c; |
1208 | |
1209 c = gaim_blist_find_chat(account, name); | |
1210 if (c != NULL) | |
9730 | 1211 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1212 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1216 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 { |
11581 | 1218 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1219 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1220 |
11581 | 1221 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1222 |
10810 | 1223 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1224 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1225 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1226 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1227 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1228 { |
11581 | 1229 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1230 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1231 |
11581 | 1232 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1233 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1234 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1235 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1236 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1237 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1238 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1239 { |
11581 | 1240 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1241 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1242 |
11581 | 1243 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1244 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1245 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1246 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1247 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1248 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1249 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1250 { |
11581 | 1251 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1252 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1253 |
11581 | 1254 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1255 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1256 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1257 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1258 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1259 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1260 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1261 { |
11581 | 1262 GaimGtkWindow *win = data; |
1263 | |
1264 close_conv_cb(NULL, GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1265 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1266 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1267 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1268 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1269 { |
11581 | 1270 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1271 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1272 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1273 |
11581 | 1274 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1275 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1276 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1277 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1278 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1279 logging = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1280 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1281 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1282 return; |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1283 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1284 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1285 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1286 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1287 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1288 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1289 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1290 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1291 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1292 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1293 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1294 } |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1295 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1296 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1297 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1298 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1299 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1300 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1301 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1302 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1303 /* Disable the logging second, so that the above message can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1304 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1305 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1306 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1307 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1309 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1310 { |
11581 | 1311 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1312 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1313 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1314 |
11581 | 1315 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1316 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1317 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1318 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1319 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1320 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1321 |
10377 | 1322 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1323 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
|
1324 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1325 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1326 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1327 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1328 { |
11581 | 1329 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1330 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1331 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1332 |
11581 | 1333 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1334 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1335 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1336 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1337 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1338 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1339 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1340 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1341 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1342 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1343 |
7961 | 1344 static void |
9188 | 1345 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1346 { | |
11581 | 1347 GaimGtkWindow *win = data; |
9188 | 1348 GaimConversation *conv; |
1349 GaimGtkConversation *gtkconv; | |
1350 | |
11581 | 1351 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1352 |
1353 if (!conv) | |
1354 return; | |
1355 | |
1356 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1357 | |
12188 | 1358 gaim_prefs_set_bool("/gaim/gtk/conversations/show_timestamps", |
9188 | 1359 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
1360 } | |
1361 | |
1362 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1363 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1364 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1365 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1366 GaimAccount *account; |
1367 GaimConnection *gc; | |
7961 | 1368 GaimPluginProtocolInfo *prpl_info = NULL; |
1369 char *real_who; | |
1370 | |
1371 account = gaim_conversation_get_account(conv); | |
10431 | 1372 g_return_if_fail(account != NULL); |
1373 | |
1374 gc = gaim_account_get_connection(account); | |
1375 g_return_if_fail(gc != NULL); | |
1376 | |
1377 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1378 | |
1379 if (prpl_info && prpl_info->get_cb_real_name) | |
1380 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1381 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1382 else | |
1383 real_who = g_strdup(who); | |
1384 | |
1385 if(!real_who) | |
1386 return; | |
1387 | |
10431 | 1388 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1389 |
1390 g_free(real_who); | |
1391 } | |
1392 | |
1393 static void | |
10810 | 1394 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1395 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1396 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1397 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1398 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1399 GtkTreeSelection *sel; |
9554 | 1400 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1401 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1402 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1403 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1404 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1405 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1406 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1407 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1408 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
|
1409 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1410 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1411 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1412 chat_do_im(gtkconv, name); |
9554 | 1413 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1414 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1415 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1416 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1417 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1418 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1419 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1420 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1421 GaimConvChat *chat; |
11869 | 1422 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1423 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1424 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1425 GtkTreeSelection *sel; |
10504 | 1426 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1427 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1428 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1429 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1430 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1431 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1432 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1433 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
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 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1436 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1437 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1438 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1439 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1440 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1441 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
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 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1444 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1445 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1446 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1447 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1448 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1449 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1450 |
11869 | 1451 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1452 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1453 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1454 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1455 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1456 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1457 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1458 { |
1459 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1460 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1461 chat_do_im(gtkconv, who); |
5908
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 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1464 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1465 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1466 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1467 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1468 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1469 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1470 | |
1471 serv_send_file(gc, who, NULL); | |
1472 } | |
1473 | |
1474 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1475 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
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 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1478 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1479 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1480 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1481 chat_do_info(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1482 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1483 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1484 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1485 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1486 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1487 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1488 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1489 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1490 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1491 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1492 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1493 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1494 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1495 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1496 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1497 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1498 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1499 * 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
|
1500 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1501 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1502 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1503 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1504 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1505 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1506 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1507 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1508 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1509 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1510 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1511 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1512 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1513 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1514 GaimAccount *account; |
6695 | 1515 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1516 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1517 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1518 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1519 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1520 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1521 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1522 if (b != NULL) |
9730 | 1523 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1524 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1525 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1526 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1527 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1528 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1529 |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1530 static GtkTextMark * |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1531 get_mark_for_user(GaimGtkConversation *gtkconv, const char *who) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1532 { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1533 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
|
1534 char *tmp = g_strconcat("user:", who, NULL); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1535 GtkTextMark *mark = gtk_text_buffer_get_mark(buf, tmp); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1536 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1537 g_free(tmp); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1538 return mark; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1539 } |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1540 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1541 static void |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1542 menu_last_said_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1543 { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1544 GtkTextMark *mark; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1545 const char *who; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1546 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1547 who = g_object_get_data(G_OBJECT(w), "user_data"); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1548 mark = get_mark_for_user(gtkconv, who); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1549 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1550 if (mark != NULL) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1551 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
|
1552 else |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1553 g_return_if_reached(); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1554 } |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1555 |
8143 | 1556 static GtkWidget * |
10504 | 1557 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1558 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1559 { | |
1560 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1561 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1562 gboolean is_me = FALSE; |
8143 | 1563 GtkWidget *button; |
1564 | |
1565 /* | |
1566 * If a menu already exists, destroy it before creating a new one, | |
1567 * thus freeing-up the memory it occupied. | |
1568 */ | |
1569 if (menu) | |
1570 gtk_widget_destroy(menu); | |
1571 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1572 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1573 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1574 |
8143 | 1575 menu = gtk_menu_new(); |
1576 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1577 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1578 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1579 G_CALLBACK(menu_chat_im_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1580 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
|
1581 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1582 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1583 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1584 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1585 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1586 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1587 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
|
1588 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1589 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1590 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
|
1591 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
|
1592 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1593 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1594 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1595 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1596 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1597 } |
9498 | 1598 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1599 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1600 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
|
1601 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1602 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1603 } |
1604 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1605 if (prpl_info->get_cb_away) { |
10221 | 1606 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
|
1607 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1608 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1609 } |
1610 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1611 if (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1612 if (gaim_find_buddy(gc->account, who)) |
10221 | 1613 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
|
1614 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1615 else |
10221 | 1616 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
|
1617 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1618 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1619 } |
1620 | |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1621 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
|
1622 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
|
1623 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
|
1624 if (!get_mark_for_user(GAIM_GTK_CONVERSATION(conv), who)) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1625 gtk_widget_set_sensitive(button, FALSE); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1626 |
8143 | 1627 return menu; |
1628 } | |
1629 | |
1630 | |
1631 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1632 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1633 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1634 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1635 GaimPluginProtocolInfo *prpl_info = NULL; |
1636 GaimGtkChatPane *gtkchat; | |
1637 GaimConnection *gc; | |
1638 GaimAccount *account; | |
1639 GtkTreeSelection *sel; | |
1640 GtkTreeIter iter; | |
1641 GtkTreeModel *model; | |
1642 GtkWidget *menu; | |
1643 gchar *who; | |
1644 | |
1645 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1646 gtkchat = gtkconv->u.chat; | |
1647 account = gaim_conversation_get_account(conv); | |
1648 gc = account->gc; | |
1649 | |
1650 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1651 | |
1652 if (gc != NULL) | |
1653 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1654 | |
1655 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1656 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1657 return FALSE; | |
1658 | |
9498 | 1659 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1660 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1661 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1662 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1663 0, GDK_CURRENT_TIME); |
10504 | 1664 g_free(who); |
8143 | 1665 |
1666 return TRUE; | |
1667 } | |
1668 | |
1669 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1670 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1671 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1672 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1673 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1674 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1675 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1676 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1677 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1678 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1679 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1680 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1681 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1682 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1683 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1684 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1685 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1686 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1687 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1688 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1689 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1690 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
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 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
|
1693 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1694 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1695 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1696 return FALSE; |
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 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1699 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1702 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
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_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1705 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
|
1706 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1707 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1708 chat_do_im(gtkconv, who); |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1709 } else if (event->button == 2 && event->type == GDK_BUTTON_PRESS) { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1710 /* Move to user's anchor */ |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1711 GtkTextMark *mark = get_mark_for_user(gtkconv, who); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1712 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1713 if(mark != NULL) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1714 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(gtkconv->imhtml), mark, 0.1, FALSE, 0, 0); |
7398 | 1715 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1716 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1717 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1718 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1719 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1720 |
10504 | 1721 g_free(who); |
1722 gtk_tree_path_free(path); | |
1723 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1724 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1725 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1726 |
8133 | 1727 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1728 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1729 { |
10827 | 1730 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1731 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1732 int index, i, total, found = 0; |
8133 | 1733 |
11581 | 1734 win = gtkconv->win; |
1735 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1736 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1737 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1738 /* First check the tabs after (forward) or before (!forward) this position. */ |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1739 for (i = forward ? index + 1 : index - 1; |
11581 | 1740 !found && (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1741 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1742 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1743 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1744 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1745 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1746 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1747 found = 1; |
8133 | 1748 } |
11252 | 1749 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1750 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1751 /* Now check from the beginning up to (forward) or end back to (!forward) this position. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1752 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1753 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1754 (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1755 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1756 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1757 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1758 found = 1; |
8133 | 1759 } |
10827 | 1760 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1761 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1762 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1763 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1764 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1765 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1766 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1767 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1768 } |
11581 | 1769 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1770 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1771 } |
8133 | 1772 } |
1773 | |
10827 | 1774 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1775 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1776 } |
1777 | |
4359 | 1778 static gboolean |
8105 | 1779 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1780 { |
11581 | 1781 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1782 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1783 GaimGtkConversation *gtkconv; |
8105 | 1784 int curconv; |
1785 | |
10810 | 1786 gtkconv = (GaimGtkConversation *)data; |
10849 | 1787 conv = gtkconv->active_conv; |
11581 | 1788 win = gtkconv->win; |
1789 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1790 |
8105 | 1791 /* If CTRL was held down... */ |
1792 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1793 switch (event->keyval) { |
1794 case GDK_Up: | |
1795 if (!conv->send_history) | |
1796 break; | |
1797 | |
1798 if (!conv->send_history->prev) { | |
1799 GtkTextIter start, end; | |
1800 | |
1801 if (conv->send_history->data) | |
1802 g_free(conv->send_history->data); | |
1803 | |
1804 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1805 &start); | |
1806 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1807 | |
1808 conv->send_history->data = | |
8506 | 1809 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1810 } |
8677 | 1811 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1812 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1813 GObject *object; |
8677 | 1814 GtkTextIter iter; |
1815 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1816 |
1817 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1818 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1819 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1820 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1821 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
|
1822 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1823 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1824 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1825 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1826 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
|
1827 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1828 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1829 |
8061 | 1830 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1831 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1832 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1833 0, NULL); |
8677 | 1834 /* this is mainly just a hack so the formatting at the |
1835 * cursor gets picked up. */ | |
1836 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1837 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1838 } |
1839 | |
8105 | 1840 return TRUE; |
4359 | 1841 break; |
1842 | |
1843 case GDK_Down: | |
1844 if (!conv->send_history) | |
1845 break; | |
1846 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1847 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1848 GObject *object; |
8677 | 1849 GtkTextIter iter; |
1850 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1851 |
4359 | 1852 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1853 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1854 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1855 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1856 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
|
1857 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1858 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1859 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1860 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1861 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
|
1862 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1863 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1864 |
8105 | 1865 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1866 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1867 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1868 0, NULL); |
8677 | 1869 /* this is mainly just a hack so the formatting at the |
1870 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1871 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1872 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1873 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1874 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1875 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1876 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1877 } |
4359 | 1878 } |
1879 | |
8105 | 1880 return TRUE; |
4359 | 1881 break; |
8105 | 1882 |
13354
da2179c099f0
[gaim-migrate @ 15726]
Richard Laager <rlaager@wiktel.com>
parents:
13352
diff
changeset
|
1883 case GDK_Page_Down: |
8143 | 1884 case ']': |
11581 | 1885 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1886 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1887 else |
11581 | 1888 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1889 return TRUE; |
1890 break; | |
1891 | |
13354
da2179c099f0
[gaim-migrate @ 15726]
Richard Laager <rlaager@wiktel.com>
parents:
13352
diff
changeset
|
1892 case GDK_Page_Up: |
8143 | 1893 case '[': |
11581 | 1894 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1895 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1896 else |
11581 | 1897 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1898 return TRUE; |
1899 break; | |
1900 | |
8108 | 1901 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1902 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1903 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1904 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1905 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1906 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1907 } |
8108 | 1908 |
1909 return TRUE; | |
1910 break; | |
1911 | |
11252 | 1912 case GDK_comma: |
11581 | 1913 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1914 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1915 curconv - 1); |
1916 break; | |
1917 | |
1918 case GDK_period: | |
11581 | 1919 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1920 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1921 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1922 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1923 #else |
1924 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1925 #endif | |
11252 | 1926 break; |
1927 | |
8105 | 1928 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1929 } |
8758 | 1930 |
8105 | 1931 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1932 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1933 { |
10864 | 1934 if (event->keyval > '0' && event->keyval <= '9') |
1935 { | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1936 guint switchto = event->keyval - '1'; |
11581 | 1937 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1938 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1939 |
1940 return TRUE; | |
1941 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1942 } |
8758 | 1943 |
8105 | 1944 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1945 else |
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 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1948 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1949 case GDK_Tab: |
9605 | 1950 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1951 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1952 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1953 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1954 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1955 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1956 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1957 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1958 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1959 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1960 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1961 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1962 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1963 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1964 } |
4359 | 1965 return FALSE; |
1966 } | |
1967 | |
1968 /* | |
1969 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1970 * 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
|
1971 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1972 * 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
|
1973 * going all the way down to the notebook. I suspect a bug in |
4359 | 1974 * GtkTextView, but I'm not ready to point any fingers yet. |
1975 */ | |
1976 static gboolean | |
1977 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1978 { | |
1979 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1980 /* Right single click */ | |
1981 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1982 | |
1983 return TRUE; | |
1984 } | |
1985 | |
1986 return FALSE; | |
1987 } | |
1988 | |
8173 | 1989 /* |
1990 * If someone tries to type into the conversation backlog of a | |
1991 * conversation window then we yank focus from the conversation backlog | |
1992 * and give it to the text entry box so that people can type | |
1993 * all the live long day and it will get entered into the entry box. | |
1994 */ | |
6057 | 1995 static gboolean |
8105 | 1996 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1997 { |
1998 GaimGtkConversation *gtkconv = data; | |
1999 | |
8237 | 2000 /* If we have a valid key for the conversation display, then exit */ |
8224 | 2001 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 2002 (event->keyval == GDK_F10) || |
2003 (event->keyval == GDK_Shift_L) || | |
2004 (event->keyval == GDK_Shift_R) || | |
2005 (event->keyval == GDK_Escape) || | |
8177 | 2006 (event->keyval == GDK_Up) || |
2007 (event->keyval == GDK_Down) || | |
2008 (event->keyval == GDK_Left) || | |
8191 | 2009 (event->keyval == GDK_Right) || |
2010 (event->keyval == GDK_Home) || | |
9297 | 2011 (event->keyval == GDK_End) || |
2012 (event->keyval == GDK_Tab) || | |
2013 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 2014 return FALSE; |
2015 | |
2016 if (event->type == GDK_KEY_RELEASE) | |
2017 gtk_widget_grab_focus(gtkconv->entry); | |
2018 | |
2019 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
2020 | |
2021 return TRUE; | |
6057 | 2022 } |
2023 | |
4359 | 2024 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2025 gaim_gtkconv_set_active_conversation(GaimConversation *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 GaimGtkConversation *gtkconv; |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2028 GaimConversation *old_conv; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2029 GtkIMHtml *entry; |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2030 const char *protocol_name; |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2031 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2032 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2033 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2034 gtkconv = GAIM_GTK_CONVERSATION(conv); |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2035 old_conv = gtkconv->active_conv; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2036 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2037 if (old_conv == conv) |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2038 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2039 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2040 gaim_conversation_close_logs(old_conv); |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2041 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2042 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2043 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2044 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
|
2045 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2046 entry = GTK_IMHTML(gtkconv->entry); |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2047 protocol_name = gaim_account_get_protocol_name(conv->account); |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2048 gtk_imhtml_set_protocol_name(entry, protocol_name); |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2049 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol_name); |
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2050 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2051 if (!(conv->features & GAIM_CONNECTION_HTML)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2052 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2053 else if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO && |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2054 !(old_conv->features & GAIM_CONNECTION_FORMATTING_WBFO)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2055 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2056 /* The old conversation allowed formatting on parts of the |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2057 * buffer, but the new one only allows it on the whole |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2058 * buffer. This code saves the formatting from the current |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2059 * position of the cursor, clears the formatting, then |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2060 * applies the saved formatting to the entire buffer. */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2061 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2062 gboolean bold; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2063 gboolean italic; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2064 gboolean underline; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2065 char *fontface = gtk_imhtml_get_current_fontface(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2066 char *forecolor = gtk_imhtml_get_current_forecolor(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2067 char *backcolor = gtk_imhtml_get_current_backcolor(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2068 char *background = gtk_imhtml_get_current_background(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2069 gint fontsize = gtk_imhtml_get_current_fontsize(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2070 gboolean bold2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2071 gboolean italic2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2072 gboolean underline2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2073 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2074 gtk_imhtml_get_current_format(entry, &bold, &italic, &underline); |
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 /* Clear existing formatting */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2077 gtk_imhtml_clear_formatting(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2078 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2079 /* Apply saved formatting to the whole buffer. */ |
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_get_current_format(entry, &bold2, &italic2, &underline2); |
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 (bold != bold2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2084 gtk_imhtml_toggle_bold(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2085 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2086 if (italic != italic2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2087 gtk_imhtml_toggle_italic(entry); |
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 if (underline != underline2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2090 gtk_imhtml_toggle_underline(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2091 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2092 gtk_imhtml_toggle_fontface(entry, fontface); |
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 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2095 gtk_imhtml_font_set_size(entry, fontsize); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2096 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2097 gtk_imhtml_toggle_forecolor(entry, forecolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2098 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2099 if (!(conv->features & GAIM_CONNECTION_NO_BGCOLOR)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2100 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2101 gtk_imhtml_toggle_backcolor(entry, backcolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2102 gtk_imhtml_toggle_background(entry, background); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2103 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2104 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2105 g_free(fontface); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2106 g_free(forecolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2107 g_free(backcolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2108 g_free(background); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2109 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2110 else |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2111 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2112 /* 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
|
2113 * 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
|
2114 * 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
|
2115 * 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
|
2116 gtk_imhtml_set_whole_buffer_formatting_only(entry, |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2117 (conv->features & GAIM_CONNECTION_FORMATTING_WBFO)); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2118 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2119 |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
2120 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-switched", conv); |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2121 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2122 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
2123 void |
11604 | 2124 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
2125 { | |
2126 GaimGtkConversation *gtkconv; | |
2127 | |
2128 g_return_if_fail(conv != NULL); | |
2129 | |
2130 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2131 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2132 gaim_gtkconv_set_active_conversation(conv); |
11604 | 2133 |
2134 gray_stuff_out(gtkconv); | |
2135 update_typing_icon(gtkconv); | |
2136 | |
2137 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
2138 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
2139 } | |
2140 | |
2141 static void | |
4673 | 2142 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 2143 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2144 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 2145 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2146 GaimConversation *conv; |
4359 | 2147 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2148 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2149 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2150 |
11594 | 2151 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 2152 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 2153 } |
2154 | |
2155 static void | |
2156 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
2157 gchar *new_text, gint new_text_length, gpointer user_data) | |
2158 { | |
10810 | 2159 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2160 GaimConversation *conv; | |
2161 | |
2162 g_return_if_fail(gtkconv != NULL); | |
11508 | 2163 |
10810 | 2164 conv = gtkconv->active_conv; |
4359 | 2165 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2166 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2167 return; |
2168 | |
10810 | 2169 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2170 gtk_text_iter_is_end(position))); | |
4359 | 2171 } |
2172 | |
2173 static void | |
2174 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2175 GtkTextIter *end_pos, gpointer user_data) | |
2176 { | |
10810 | 2177 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2178 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2179 GaimConvIm *im; |
4359 | 2180 |
10810 | 2181 g_return_if_fail(gtkconv != NULL); |
11508 | 2182 |
10810 | 2183 conv = gtkconv->active_conv; |
4359 | 2184 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2185 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2186 return; |
2187 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2188 im = GAIM_CONV_IM(conv); |
4359 | 2189 |
2190 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2191 | |
2192 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2193 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2194 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2195 |
2196 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2197 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2198 GAIM_NOT_TYPING); |
4359 | 2199 } |
2200 else { | |
2201 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2202 got_typing_keypress(gtkconv, FALSE); |
4359 | 2203 } |
2204 } | |
2205 | |
8189 | 2206 /************************************************************************** |
2207 * A bunch of buddy icon functions | |
2208 **************************************************************************/ | |
11581 | 2209 GdkPixbuf * |
2210 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2211 { |
10116 | 2212 GaimAccount *account = NULL; |
2213 const char *name = NULL; | |
7143 | 2214 GdkPixbuf *status = NULL; |
2215 | |
10116 | 2216 g_return_val_if_fail(conv != NULL, NULL); |
2217 | |
2218 account = gaim_conversation_get_account(conv); | |
2219 name = gaim_conversation_get_name(conv); | |
2220 | |
2221 g_return_val_if_fail(account != NULL, NULL); | |
2222 g_return_val_if_fail(name != NULL, NULL); | |
2223 | |
13090 | 2224 /* Use the buddy icon, if possible */ |
11338 | 2225 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2226 GaimBuddy *b = gaim_find_buddy(account, name); |
2227 if (b != NULL) { | |
2228 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2229 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2230 } |
2231 } | |
2232 | |
13090 | 2233 /* If they don't have a buddy icon, then use the PRPL icon */ |
2234 if (status == NULL) | |
2235 status = gaim_gtk_create_prpl_icon(account, small_icon ? 0.5 : 1.0); | |
2236 | |
7143 | 2237 return status; |
2238 } | |
2239 | |
8189 | 2240 static void |
2241 update_tab_icon(GaimConversation *conv) | |
2242 { | |
2243 GaimGtkConversation *gtkconv; | |
11581 | 2244 GaimGtkWindow *win; |
8189 | 2245 GaimAccount *account; |
2246 const char *name; | |
2247 GdkPixbuf *status = NULL; | |
2248 | |
10116 | 2249 g_return_if_fail(conv != NULL); |
2250 | |
8189 | 2251 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2252 win = gtkconv->win; |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2253 if (conv != gtkconv->active_conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2254 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2255 |
8189 | 2256 name = gaim_conversation_get_name(conv); |
2257 account = gaim_conversation_get_account(conv); | |
2258 | |
11581 | 2259 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2260 |
10116 | 2261 g_return_if_fail(status != NULL); |
2262 | |
8189 | 2263 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2264 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2265 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2266 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2267 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2268 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2269 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2270 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2271 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2272 { |
11581 | 2273 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2274 | |
2275 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2276 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2277 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2278 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2279 } |
8189 | 2280 } |
2281 | |
2282 static gboolean | |
2283 redraw_icon(gpointer data) | |
2284 { | |
10810 | 2285 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2286 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2287 GaimAccount *account; |
2288 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2289 |
2290 GdkPixbuf *buf; | |
2291 GdkPixbuf *scale; | |
2292 GdkPixmap *pm; | |
2293 GdkBitmap *bm; | |
2294 gint delay; | |
9318 | 2295 int scale_width, scale_height; |
8189 | 2296 |
2297 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2298 account = gaim_conversation_get_account(conv); |
2299 if(account && account->gc) | |
2300 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2301 |
2302 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2303 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2304 | |
10483 | 2305 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2306 NULL, &scale_width, &scale_height); |
2307 | |
2308 /* this code is ugly, and scares me */ | |
8189 | 2309 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2310 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2311 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2312 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2313 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2314 GDK_INTERP_BILINEAR); |
8189 | 2315 |
2316 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2317 g_object_unref(G_OBJECT(scale)); | |
2318 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2319 g_object_unref(G_OBJECT(pm)); | |
2320 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2321 | |
2322 if (bm) | |
2323 g_object_unref(G_OBJECT(bm)); | |
2324 | |
9131 | 2325 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2326 |
2327 if (delay < 100) | |
9131 | 2328 delay = 100; |
2329 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2330 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2331 |
2332 return FALSE; | |
2333 } | |
2334 | |
2335 static void | |
10810 | 2336 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2337 { |
2338 int delay; | |
2339 | |
8228 | 2340 if (gtkconv->u.im->anim == NULL) |
2341 return; | |
2342 | |
8202 | 2343 if (gtkconv->u.im->icon_timer != 0) |
2344 return; | |
2345 | |
8189 | 2346 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2347 return; | |
2348 | |
10639 | 2349 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2350 | |
2351 if (delay < 100) | |
2352 delay = 100; | |
2353 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2354 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2355 } |
2356 | |
2357 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2358 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2359 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2360 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2361 GaimGtkWindow *gtkwin; |
2362 | |
2363 g_return_if_fail(conv != NULL); | |
2364 | |
9887 | 2365 if (gtkconv->u.im->icon_container != NULL) |
2366 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2367 |
2368 if (gtkconv->u.im->anim != NULL) | |
2369 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2370 | |
2371 if (gtkconv->u.im->icon_timer != 0) | |
2372 g_source_remove(gtkconv->u.im->icon_timer); | |
2373 | |
2374 if (gtkconv->u.im->iter != NULL) | |
2375 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2376 | |
2377 gtkconv->u.im->icon_timer = 0; | |
2378 gtkconv->u.im->icon = NULL; | |
2379 gtkconv->u.im->anim = NULL; | |
2380 gtkconv->u.im->iter = NULL; | |
10456 | 2381 gtkconv->u.im->icon_container = NULL; |
9687 | 2382 gtkconv->u.im->show_icon = FALSE; |
10456 | 2383 |
11581 | 2384 gtkwin = gtkconv->win; |
10456 | 2385 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2386 } |
2387 | |
9497 | 2388 static void |
9504 | 2389 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2390 { |
10810 | 2391 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2392 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2393 FILE *fp; |
2394 GaimBuddyIcon *icon; | |
2395 const void *data; | |
2396 size_t len; | |
2397 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2398 if ((fp = g_fopen(filename, "wb")) == NULL) { |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
2399 gaim_notify_error(gtkconv, NULL, _("Unable to open file."), NULL); |
9497 | 2400 return; |
2401 } | |
2402 | |
2403 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2404 data = gaim_buddy_icon_get_data(icon, &len); | |
2405 | |
2406 if ((len <= 0) || (data == NULL)) { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
2407 gaim_notify_error(gtkconv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2408 return; |
2409 } | |
2410 | |
2411 fwrite(data, 1, len, fp); | |
2412 fclose(fp); | |
2413 } | |
2414 | |
2415 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2416 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2417 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2418 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2419 const gchar *ext; |
9497 | 2420 gchar *buf; |
2421 | |
2422 g_return_if_fail(conv != NULL); | |
9504 | 2423 |
10953 | 2424 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2425 if (ext == NULL) | |
2426 ext = "icon"; | |
2427 | |
2428 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2429 |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
2430 gaim_request_file(gtkconv, _("Save Icon"), buf, TRUE, |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2431 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2432 |
2433 g_free(buf); | |
2434 } | |
2435 | |
11581 | 2436 static void |
2437 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2438 { | |
2439 if (gtkconv->u.im->icon_timer != 0) | |
2440 g_source_remove(gtkconv->u.im->icon_timer); | |
2441 | |
2442 gtkconv->u.im->icon_timer = 0; | |
2443 } | |
2444 | |
2445 | |
2446 static void | |
2447 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2448 { | |
2449 gtkconv->u.im->animate = | |
2450 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2451 | |
2452 if (gtkconv->u.im->animate) | |
2453 start_anim(NULL, gtkconv); | |
2454 else | |
2455 stop_anim(NULL, gtkconv); | |
2456 } | |
2457 | |
8189 | 2458 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2459 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2460 { |
2461 static GtkWidget *menu = NULL; | |
2462 GtkWidget *button; | |
2463 | |
2464 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2465 return FALSE; | |
2466 | |
2467 /* | |
2468 * If a menu already exists, destroy it before creating a new one, | |
2469 * thus freeing-up the memory it occupied. | |
2470 */ | |
2471 if (menu != NULL) | |
2472 gtk_widget_destroy(menu); | |
2473 | |
2474 menu = gtk_menu_new(); | |
2475 | |
2476 if (gtkconv->u.im->anim && | |
2477 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2478 { | |
2479 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2480 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2481 gtkconv->u.im->icon_timer); |
2482 } | |
2483 | |
2484 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2485 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2486 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2487 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2488 gtk_widget_show(button); | |
2489 | |
2490 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
|
2491 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2492 0, 0, NULL); |
2493 | |
2494 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2495 | |
2496 return TRUE; | |
2497 } | |
10456 | 2498 |
2499 static void | |
2500 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2501 { | |
11581 | 2502 GaimGtkWindow *win = data; |
10456 | 2503 GaimConversation *conv; |
2504 GaimGtkConversation *gtkconv; | |
2505 gboolean active; | |
2506 | |
11581 | 2507 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2508 |
2509 if (!conv) | |
2510 return; | |
2511 | |
11338 | 2512 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2513 |
2514 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2515 | |
2516 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2517 gtkconv->u.im->show_icon = active; | |
2518 if (active) | |
2519 gaim_gtkconv_update_buddy_icon(conv); | |
2520 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2521 remove_icon(gtkconv); |
10456 | 2522 } |
2523 | |
8189 | 2524 /************************************************************************** |
2525 * End of the bunch of buddy icon functions | |
2526 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2527 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2528 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2529 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2530 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2531 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2532 if(gtkconv->win==hidden_convwin) { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
2533 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2534 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2535 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2536 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2537 gaim_gtkconv_set_active_conversation(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2538 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2539 gaim_gtk_conv_window_raise(gtkconv->win); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2540 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2541 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2542 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2543 GList * |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2544 gaim_gtk_conversations_find_unseen_list(GaimConversationType type, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2545 GaimUnseenState min_state, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2546 gboolean hidden_only, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2547 guint max_count) |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2548 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2549 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2550 GList *r = NULL; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2551 guint c = 0; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2552 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2553 if (type == GAIM_CONV_TYPE_IM) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2554 l = gaim_get_ims(); |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2555 } else if (type == GAIM_CONV_TYPE_CHAT) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2556 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2557 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2558 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2559 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2560 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2561 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
|
2562 GaimConversation *conv = (GaimConversation*)l->data; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2563 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2564 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2565 if(gtkconv->active_conv != conv) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2566 continue; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2567 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2568 if (gtkconv->unseen_state >= min_state |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2569 && (!hidden_only || |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2570 (hidden_only && gtkconv->win == hidden_convwin))) { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2571 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2572 r = g_list_prepend(r, conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2573 c++; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2574 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2575 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2576 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2577 return r; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2578 } |
8189 | 2579 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2580 static void |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2581 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2582 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2583 g_return_if_fail(conv != NULL); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2584 gaim_gtkconv_present_conversation(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2585 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2586 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2587 guint |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2588 gaim_gtk_conversations_fill_menu(GtkWidget *menu, GList *convs) |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2589 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2590 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2591 guint ret=0; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2592 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2593 g_return_val_if_fail(menu != NULL, 0); |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2594 g_return_val_if_fail(convs != NULL, 0); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2595 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2596 for (l = convs; l != NULL ; l = l->next) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2597 GaimConversation *conv = (GaimConversation*)l->data; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2598 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2599 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2600 GtkWidget *icon = gtk_image_new(); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2601 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2602 GtkWidget *item; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2603 gchar *text = g_strdup_printf("%s (%d)", |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2604 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2605 gtkconv->unseen_count); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2606 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2607 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2608 g_object_unref(pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2609 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2610 item = gtk_image_menu_item_new_with_label(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2611 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
|
2612 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
|
2613 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2614 g_free(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2615 ret++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2616 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2617 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2618 return ret; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2619 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2620 |
11581 | 2621 GaimGtkWindow * |
2622 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2623 { | |
2624 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2625 return gtkconv->win; | |
2626 } | |
2627 | |
2628 static GtkItemFactoryEntry menu_items[] = | |
2629 { | |
2630 /* Conversation menu */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2631 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>", NULL }, |
11581 | 2632 |
2633 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2634 0, "<StockItem>", GAIM_STOCK_IM }, | |
2635 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2636 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2637 |
2638 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2639 "<StockItem>", GTK_STOCK_FIND }, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2640 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", GAIM_STOCK_LOG }, |
11581 | 2641 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2642 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
12897
e9b0c90ce58a
[gaim-migrate @ 15250]
Richard Laager <rlaager@wiktel.com>
parents:
12867
diff
changeset
|
2643 { N_("/Conversation/Clea_r Scrollback"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
11581 | 2644 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2645 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2646 |
2647 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2648 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2649 0, "<StockItem>", GAIM_STOCK_POUNCE }, |
11581 | 2650 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2651 "<StockItem>", GAIM_STOCK_INFO }, | |
2652 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2653 "<StockItem>", GAIM_STOCK_INVITE }, | |
2654 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2655 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2656 |
2657 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2658 "<StockItem>", GAIM_STOCK_EDIT }, | |
2659 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2660 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2661 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2662 "<StockItem>", GTK_STOCK_ADD }, | |
2663 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2664 "<StockItem>", GTK_STOCK_REMOVE }, | |
2665 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2666 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2667 |
2668 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2669 "<StockItem>", GAIM_STOCK_LINK }, | |
2670 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2671 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2672 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2673 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2674 |
2675 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2676 "<StockItem>", GTK_STOCK_CLOSE }, | |
2677 | |
2678 /* Options */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2679 { N_("/_Options"), NULL, NULL, 0, "<Branch>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2680 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2681 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2682 { 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
|
2683 { "/Options/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2684 { 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
|
2685 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>", NULL }, |
11581 | 2686 }; |
2687 | |
2688 static const int menu_item_count = | |
2689 sizeof(menu_items) / sizeof(*menu_items); | |
2690 | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2691 static const char * |
11581 | 2692 item_factory_translate_func (const char *path, gpointer func_data) |
2693 { | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2694 return _(path); |
11581 | 2695 } |
2696 | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2697 static void |
12816 | 2698 sound_method_pref_changed_cb(const char *name, GaimPrefType type, |
2699 gconstpointer value, gpointer data) | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2700 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2701 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2702 const char *method = value; |
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 if (!strcmp(method, "none")) |
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 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
|
2707 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2708 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2709 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2710 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2711 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2712 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2713 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2714 if (gtkconv != NULL) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2715 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
|
2716 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2717 gtk_widget_set_sensitive(win->menu.sounds, TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2718 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2719 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2720 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2721 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2722 static void |
12816 | 2723 show_buddy_icons_pref_changed_cb(const char *name, GaimPrefType type, |
2724 gconstpointer value, gpointer data) | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2725 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2726 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2727 gboolean show_icons = GPOINTER_TO_INT(value); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2728 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2729 if (!show_icons) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2730 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2731 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
|
2732 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2733 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2734 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2735 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2736 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2737 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2738 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2739 if (gtkconv != NULL) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2740 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
|
2741 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2742 gtk_widget_set_sensitive(win->menu.show_icon, TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2743 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2744 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2745 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2746 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2747 |
11581 | 2748 static GtkWidget * |
2749 setup_menubar(GaimGtkWindow *win) | |
2750 { | |
2751 GtkAccelGroup *accel_group; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2752 const char *method; |
11581 | 2753 |
2754 accel_group = gtk_accel_group_new (); | |
2755 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2756 g_object_unref(accel_group); | |
2757 | |
2758 win->menu.item_factory = | |
2759 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2760 | |
2761 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2762 (GtkTranslateFunc)item_factory_translate_func, |
11581 | 2763 NULL, NULL); |
2764 | |
2765 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2766 menu_items, win); | |
2767 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2768 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2769 | |
2770 | |
2771 win->menu.menubar = | |
2772 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2773 | |
2774 | |
2775 win->menu.view_log = | |
2776 gtk_item_factory_get_widget(win->menu.item_factory, | |
2777 N_("/Conversation/View Log")); | |
2778 | |
2779 /* --- */ | |
2780 | |
2781 win->menu.send_file = | |
2782 gtk_item_factory_get_widget(win->menu.item_factory, | |
2783 N_("/Conversation/Send File...")); | |
2784 | |
2785 win->menu.add_pounce = | |
2786 gtk_item_factory_get_widget(win->menu.item_factory, | |
2787 N_("/Conversation/Add Buddy Pounce...")); | |
2788 | |
2789 /* --- */ | |
2790 | |
2791 win->menu.get_info = | |
2792 gtk_item_factory_get_widget(win->menu.item_factory, | |
2793 N_("/Conversation/Get Info")); | |
2794 | |
2795 win->menu.invite = | |
2796 gtk_item_factory_get_widget(win->menu.item_factory, | |
2797 N_("/Conversation/Invite...")); | |
2798 | |
2799 /* --- */ | |
2800 | |
2801 win->menu.alias = | |
2802 gtk_item_factory_get_widget(win->menu.item_factory, | |
2803 N_("/Conversation/Alias...")); | |
2804 | |
2805 win->menu.block = | |
2806 gtk_item_factory_get_widget(win->menu.item_factory, | |
2807 N_("/Conversation/Block...")); | |
2808 | |
2809 win->menu.add = | |
2810 gtk_item_factory_get_widget(win->menu.item_factory, | |
2811 N_("/Conversation/Add...")); | |
2812 | |
2813 win->menu.remove = | |
2814 gtk_item_factory_get_widget(win->menu.item_factory, | |
2815 N_("/Conversation/Remove...")); | |
2816 | |
2817 /* --- */ | |
2818 | |
2819 win->menu.insert_link = | |
2820 gtk_item_factory_get_widget(win->menu.item_factory, | |
2821 N_("/Conversation/Insert Link...")); | |
2822 | |
2823 win->menu.insert_image = | |
2824 gtk_item_factory_get_widget(win->menu.item_factory, | |
2825 N_("/Conversation/Insert Image...")); | |
2826 | |
2827 /* --- */ | |
2828 | |
2829 win->menu.logging = | |
2830 gtk_item_factory_get_widget(win->menu.item_factory, | |
2831 N_("/Options/Enable Logging")); | |
2832 win->menu.sounds = | |
2833 gtk_item_factory_get_widget(win->menu.item_factory, | |
2834 N_("/Options/Enable Sounds")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2835 method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2836 if (!strcmp(method, "none")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2837 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2838 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
|
2839 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2840 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2841 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2842 gaim_prefs_connect_callback(win, "/gaim/gtk/sound/method", |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2843 sound_method_pref_changed_cb, win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2844 |
11581 | 2845 win->menu.show_formatting_toolbar = |
2846 gtk_item_factory_get_widget(win->menu.item_factory, | |
2847 N_("/Options/Show Formatting Toolbars")); | |
2848 win->menu.show_timestamps = | |
2849 gtk_item_factory_get_widget(win->menu.item_factory, | |
2850 N_("/Options/Show Timestamps")); | |
2851 win->menu.show_icon = | |
2852 gtk_item_factory_get_widget(win->menu.item_factory, | |
2853 N_("/Options/Show Buddy Icon")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2854 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
|
2855 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2856 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
|
2857 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2858 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2859 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2860 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
|
2861 show_buddy_icons_pref_changed_cb, win); |
11581 | 2862 |
2863 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2864 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2865 win->menu.tray); | |
2866 gtk_widget_show(win->menu.tray); | |
2867 | |
2868 gtk_widget_show(win->menu.menubar); | |
2869 | |
2870 return win->menu.menubar; | |
2871 } | |
2872 | |
4359 | 2873 |
2874 /************************************************************************** | |
2875 * Utility functions | |
2876 **************************************************************************/ | |
2877 | |
2878 static void | |
10810 | 2879 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2880 { |
10810 | 2881 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2882 GaimConvIm *im; |
4685 | 2883 |
4359 | 2884 /* |
2885 * 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
|
2886 * send GAIM_TYPED any time soon. |
4359 | 2887 */ |
2888 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2889 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2890 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2891 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2892 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2893 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2894 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2895 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2896 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2897 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2898 |
2899 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2900 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2901 GAIM_TYPING); |
4359 | 2902 |
2903 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2904 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2905 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2906 gaim_conv_im_set_type_again(im, 0); |
4359 | 2907 } |
2908 } | |
2909 | |
4736 | 2910 static void |
10810 | 2911 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2912 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2913 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2914 GaimConvIm *im = NULL; |
10810 | 2915 GaimConversation *conv = gtkconv->active_conv; |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2916 char *stock_id; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2917 const char *tooltip; |
11508 | 2918 |
11581 | 2919 gtkwin = gtkconv->win; |
4736 | 2920 |
12008 | 2921 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2922 im = GAIM_CONV_IM(conv); |
4736 | 2923 |
12008 | 2924 if (gtkwin->menu.typing_icon) { |
2925 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2926 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2927 |
12008 | 2928 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2929 return; | |
2930 | |
2931 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2932 stock_id = GAIM_STOCK_TYPING; | |
2933 tooltip = _("User is typing..."); | |
2934 } else { | |
2935 stock_id = GAIM_STOCK_TYPED; | |
2936 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2937 } |
12008 | 2938 |
2939 if (gtkwin->menu.typing_icon == NULL) | |
2940 { | |
2941 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
|
2942 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
|
2943 gtkwin->menu.typing_icon, |
12008 | 2944 tooltip); |
4736 | 2945 } |
12008 | 2946 else |
2947 { | |
2948 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2949 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2950 gtkwin->menu.typing_icon, | |
2951 tooltip); | |
2952 } | |
2953 | |
2954 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2955 } |
2956 | |
4685 | 2957 static gboolean |
11594 | 2958 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2959 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2960 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2961 GaimConversation *conv; |
4359 | 2962 GtkWidget *menu; |
2963 GList *child; | |
11594 | 2964 GaimBuddy *b; |
11581 | 2965 |
2966 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2967 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2968 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2969 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2970 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2971 account = gaim_conversation_get_account(conv); |
11581 | 2972 |
13131 | 2973 if (account == NULL) |
2974 return FALSE; | |
2975 | |
11594 | 2976 if (win->menu.send_to == NULL) |
4685 | 2977 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2978 |
11594 | 2979 if (!(b = gaim_find_buddy(account, conv->name))) |
2980 return FALSE; | |
2981 | |
2982 | |
2983 gtk_widget_show(win->menu.send_to); | |
4359 | 2984 |
2985 menu = gtk_menu_item_get_submenu( | |
11594 | 2986 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2987 |
2988 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2989 child != NULL; | |
2990 child = child->next) { | |
2991 | |
2992 GtkWidget *item = child->data; | |
11594 | 2993 GaimBuddy *item_buddy; |
2994 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2995 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2996 "gaim_buddy_name"); | |
2997 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2998 | |
2999 if (b == item_buddy) { | |
4359 | 3000 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
3001 break; | |
3002 } | |
3003 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
3004 |
4685 | 3005 return FALSE; |
4359 | 3006 } |
3007 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3008 static gboolean |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3009 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
|
3010 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3011 gtk_widget_set_sensitive(GTK_WIDGET(label), TRUE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3012 return FALSE; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3013 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3014 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3015 static gboolean |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3016 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
|
3017 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3018 gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3019 return FALSE; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3020 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3021 |
4359 | 3022 static void |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3023 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
|
3024 { |
11594 | 3025 GtkWidget *box; |
3026 GtkWidget *label; | |
3027 GtkWidget *image; | |
3028 GtkWidget *menuitem; | |
11625 | 3029 GdkPixbuf *pixbuf; |
11616 | 3030 gchar *text; |
11594 | 3031 |
3032 /* Create a pixmap for the protocol icon. */ | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3033 if (buddy != NULL) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3034 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
|
3035 else |
13090 | 3036 pixbuf = gaim_gtk_create_prpl_icon(account, 0.5); |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3037 |
11594 | 3038 /* Now convert it to GtkImage */ |
3039 if (pixbuf == NULL) | |
3040 image = gtk_image_new(); | |
3041 else | |
13090 | 3042 { |
11625 | 3043 image = gtk_image_new_from_pixbuf(pixbuf); |
13090 | 3044 g_object_unref(G_OBJECT(pixbuf)); |
3045 } | |
11594 | 3046 |
3047 gtk_size_group_add_widget(sg, image); | |
3048 | |
3049 /* Make our menu item */ | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3050 text = g_strdup_printf("%s (%s)", name, gaim_account_get_username(account)); |
11616 | 3051 menuitem = gtk_radio_menu_item_new_with_label(*group, text); |
3052 g_free(text); | |
11594 | 3053 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
3054 | |
3055 /* Do some evil, see some evil, speak some evil. */ | |
3056 box = gtk_hbox_new(FALSE, 0); | |
3057 | |
3058 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
3059 g_object_ref(label); | |
3060 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
3061 | |
3062 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
3063 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
3064 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3065 if (buddy != NULL && |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3066 !gaim_presence_is_online(gaim_buddy_get_presence(buddy)) && |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3067 !gaim_account_supports_offline_message(account, buddy)) |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3068 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3069 gtk_widget_set_sensitive(label, FALSE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3070 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3071 /* Set the label sensitive when the menuitem is highlighted and |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3072 * insensitive again when the mouse leaves it. This way, it |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3073 * doesn't appear weird from the highlighting of the embossed |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3074 * (insensitive style) text.*/ |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3075 g_signal_connect(menuitem, "enter-notify-event", |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3076 G_CALLBACK(send_to_item_enter_notify_cb), label); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3077 g_signal_connect(menuitem, "leave-notify-event", |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3078 G_CALLBACK(send_to_item_leave_notify_cb), label); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3079 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3080 |
11594 | 3081 g_object_unref(label); |
3082 | |
3083 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
3084 | |
3085 gtk_widget_show(label); | |
3086 gtk_widget_show(image); | |
3087 gtk_widget_show(box); | |
3088 | |
3089 /* Set our data and callbacks. */ | |
3090 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3091 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(name), g_free); |
11594 | 3092 |
3093 g_signal_connect(G_OBJECT(menuitem), "activate", | |
3094 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
3095 | |
3096 gtk_widget_show(menuitem); | |
3097 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3098 } | |
3099 | |
3100 static void | |
3101 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 3102 { |
4359 | 3103 GtkWidget *menu; |
3104 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3105 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 3106 GaimGtkConversation *gtkconv; |
3107 GSList *l, *buds; | |
3108 | |
3109 g_return_if_fail(win != NULL); | |
3110 | |
3111 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
3112 | |
11604 | 3113 g_return_if_fail(gtkconv != NULL); |
3114 | |
11594 | 3115 if (win->menu.send_to != NULL) |
3116 gtk_widget_destroy(win->menu.send_to); | |
3117 | |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12272
diff
changeset
|
3118 /* Build the Send To menu */ |
11594 | 3119 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
3120 gtk_widget_show(win->menu.send_to); | |
4359 | 3121 |
3122 menu = gtk_menu_new(); | |
11581 | 3123 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 3124 win->menu.send_to, 2); |
3125 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 3126 |
3127 gtk_widget_show(menu); | |
3128 | |
11604 | 3129 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
3130 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
|
3131 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3132 if (buds == NULL) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3133 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3134 /* The user isn't on the buddy list. */ |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3135 create_sendto_item(menu, sg, &group, NULL, gtkconv->active_conv->account, gtkconv->active_conv->name); |
11604 | 3136 } |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3137 else |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3138 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3139 GList *list = NULL, *iter; |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3140 for (l = buds; l != NULL; l = l->next) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3141 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3142 GaimBlistNode *node; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3143 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3144 node = (GaimBlistNode *) gaim_buddy_get_contact((GaimBuddy *)l->data); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3145 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3146 for (node = node->child; node != NULL; node = node->next) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3147 { |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
3148 GaimBuddy *buddy = (GaimBuddy *)node; |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3149 GaimAccount *account; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3150 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3151 if (!GAIM_BLIST_NODE_IS_BUDDY(node)) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3152 continue; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3153 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3154 account = gaim_buddy_get_account(buddy); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3155 if (gaim_account_is_connected(account)) |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3156 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3157 /* Use the GaimPresence to get unique buddies. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3158 GaimPresence *presence = gaim_buddy_get_presence(buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3159 if (!g_list_find(list, presence)) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3160 list = g_list_prepend(list, presence); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3161 } |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3162 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3163 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3164 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3165 /* 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
|
3166 * since we did a g_list_prepend() earlier. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3167 for (iter = g_list_last(list); iter != NULL; iter = iter->prev) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3168 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3169 GaimPresence *pre = iter->data; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3170 GaimBuddy *buddy = gaim_presence_get_buddies(pre)->data; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3171 create_sendto_item(menu, sg, &group, buddy, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3172 gaim_buddy_get_account(buddy), gaim_buddy_get_name(buddy)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3173 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3174 g_list_free(list); |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3175 g_slist_free(buds); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3176 } |
4359 | 3177 } |
3178 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3179 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3180 |
11594 | 3181 gtk_widget_show(win->menu.send_to); |
12455 | 3182 /* TODO: This should never be insensitive. Possibly hidden or not. */ |
11594 | 3183 if (!group) |
3184 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
3185 update_send_to_selection(win); | |
4359 | 3186 } |
3187 | |
3188 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3189 generate_invite_user_names(GaimConnection *gc) |
4359 | 3190 { |
6695 | 3191 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 3192 static GList *tmp = NULL; |
3193 | |
3194 if (tmp) | |
3195 g_list_free(tmp); | |
3196 | |
3197 tmp = g_list_append(NULL, ""); | |
3198 | |
3199 if (gc != NULL) { | |
4785 | 3200 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
3201 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
3202 continue; | |
6695 | 3203 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3204 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 3205 continue; |
6695 | 3206 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
3207 GaimBuddy *buddy; | |
3208 | |
3209 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
3210 continue; | |
3211 | |
3212 buddy = (GaimBuddy *)bnode; | |
3213 | |
3214 if (buddy->account == gc->account && | |
3215 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 3216 tmp = g_list_insert_sorted(tmp, buddy->name, |
3217 (GCompareFunc)g_utf8_collate); | |
6695 | 3218 } |
4359 | 3219 } |
3220 } | |
3221 } | |
3222 | |
3223 return tmp; | |
3224 } | |
3225 | |
9498 | 3226 static GdkPixbuf * |
9554 | 3227 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 3228 { |
9554 | 3229 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 3230 char *filename; |
10274 | 3231 const char *image = NULL; |
9554 | 3232 |
3233 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 3234 image = "founder.png"; |
9554 | 3235 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 3236 image = "op.png"; |
9554 | 3237 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 3238 image = "halfop.png"; |
9554 | 3239 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 3240 image = "voice.png"; |
9554 | 3241 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 3242 image = "ignored.png"; |
3243 } else { | |
3244 return NULL; | |
9554 | 3245 } |
10274 | 3246 |
3247 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
3248 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
3249 g_free(filename); | |
3250 | |
3251 if (!pixbuf) | |
3252 return NULL; | |
3253 | |
3254 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
3255 g_object_unref(pixbuf); | |
3256 | |
3257 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
3258 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 3259 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
3260 g_free(filename); | |
10274 | 3261 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 3262 g_object_unref(pixbuf); |
10274 | 3263 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
3264 g_object_unref(scale2); | |
9498 | 3265 } |
3266 | |
10274 | 3267 return scale; |
9498 | 3268 } |
3269 | |
4359 | 3270 static void |
11869 | 3271 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 3272 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3273 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3274 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3275 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3276 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3277 GaimPluginProtocolInfo *prpl_info; |
4359 | 3278 GtkListStore *ls; |
9498 | 3279 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3280 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3281 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3282 gboolean is_buddy; |
4359 | 3283 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3284 chat = GAIM_CONV_CHAT(conv); |
4359 | 3285 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3286 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3287 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3288 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3289 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3290 return; |
4359 | 3291 |
3292 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3293 | |
9554 | 3294 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 3295 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3296 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
|
3297 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3298 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3299 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3300 |
4359 | 3301 gtk_list_store_append(ls, &iter); |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3302 |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3303 if (is_me) |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3304 { |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3305 GdkColor send_color; |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3306 gdk_color_parse(SEND_COLOR, &send_color); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3307 |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3308 gtk_list_store_set(ls, &iter, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3309 CHAT_USERS_ICON_COLUMN, pixbuf, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3310 CHAT_USERS_ALIAS_COLUMN, alias, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3311 CHAT_USERS_NAME_COLUMN, name, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3312 CHAT_USERS_FLAGS_COLUMN, flags, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3313 CHAT_USERS_COLOR_COLUMN, &send_color, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3314 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3315 -1); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3316 } |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3317 else |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3318 { |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3319 gtk_list_store_set(ls, &iter, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3320 CHAT_USERS_ICON_COLUMN, pixbuf, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3321 CHAT_USERS_ALIAS_COLUMN, alias, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3322 CHAT_USERS_NAME_COLUMN, name, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3323 CHAT_USERS_FLAGS_COLUMN, flags, |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
3324 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, name), |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3325 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3326 -1); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3327 } |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3328 |
9554 | 3329 if (pixbuf) |
3330 g_object_unref(pixbuf); | |
4359 | 3331 } |
3332 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3333 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3334 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
|
3335 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3336 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3339 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3340 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3341 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3342 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3343 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3344 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3345 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3346 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3347 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3348 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3349 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3350 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3351 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3352 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3353 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3354 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3355 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3356 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3357 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3358 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3359 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3360 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3361 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3362 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3363 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3364 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3365 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3366 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3367 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3368 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3369 |
9605 | 3370 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3371 tab_complete(GaimConversation *conv) |
4359 | 3372 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3373 GaimGtkConversation *gtkconv; |
4359 | 3374 GtkTextIter cursor, word_start, start_buffer; |
3375 int start; | |
3376 int most_matched = -1; | |
3377 char *entered, *partial = NULL; | |
3378 char *text; | |
8021 | 3379 char *nick_partial; |
9605 | 3380 const char *prefix; |
4359 | 3381 GList *matches = NULL; |
9605 | 3382 gboolean command = FALSE; |
4359 | 3383 |
3384 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3385 | |
3386 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3387 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3388 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3389 | |
3390 word_start = cursor; | |
3391 | |
3392 /* if there's nothing there just return */ | |
3393 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3394 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
|
3395 |
4359 | 3396 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3397 &cursor, FALSE); | |
3398 | |
3399 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3400 start = strlen(text) - 1; | |
3401 | |
8021 | 3402 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3403 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3404 start-=2; |
3405 } | |
4359 | 3406 |
3407 /* find the start of the word that we're tabbing */ | |
3408 while (start >= 0 && text[start] != ' ') { | |
3409 gtk_text_iter_backward_char(&word_start); | |
3410 start--; | |
3411 } | |
3412 | |
9605 | 3413 prefix = gaim_gtk_get_cmd_prefix(); |
3414 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3415 command = TRUE; | |
3416 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3417 } | |
3418 | |
4359 | 3419 g_free(text); |
3420 | |
3421 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3422 &cursor, FALSE); | |
3423 | |
8021 | 3424 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3425 g_free(entered); |
11338 | 3426 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3427 } |
3428 | |
8021 | 3429 nick_partial = g_malloc(strlen(entered)+1); |
3430 | |
9605 | 3431 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3432 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3433 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3434 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3435 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3436 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3437 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3438 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3439 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3440 g_list_free(list); |
11338 | 3441 } 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
|
3442 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3443 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3444 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
|
3445 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3446 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3447 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3448 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3449 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3450 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3451 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3452 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3453 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3454 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3455 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3456 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
|
3457 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3458 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3459 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3460 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3461 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3462 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3463 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3464 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3465 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3466 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3467 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3468 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3469 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3470 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3471 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3472 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3473 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3474 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3475 } |
9605 | 3476 } else { |
3477 g_free(nick_partial); | |
3478 g_free(entered); | |
3479 return FALSE; | |
3480 } | |
3481 | |
8021 | 3482 g_free(nick_partial); |
3483 | |
4359 | 3484 /* we're only here if we're doing new style */ |
3485 | |
3486 /* if there weren't any matches, return */ | |
3487 if (!matches) { | |
3488 /* if matches isn't set partials won't be either */ | |
3489 g_free(entered); | |
11338 | 3490 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3491 } |
3492 | |
3493 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3494 | |
3495 if (!matches->next) { | |
3496 /* there was only one match. fill it in. */ | |
3497 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3498 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3499 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3500 | |
3501 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3502 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3503 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3504 g_free(tmp); | |
3505 } | |
3506 else | |
3507 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3508 matches->data, -1); | |
3509 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3510 g_free(matches->data); |
4359 | 3511 matches = g_list_remove(matches, matches->data); |
3512 } | |
3513 else { | |
3514 /* | |
3515 * there were lots of matches, fill in as much as possible | |
3516 * and display all of them | |
3517 */ | |
3518 char *addthis = g_malloc0(1); | |
3519 | |
3520 while (matches) { | |
3521 char *tmp = addthis; | |
3522 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3523 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3524 g_free(matches->data); |
4359 | 3525 matches = g_list_remove(matches, matches->data); |
3526 } | |
3527 | |
6982 | 3528 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3529 time(NULL)); |
3530 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3531 g_free(addthis); | |
3532 } | |
3533 | |
3534 g_free(entered); | |
3535 g_free(partial); | |
9605 | 3536 |
3537 return TRUE; | |
4359 | 3538 } |
3539 | |
10810 | 3540 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3541 { |
3542 GaimPluginProtocolInfo *prpl_info = NULL; | |
3543 GaimConnection *gc; | |
10810 | 3544 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3545 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3546 char *new_topic; |
8858 | 3547 const char *current_topic; |
7971 | 3548 |
3549 gc = gaim_conversation_get_gc(conv); | |
3550 | |
3551 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3552 return; | |
3553 | |
3554 if(prpl_info->set_chat_topic == NULL) | |
3555 return; | |
3556 | |
3557 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3558 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3559 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3560 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3561 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3562 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3563 g_free(new_topic); |
7971 | 3564 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3565 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3566 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3567 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3568 |
8858 | 3569 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3570 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3571 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3572 g_free(new_topic); |
7971 | 3573 } |
3574 | |
9554 | 3575 static gint |
3576 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3577 { | |
3578 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3579 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3580 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3581 gint ret = 0; |
3582 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3583 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3584 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3585 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3586 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3587 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3588 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3589 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3590 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3591 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3592 -1); |
9554 | 3593 |
3594 if (user1 == NULL || user2 == NULL) { | |
3595 if (!(user1 == NULL && user2 == NULL)) | |
3596 ret = (user1 == NULL) ? -1: 1; | |
3597 } else if (f1 != f2) { | |
3598 /* sort more important users first */ | |
3599 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3600 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3601 ret = buddy1 ? -1 : 1; |
9554 | 3602 } else { |
10904 | 3603 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3604 } |
3605 | |
3606 g_free(user1); | |
3607 g_free(user2); | |
3608 | |
3609 return ret; | |
3610 } | |
3611 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3612 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3613 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
|
3614 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3615 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3616 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3617 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3618 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3619 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3620 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3621 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3622 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3623 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3624 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3625 /* 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
|
3626 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
|
3627 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3628 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
|
3629 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3630 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3631 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
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 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3634 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3635 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3636 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
|
3637 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3638 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3639 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3640 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3641 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3642 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3643 /* This user is not me, so look into updating the alias. */ |
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 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3646 alias = gaim_buddy_get_contact_alias(buddy2); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3647 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3648 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3649 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3650 -1); |
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 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3653 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3654 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3655 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3656 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3657 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3658 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3659 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3660 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3661 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3662 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3663 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3664 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3665 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
|
3666 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3667 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3668 GaimPluginProtocolInfo *prpl_info; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3669 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3670 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3671 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3672 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3673 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3674 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3675 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3676 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
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 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3679 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3680 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3681 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
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 GaimBlistNode *bnode; |
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 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3686 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3687 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3688 continue; |
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 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3691 } |
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 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3694 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3697 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3698 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
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 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3701 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3702 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3703 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3704 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3705 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3706 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3707 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3708 /* 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
|
3709 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3710 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3711 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3712 /* 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
|
3713 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
|
3714 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3715 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
|
3716 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3717 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3718 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3719 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3720 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3721 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3722 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3723 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
|
3724 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3725 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3726 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
|
3727 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3728 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3729 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3730 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3731 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3732 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3733 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3734 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3735 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3736 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3737 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3738 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3739 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3740 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3741 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3742 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3743 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3744 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3745 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3746 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3747 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3748 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3749 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3750 /* 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
|
3751 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3752 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3753 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3754 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3755 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3756 |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3757 static void send_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3758 { |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3759 g_signal_emit_by_name(gtkconv->entry, "message_send"); |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3760 } |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3761 |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3762 static void |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3763 entry_popup_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3764 { |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3765 GtkWidget *menuitem; |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3766 GaimGtkConversation *gtkconv = data; |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3767 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3768 g_return_if_fail(menu != NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3769 g_return_if_fail(gtkconv != NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3770 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3771 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
|
3772 G_CALLBACK(send_menu_cb), gtkconv, |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3773 0, 0, NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3774 if (gtk_text_buffer_get_char_count(imhtml->text_buffer) == 0) |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3775 gtk_widget_set_sensitive(menuitem, FALSE); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3776 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 0); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3777 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3778 menuitem = gtk_separator_menu_item_new(); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3779 gtk_widget_show(menuitem); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3780 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 1); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3781 } |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3782 |
4359 | 3783 static GtkWidget * |
10810 | 3784 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3785 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3786 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3787 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3788 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3789 GaimConnection *gc; |
4359 | 3790 GtkWidget *vpaned, *hpaned; |
10175 | 3791 GtkWidget *vbox, *hbox, *frame; |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3792 GtkWidget *imhtml_sw; |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3793 GtkPolicyType imhtml_sw_hscroll; |
4359 | 3794 GtkWidget *lbox, *bbox; |
3795 GtkWidget *label; | |
3796 GtkWidget *list; | |
3797 GtkWidget *button; | |
7949 | 3798 GtkWidget *sw; |
4359 | 3799 GtkListStore *ls; |
3800 GtkCellRenderer *rend; | |
3801 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3802 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3803 GList *focus_chain = NULL; |
4359 | 3804 |
3805 gtkchat = gtkconv->u.chat; | |
3806 gc = gaim_conversation_get_gc(conv); | |
3807 | |
3808 /* Setup the outer pane. */ | |
3809 vpaned = gtk_vpaned_new(); | |
3810 gtk_widget_show(vpaned); | |
3811 | |
3812 /* Setup the top part of the pane. */ | |
11243 | 3813 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3814 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3815 gtk_widget_show(vbox); |
3816 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3817 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3818 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3819 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3820 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3821 { |
11243 | 3822 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3823 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3824 gtk_widget_show(hbox); |
3825 | |
3826 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3827 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3828 gtk_widget_show(label); |
3829 | |
3830 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3831 |
7971 | 3832 if(prpl_info->set_chat_topic == NULL) { |
3833 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3834 } else { | |
3835 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3836 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3837 } |
3838 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3839 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3840 gtk_widget_show(gtkchat->topic_text); |
3841 } | |
3842 | |
3843 /* Setup the horizontal pane. */ | |
3844 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3845 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3846 gtk_widget_show(hpaned); |
3847 | |
10175 | 3848 /* Setup gtkihmtml. */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3849 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL, &imhtml_sw); |
10175 | 3850 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); |
10389 | 3851 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3852 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3853 gtk_widget_show(frame); | |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3854 gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3855 &imhtml_sw_hscroll, NULL); |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3856 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3857 imhtml_sw_hscroll, GTK_POLICY_ALWAYS); |
10175 | 3858 |
3859 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3860 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3861 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3862 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3863 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3864 |
4359 | 3865 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3866 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3867 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3868 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3869 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3870 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3871 |
3872 /* Build the right pane. */ | |
11243 | 3873 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3874 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3875 gtk_widget_show(lbox); |
3876 | |
3877 /* Setup the label telling how many people are in the room. */ | |
3878 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3879 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3880 gtk_widget_show(gtkchat->count); | |
3881 | |
3882 /* Setup the list of users. */ | |
7949 | 3883 sw = gtk_scrolled_window_new(NULL, NULL); |
3884 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3885 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3886 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3887 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3888 gtk_widget_show(sw); | |
4359 | 3889 |
9554 | 3890 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
|
3891 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
|
3892 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3893 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3894 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3895 GTK_SORT_ASCENDING); |
3896 | |
3897 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3898 | |
9498 | 3899 rend = gtk_cell_renderer_pixbuf_new(); |
3900 | |
4359 | 3901 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3902 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3903 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3904 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3905 |
3906 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3907 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3908 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3909 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3910 |
9498 | 3911 rend = gtk_cell_renderer_text_new(); |
3912 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3913 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3914 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3915 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3916 NULL); |
4359 | 3917 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3918 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3919 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3920 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3921 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3922 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3923 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3924 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3925 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3926 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3927 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3928 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3929 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3930 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3931 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3932 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3933 #endif |
4359 | 3934 |
3935 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3936 | |
3937 gtk_widget_set_size_request(list, 150, -1); | |
3938 | |
3939 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3940 gtk_widget_show(list); | |
3941 | |
3942 gtkchat->list = list; | |
3943 | |
7949 | 3944 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3945 |
3946 /* Setup the user list toolbar. */ | |
11243 | 3947 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3948 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3949 gtk_widget_show(bbox); | |
3950 | |
3951 /* IM */ | |
10221 | 3952 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3953 GAIM_BUTTON_VERTICAL); |
10500 | 3954 gtkchat->userlist_im = button; |
4359 | 3955 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3956 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
|
3957 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3958 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3959 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3960 |
3961 gtk_widget_show(button); | |
3962 | |
3963 /* Ignore */ | |
3964 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3965 GAIM_BUTTON_VERTICAL); | |
10500 | 3966 gtkchat->userlist_ignore = button; |
4359 | 3967 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3968 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
|
3969 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3970 _("Ignore the user"), NULL); |
4359 | 3971 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3972 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3973 gtk_widget_show(button); |
3974 | |
3975 /* Info */ | |
3976 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3977 GAIM_BUTTON_VERTICAL); | |
10500 | 3978 gtkchat->userlist_info = button; |
4359 | 3979 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3980 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3981 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3982 _("Get the user's information"), NULL); |
4359 | 3983 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3984 G_CALLBACK(info_cb), gtkconv); |
4359 | 3985 |
3986 gtk_widget_show(button); | |
3987 | |
10175 | 3988 /* Setup the bottom half of the conversation window */ |
11243 | 3989 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3990 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3991 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3992 |
11243 | 3993 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3994 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3995 gtk_widget_show(gtkconv->lower_hbox); | |
3996 | |
11243 | 3997 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3998 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3999 gtk_widget_show(vbox); | |
4000 | |
10175 | 4001 /* Setup the toolbar, entry widget and all signals */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4002 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar, NULL); |
10080 | 4003 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 4004 gtk_widget_show(frame); |
4005 | |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4006 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4007 G_CALLBACK(entry_popup_menu_cb), gtkconv); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4008 |
9005 | 4009 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 4010 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 4011 gaim_account_get_protocol_name(conv->account)); |
10175 | 4012 gtk_widget_set_size_request(gtkconv->entry, -1, |
4013 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4014 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4015 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 4016 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 4017 |
4018 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 4019 G_CALLBACK(entry_key_press_cb), gtkconv); |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4020 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4021 G_CALLBACK(send_cb), gtkconv); |
4359 | 4022 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 4023 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 4024 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 4025 G_CALLBACK(size_allocate_cb), gtkconv); |
4026 | |
4027 default_formatize(gtkconv); | |
4359 | 4028 |
9080 | 4029 /* |
4030 * Focus for chat windows should be as follows: | |
4031 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
4032 * user list buttons -> entry -> buttons at bottom | |
4033 */ | |
9332 | 4034 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4035 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
4036 | |
4359 | 4037 return vpaned; |
4038 } | |
4039 | |
4040 static GtkWidget * | |
10810 | 4041 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 4042 { |
10810 | 4043 GaimConversation *conv = gtkconv->active_conv; |
10175 | 4044 GtkWidget *frame; |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4045 GtkWidget *imhtml_sw; |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4046 GtkPolicyType imhtml_sw_hscroll; |
4359 | 4047 GtkWidget *paned; |
10175 | 4048 GtkWidget *vbox; |
4049 GtkWidget *vbox2; | |
9080 | 4050 GList *focus_chain = NULL; |
4359 | 4051 |
10175 | 4052 /* Setup the outer pane */ |
4359 | 4053 paned = gtk_vpaned_new(); |
4054 gtk_widget_show(paned); | |
4055 | |
10175 | 4056 /* Setup the top part of the pane */ |
11243 | 4057 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
4058 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 4059 gtk_widget_show(vbox); |
4060 | |
10175 | 4061 /* Setup the gtkimhtml widget */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4062 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL, &imhtml_sw); |
10175 | 4063 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); |
10389 | 4064 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 4065 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
4066 gtk_widget_show(frame); | |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4067 gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4068 &imhtml_sw_hscroll, NULL); |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4069 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4070 imhtml_sw_hscroll, GTK_POLICY_ALWAYS); |
10175 | 4071 |
4072 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4073 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4074 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 4075 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 4076 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 4077 |
4078 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 4079 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 4080 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 4081 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 4082 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 4083 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 4084 |
10175 | 4085 /* Setup the bottom half of the conversation window */ |
11243 | 4086 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 4087 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4088 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4089 |
11243 | 4090 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 4091 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
4092 gtk_widget_show(gtkconv->lower_hbox); | |
4093 | |
11243 | 4094 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 4095 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
4096 gtk_widget_show(vbox2); | |
8821 | 4097 |
10175 | 4098 /* Setup the toolbar, entry widget and all signals */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4099 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar, NULL); |
10080 | 4100 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 4101 gtk_widget_show(frame); |
4102 | |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4103 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4104 G_CALLBACK(entry_popup_menu_cb), gtkconv); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4105 |
9005 | 4106 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 4107 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 4108 gaim_account_get_protocol_name(conv->account)); |
10175 | 4109 gtk_widget_set_size_request(gtkconv->entry, -1, |
4110 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4111 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4112 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 4113 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
|
4114 |
4359 | 4115 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 4116 G_CALLBACK(entry_key_press_cb), gtkconv); |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4117 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4118 G_CALLBACK(send_cb), gtkconv); |
4359 | 4119 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 4120 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 4121 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 4122 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 4123 |
4124 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 4125 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 4126 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 4127 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 4128 |
8481 | 4129 /* had to move this after the imtoolbar is attached so that the |
4130 * signals get fired to toggle the buttons on the toolbar as well. | |
4131 */ | |
10810 | 4132 default_formatize(gtkconv); |
4359 | 4133 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4134 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4135 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4136 |
8758 | 4137 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 4138 gtkconv->u.im->show_icon = TRUE; |
4359 | 4139 |
9080 | 4140 /* |
4141 * Focus for IM windows should be as follows: | |
10356 | 4142 * Tab title -> conversation scrollback -> entry |
9080 | 4143 */ |
9332 | 4144 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4145 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 4146 |
4359 | 4147 return paned; |
4148 } | |
4149 | |
4150 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4151 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 4152 GtkSelectionData *sd, guint info, guint t, |
4153 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4154 { |
10810 | 4155 GaimConversation *conv = gtkconv->active_conv; |
11581 | 4156 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4157 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4158 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4159 { |
4781 | 4160 GaimBlistNode *n = NULL; |
6695 | 4161 GaimBuddy *b; |
11581 | 4162 GaimGtkConversation *gtkconv = NULL; |
9622 | 4163 |
11812 | 4164 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4165 |
6695 | 4166 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
4167 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
4168 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
4169 b = (GaimBuddy*)n; | |
4170 else | |
4781 | 4171 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4172 |
9622 | 4173 /* |
4174 * If we already have an open conversation with this buddy, then | |
4175 * just move the conv to this window. Otherwise, create a new | |
4176 * conv and add it to this window. | |
4177 */ | |
11338 | 4178 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 4179 if (c != NULL) { |
11581 | 4180 GaimGtkWindow *oldwin; |
4181 gtkconv = GAIM_GTK_CONVERSATION(c); | |
4182 oldwin = gtkconv->win; | |
9622 | 4183 if (oldwin != win) { |
11581 | 4184 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
4185 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 4186 } |
4187 } else { | |
11338 | 4188 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 4189 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 4190 if (gtkconv->win != win) |
4191 { | |
4192 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
4193 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
4194 } | |
9622 | 4195 } |
4196 | |
4197 /* Make this conversation the active conversation */ | |
11581 | 4198 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4199 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4200 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 4201 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4202 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
|
4203 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4204 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4205 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4206 GaimAccount *account; |
11581 | 4207 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4208 |
11137 | 4209 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 4210 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4211 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4212 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4213 { |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
4214 gaim_notify_error(win, NULL, |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4215 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4216 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4217 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4218 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4219 { |
11338 | 4220 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 4221 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 4222 if (gtkconv->win != win) |
4223 { | |
4224 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
4225 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
4226 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4227 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4228 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4229 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4230 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4231 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4232 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4233 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4234 } |
9525 | 4235 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 4236 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 4237 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 4238 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 4239 } |
10145 | 4240 else |
4241 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4242 } |
4359 | 4243 |
4244 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4245 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4246 { |
10145 | 4247 GTK_IMHTML_DND_TARGETS, |
4248 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
4249 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4250 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4251 |
10810 | 4252 static GaimGtkConversation * |
4253 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
4254 { | |
4255 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
4256 GaimContact *c; | |
4257 GaimBlistNode *cn; | |
10935 | 4258 |
10810 | 4259 if (!bud) |
4260 return NULL; | |
10935 | 4261 |
10810 | 4262 if (!(c = gaim_buddy_get_contact(bud))) |
4263 return NULL; | |
10935 | 4264 |
10810 | 4265 cn = (GaimBlistNode *)c; |
4266 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
4267 GaimConversation *conv; | |
11338 | 4268 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 4269 if (conv->ui_data) |
4270 return conv->ui_data; | |
4271 } | |
4272 } | |
10935 | 4273 |
10810 | 4274 return NULL; |
4275 } | |
4276 | |
11855 | 4277 static void |
4278 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
4279 { | |
4280 GList *list; | |
4281 | |
4282 g_return_if_fail(bnode); | |
4283 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
4284 | |
4285 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
4286 { | |
4287 GaimGtkWindow *win = list->data; | |
4288 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4289 | |
4290 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
4291 continue; | |
4292 | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
4293 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_MENU); |
11855 | 4294 } |
4295 } | |
4296 | |
11581 | 4297 /************************************************************************** |
4298 * Conversation UI operations | |
4299 **************************************************************************/ | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4300 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4301 private_gtkconv_new(GaimConversation *conv, gboolean hidden) |
11581 | 4302 { |
4303 GaimGtkConversation *gtkconv; | |
4304 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 4305 GtkWidget *pane = NULL; |
4306 GtkWidget *tab_cont; | |
11581 | 4307 |
4308 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 4309 conv->ui_data = gtkconv; |
4310 if (!g_list_find(gtkconv->convs, conv)) | |
4311 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 4312 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 4313 return; |
4359 | 4314 } |
4315 | |
11581 | 4316 gtkconv = g_new0(GaimGtkConversation, 1); |
4317 conv->ui_data = gtkconv; | |
4318 gtkconv->active_conv = conv; | |
4319 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
4320 | |
4321 /* Setup some initial variables. */ | |
4322 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
4323 gtkconv->tooltips = gtk_tooltips_new(); | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4324 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4325 gtkconv->unseen_count = 0; |
11581 | 4326 |
4327 if (conv_type == GAIM_CONV_TYPE_IM) { | |
4328 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
4329 | |
4330 pane = setup_im_pane(gtkconv); | |
4331 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
4332 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
4333 pane = setup_chat_pane(gtkconv); | |
4334 } | |
4335 | |
12101 | 4336 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
4337 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
4338 | |
11581 | 4339 if (pane == NULL) { |
4340 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
4341 g_free(gtkconv->u.chat); | |
4342 else if (conv_type == GAIM_CONV_TYPE_IM) | |
4343 g_free(gtkconv->u.im); | |
4344 | |
4345 g_free(gtkconv); | |
4346 conv->ui_data = NULL; | |
4347 return; | |
10449 | 4348 } |
11581 | 4349 |
4350 /* Setup drag-and-drop */ | |
4351 gtk_drag_dest_set(pane, | |
4352 GTK_DEST_DEFAULT_MOTION | | |
4353 GTK_DEST_DEFAULT_DROP, | |
4354 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4355 GDK_ACTION_COPY); | |
4356 gtk_drag_dest_set(pane, | |
4357 GTK_DEST_DEFAULT_MOTION | | |
4358 GTK_DEST_DEFAULT_DROP, | |
4359 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4360 GDK_ACTION_COPY); | |
4361 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4362 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4363 GDK_ACTION_COPY); | |
4364 | |
4365 gtk_drag_dest_set(gtkconv->entry, 0, | |
4366 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4367 GDK_ACTION_COPY); | |
4368 | |
4369 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
4370 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4371 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
4372 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4373 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
4374 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4375 | |
4376 /* Setup the container for the tab. */ | |
4377 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
4378 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
4379 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
4380 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
4381 gtk_widget_show(pane); | |
4382 | |
4383 gtkconv->make_sound = TRUE; | |
4384 | |
4385 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
4386 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4387 else |
11581 | 4388 gtk_widget_hide(gtkconv->toolbar); |
4389 | |
12188 | 4390 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), |
4391 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4392 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4393 gaim_account_get_protocol_name(conv->account)); |
11581 | 4394 |
4395 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
4396 G_CALLBACK(gtk_widget_grab_focus), | |
4397 gtkconv->entry); | |
4398 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4399 if (hidden) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4400 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4401 else |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4402 gaim_gtkconv_placement_place(gtkconv); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
4403 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4404 if (nick_colors == NULL) { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4405 nbr_nick_colors = NUM_NICK_COLORS; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4406 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
|
4407 } |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4408 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4409 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4410 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4411 gaim_gtkconv_new_hidden(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4412 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4413 private_gtkconv_new(conv, TRUE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4414 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4415 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4416 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4417 gaim_gtkconv_new(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4418 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4419 private_gtkconv_new(conv, FALSE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4420 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4421 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4422 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4423 received_im_msg_cb(GaimAccount *account, char *sender, char *message, |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4424 GaimConversation *conv, int flags) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4425 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4426 GaimConversationUiOps *ui_ops = gaim_gtk_conversations_get_conv_ui_ops(); |
12719
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4427 if (conv != NULL) |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4428 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4429 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4430 /* create hidden conv if hide_new pref is always */ |
12719
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4431 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
|
4432 { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4433 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4434 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4435 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4436 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4437 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4438 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4439 /* 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
|
4440 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
|
4441 !gaim_status_is_available(gaim_account_get_active_status(account))) |
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4442 { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4443 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4444 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4445 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4446 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4447 } |
11581 | 4448 } |
4449 | |
4359 | 4450 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4451 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4452 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4453 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4454 |
10810 | 4455 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4456 /* Don't destroy ourselves until all our convos are gone */ | |
4457 if (gtkconv->convs) | |
4458 return; | |
11508 | 4459 |
11581 | 4460 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4461 | |
9504 | 4462 /* 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
|
4463 gaim_request_close_with_handle(gtkconv); |
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
4464 gaim_notify_close_with_handle(gtkconv); |
4359 | 4465 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4466 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4467 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4468 |
11338 | 4469 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4470 if (gtkconv->u.im->icon_timer != 0) |
4471 g_source_remove(gtkconv->u.im->icon_timer); | |
4472 | |
4359 | 4473 if (gtkconv->u.im->anim != NULL) |
4793 | 4474 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4475 |
4476 g_free(gtkconv->u.im); | |
11581 | 4477 } 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
|
4478 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4479 g_free(gtkconv->u.chat); |
4480 } | |
4481 | |
4633 | 4482 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4483 | |
4359 | 4484 g_free(gtkconv); |
4485 } | |
4486 | |
4487 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4488 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4489 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4490 time_t mtime) |
4359 | 4491 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4492 GaimGtkConversation *gtkconv; |
4359 | 4493 |
4494 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4495 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4496 |
6982 | 4497 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4498 } |
4499 | |
4500 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4501 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4502 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4503 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4504 GaimGtkConversation *gtkconv; |
4359 | 4505 |
4506 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4507 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4508 |
10398 | 4509 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4510 |
6982 | 4511 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4512 } |
4513 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4514 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4515 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4516 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4517 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4518 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4519 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4520 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4521 char *buddyname; |
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 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4524 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4525 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4526 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4527 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4528 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4529 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4530 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4531 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
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 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4534 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4535 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4536 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4537 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4538 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4539 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4540 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4541 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4542 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4543 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4544 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4545 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4546 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4547 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4548 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4549 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4550 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4551 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4552 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4553 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4554 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4555 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4556 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4557 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4558 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4559 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4560 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4561 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4562 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4563 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4564 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4565 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4566 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4567 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4568 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4569 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4570 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4571 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4572 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4573 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4574 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4575 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4576 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4577 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4578 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4579 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4580 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4581 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4582 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4583 buddytag = gtk_text_buffer_create_tag( |
11096 | 4584 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4585 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4586 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4587 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4588 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4589 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4590 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4591 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4592 |
4359 | 4593 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4594 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4595 const char *message, GaimMessageFlags flags, |
4359 | 4596 time_t mtime) |
4597 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4598 GaimGtkConversation *gtkconv; |
11581 | 4599 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4600 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4601 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4602 GaimPluginProtocolInfo *prpl_info; |
4359 | 4603 int gtk_font_options = 0; |
12553 | 4604 int gtk_font_options_all = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4605 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4606 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4607 int line_count; |
4359 | 4608 char buf2[BUF_LONG]; |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4609 char *mdate; |
4359 | 4610 char color[10]; |
4611 char *str; | |
4612 char *with_font_tag; | |
4896 | 4613 char *sml_attrib = NULL; |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4614 size_t length; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4615 GaimConversationType type; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4616 char *displaying; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4617 gboolean plugin_return; |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4618 struct tm tm = *(localtime(&mtime)); |
4895 | 4619 |
4359 | 4620 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4621 |
12553 | 4622 if(gaim_prefs_get_bool("/gaim/gtk/conversations/use_smooth_scrolling")) |
4623 gtk_font_options_all |= GTK_IMHTML_USE_SMOOTHSCROLLING; | |
4624 | |
11581 | 4625 /* Set the active conversation to the one that just messaged us. */ |
4626 /* TODO: consider not doing this if the account is offline or something */ | |
13352
475214c22abf
[gaim-migrate @ 15724]
Richard Laager <rlaager@wiktel.com>
parents:
13350
diff
changeset
|
4627 if (flags & (GAIM_MESSAGE_SEND | GAIM_MESSAGE_RECV)) |
475214c22abf
[gaim-migrate @ 15724]
Richard Laager <rlaager@wiktel.com>
parents:
13350
diff
changeset
|
4628 gaim_gtkconv_set_active_conversation(conv); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4629 type = gaim_conversation_get_type(conv); |
11581 | 4630 |
4359 | 4631 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4632 account = gaim_conversation_get_account(conv); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4633 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4634 displaying = g_strdup(message); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4635 plugin_return = GPOINTER_TO_INT(gaim_signal_emit_return_1( |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4636 gaim_gtk_conversations_get_handle(), (type == GAIM_CONV_TYPE_IM ? |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4637 "displaying-im-msg" : "displaying-chat-msg"), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
4638 account, name, &displaying, conv, flags)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4639 if (plugin_return) |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4640 { |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4641 g_free(displaying); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4642 return; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4643 } |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4644 message = displaying; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4645 length = strlen(message) + 1; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4646 |
11581 | 4647 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4648 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4649 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4650 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4651 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4652 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4653 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4654 /* 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
|
4655 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4656 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4657 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4658 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4659 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4660 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4661 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4662 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4663 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4664 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4665 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4666 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4667 |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4668 if (type == GAIM_CONV_TYPE_CHAT) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4669 { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4670 /* Create anchor for user */ |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4671 GtkTextIter iter; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4672 char *tmp = g_strconcat("user:", name, NULL); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4673 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4674 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
|
4675 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
|
4676 tmp, &iter, TRUE); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4677 g_free(tmp); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4678 } |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4679 |
8677 | 4680 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
12553 | 4681 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", gtk_font_options_all); |
8677 | 4682 |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4683 mdate = gaim_signal_emit_return_1(gaim_gtk_conversations_get_handle(), |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4684 "conversation-timestamp", |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4685 conv, &tm); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4686 if (mdate == NULL) |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4687 { |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4688 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
|
4689 mdate = g_strdup(gaim_date_format_long(&tm)); |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4690 else |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13090
diff
changeset
|
4691 mdate = g_strdup(gaim_time_format(&tm)); |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4692 } |
4359 | 4693 |
4896 | 4694 if(gc) |
9699 | 4695 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4696 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4697 |
10503 | 4698 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4699 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4700 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4701 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4702 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4703 |
7956 | 4704 /* this is gonna crash one day, I can feel it. */ |
4705 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4706 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4707 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4708 } |
4359 | 4709 |
12553 | 4710 |
10737 | 4711 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4712 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4713 g_snprintf(buf2, sizeof(buf2), |
8690 | 4714 "<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
|
4715 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4716 |
12553 | 4717 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
7440 | 4718 |
8722 | 4719 } else if (flags & GAIM_MESSAGE_ERROR) { |
4720 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4721 "<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
|
4722 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4723 |
12553 | 4724 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
8962 | 4725 |
7431 | 4726 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4727 g_snprintf(buf2, BUF_LONG, |
8690 | 4728 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4729 sml_attrib ? sml_attrib : "", message); |
7440 | 4730 |
12553 | 4731 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
10346 | 4732 } else if (flags & GAIM_MESSAGE_RAW) { |
12553 | 4733 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, gtk_font_options_all); |
10346 | 4734 } else { |
4895 | 4735 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4736 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
|
4737 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4738 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4739 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
|
4740 int tag_end_offset = 0; |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4741 GtkSmileyTree *tree = NULL; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4742 GHashTable *smiley_data = NULL; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4743 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4744 if (flags & GAIM_MESSAGE_SEND) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4745 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4746 /* Temporarily revert to the original smiley-data to avoid showing up |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4747 * custom smileys of the buddy when sending message |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4748 */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4749 tree = GTK_IMHTML(gtkconv->imhtml)->default_smilies; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4750 GTK_IMHTML(gtkconv->imhtml)->default_smilies = |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4751 GTK_IMHTML(gtkconv->entry)->default_smilies; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4752 smiley_data = GTK_IMHTML(gtkconv->imhtml)->smiley_data; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4753 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
|
4754 } |
7440 | 4755 |
6621 | 4756 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4757 str = g_malloc(1024); |
7440 | 4758 |
4359 | 4759 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4760 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4761 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4762 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4763 tag_start_offset += 3; |
4359 | 4764 } |
4765 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4766 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
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 tag_end_offset = 2; |
4359 | 4769 strcpy(color, "#00FF00"); |
4770 } | |
7440 | 4771 } |
4359 | 4772 else { |
10504 | 4773 if (gaim_message_meify(new_message, -1)) { |
4359 | 4774 str = g_malloc(1024); |
7440 | 4775 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4776 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4777 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
|
4778 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4779 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4780 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4781 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4782 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4783 } |
7440 | 4784 |
6621 | 4785 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4786 strcpy(color, HIGHLIGHT_COLOR); |
4359 | 4787 else |
4788 strcpy(color, "#062585"); | |
4789 } | |
4790 else { | |
4791 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4792 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4793 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
|
4794 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4795 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4796 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4797 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4798 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4799 } |
6621 | 4800 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4801 strcpy(color, HIGHLIGHT_COLOR); |
6621 | 4802 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4803 if (flags & GAIM_MESSAGE_COLORIZE) { |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
4804 GdkColor *col = get_nick_color(gtkconv, name); |
10346 | 4805 |
10108 | 4806 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4807 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4808 } else |
7854 | 4809 strcpy(color, RECV_COLOR); |
4359 | 4810 } |
6621 | 4811 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4812 strcpy(color, SEND_COLOR); |
10892 | 4813 else { |
4814 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4815 strcpy(color, "#000000"); | |
4816 } | |
4359 | 4817 } |
4818 } | |
10892 | 4819 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4820 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4821 g_free(alias_escaped); |
11508 | 4822 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4823 /* 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
|
4824 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4825 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4826 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4827 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4828 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4829 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4830 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4831 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4832 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4833 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4834 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4835 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4836 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4837 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4838 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4839 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4840 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4841 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4842 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4843 /* 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
|
4844 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4845 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4846 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4847 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4848 } |
7440 | 4849 |
12553 | 4850 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
|
4851 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4852 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4853 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4854 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4855 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4856 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4857 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4858 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4859 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4860 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4861 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4862 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4863 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4864 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4865 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4866 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4867 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4868 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4869 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4870 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4871 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4872 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4873 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4874 |
4359 | 4875 g_free(str); |
4876 | |
4895 | 4877 if(gc){ |
4896 | 4878 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4879 char *post = "</font>"; |
4880 int pre_len = strlen(pre); | |
4881 int post_len = strlen(post); | |
7440 | 4882 |
4895 | 4883 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4884 |
4895 | 4885 strcpy(with_font_tag, pre); |
4886 memcpy(with_font_tag + pre_len, new_message, length); | |
4887 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4888 |
4895 | 4889 length += pre_len + post_len; |
4890 g_free(pre); | |
4891 } | |
4608 | 4892 else |
4895 | 4893 with_font_tag = g_memdup(new_message, length); |
7440 | 4894 |
8962 | 4895 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
12553 | 4896 with_font_tag, gtk_font_options | gtk_font_options_all); |
7440 | 4897 |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4898 if (flags & GAIM_MESSAGE_SEND) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4899 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4900 /* Restore the smiley-data */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4901 GTK_IMHTML(gtkconv->imhtml)->default_smilies = tree; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4902 GTK_IMHTML(gtkconv->imhtml)->smiley_data = smiley_data; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4903 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4904 |
7440 | 4905 g_free(with_font_tag); |
7447 | 4906 g_free(new_message); |
7440 | 4907 } |
4908 | |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4909 g_free(mdate); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4910 g_free(sml_attrib); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4911 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4912 /* Tab highlighting stuff */ |
13138
277c7a62650b
[gaim-migrate @ 15500]
Richard Laager <rlaager@wiktel.com>
parents:
13131
diff
changeset
|
4913 if (!(flags & GAIM_MESSAGE_SEND) && !gaim_gtkconv_has_focus(conv)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4914 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4915 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4916 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4917 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4918 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4919 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4920 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4921 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4922 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
|
4923 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4924 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4925 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4926 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4927 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4928 } |
12902
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4929 |
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4930 gaim_signal_emit(gaim_gtk_conversations_get_handle(), |
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4931 (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
|
4932 account, name, message, conv, flags); |
12902
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4933 g_free(displaying); |
4359 | 4934 } |
4935 | |
4936 static void | |
12463
b1717befbb26
[gaim-migrate @ 14773]
Richard Laager <rlaager@wiktel.com>
parents:
12455
diff
changeset
|
4937 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
|
4938 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4939 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4940 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4941 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4942 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4943 GList *ll; |
11869 | 4944 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4945 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4946 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4947 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4948 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4949 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4950 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4951 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4952 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
|
4953 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4954 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4955 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4956 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4957 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4958 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4959 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4960 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4961 l = users; |
11869 | 4962 ll = flags; |
4963 lll = aliases; | |
4964 while (l != NULL && ll != NULL && lll != NULL) { | |
4965 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
|
4966 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4967 ll = ll->next; |
11869 | 4968 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4969 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4970 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4971 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4972 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4973 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
|
4974 const char *new_name, const char *new_alias) |
4359 | 4975 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4976 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4977 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4978 GaimGtkChatPane *gtkchat; |
11869 | 4979 GaimConvChatBuddyFlags flags; |
4359 | 4980 GtkTreeIter iter; |
4981 GtkTreeModel *model; | |
4982 int f = 1; | |
4983 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4984 chat = GAIM_CONV_CHAT(conv); |
4359 | 4985 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4986 gtkchat = gtkconv->u.chat; | |
4987 | |
9554 | 4988 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4989 | |
4990 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4991 return; | |
4992 | |
4993 while (f != 0) { | |
4994 char *val; | |
4995 | |
11869 | 4996 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4997 |
4998 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4999 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5000 g_free(val); | |
4359 | 5001 break; |
5002 } | |
9554 | 5003 |
5004 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5005 | |
5006 g_free(val); | |
4359 | 5007 } |
5008 | |
9554 | 5009 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 5010 return; |
5011 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
5012 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
5013 |
11869 | 5014 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 5015 } |
5016 | |
5017 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5018 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5019 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5020 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5021 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5022 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5023 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5024 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5025 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5026 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5027 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5028 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5029 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5030 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5031 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5032 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5033 |
12982 | 5034 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
|
5035 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5036 for (l = users; l != NULL; l = l->next) { |
9554 | 5037 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5038 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
5039 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 5040 continue; |
5041 | |
5042 do { | |
5043 char *val; | |
5044 | |
5045 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
5046 CHAT_USERS_NAME_COLUMN, &val, -1); | |
5047 | |
9696 | 5048 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
5049 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 5050 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 5051 #else |
5052 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5053 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5054 #endif | |
5055 } | |
9554 | 5056 else |
5057 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5058 | |
5059 g_free(val); | |
5060 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5061 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5062 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5063 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5064 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5065 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5066 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5067 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5068 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5069 |
9554 | 5070 static void |
5071 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
5072 { | |
5073 GaimConvChat *chat; | |
11869 | 5074 GaimConvChatBuddyFlags flags; |
9554 | 5075 GaimGtkConversation *gtkconv; |
5076 GaimGtkChatPane *gtkchat; | |
5077 GtkTreeIter iter; | |
5078 GtkTreeModel *model; | |
5079 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5080 char *alias = NULL; |
9554 | 5081 |
5082 chat = GAIM_CONV_CHAT(conv); | |
5083 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5084 gtkchat = gtkconv->u.chat; | |
5085 | |
5086 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
5087 | |
5088 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5089 return; | |
5090 | |
5091 while (f != 0) { | |
5092 char *val; | |
5093 | |
5094 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5095 | |
5096 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
5097 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 5098 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
5099 g_free(val); | |
5100 break; | |
5101 } | |
5102 | |
5103 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5104 | |
5105 g_free(val); | |
5106 } | |
5107 | |
5108 if (!gaim_conv_chat_find_user(chat, user)) | |
12982 | 5109 { |
5110 g_free(alias); | |
9554 | 5111 return; |
12982 | 5112 } |
9554 | 5113 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5114 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5115 |
11869 | 5116 flags = gaim_conv_chat_user_get_flags(chat, user); |
5117 | |
5118 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5119 g_free(alias); |
9554 | 5120 } |
5121 | |
11581 | 5122 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5123 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5124 { |
11581 | 5125 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
5126 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5127 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5128 |
11581 | 5129 win = gtkconv->win; |
5130 | |
5131 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
|
5132 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5133 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5134 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5135 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
5136 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5137 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5138 |
12335 | 5139 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data) |
5140 { | |
5141 GtkIMHtmlSmiley *smiley; | |
12682 | 5142 |
12335 | 5143 smiley = (GtkIMHtmlSmiley *)user_data; |
5144 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
12682 | 5145 |
12335 | 5146 if (smiley->icon) |
5147 g_object_ref(G_OBJECT(smiley->icon)); | |
12682 | 5148 #ifdef DEBUG_CUSTOM_SMILEY |
5149 gaim_debug_info("custom-smiley", "gaim_gtkconv_custom_smiley_allocated(): got GdkPixbufAnimation %p for smiley '%s'\n", smiley->icon, smiley->smile); | |
12335 | 5150 #endif |
5151 } | |
5152 | |
5153 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data) | |
5154 { | |
5155 GtkIMHtmlSmiley *smiley; | |
5156 GtkWidget *icon = NULL; | |
5157 GtkTextChildAnchor *anchor = NULL; | |
5158 GSList *current = NULL; | |
12682 | 5159 |
12335 | 5160 smiley = (GtkIMHtmlSmiley *)user_data; |
5161 if (!smiley->imhtml) { | |
5162 #ifdef DEBUG_CUSTOM_SMILEY | |
12682 | 5163 gaim_debug_error("custom-smiley", "gaim_gtkconv_custom_smiley_closed(): orphan smiley found: %p\n", smiley); |
12335 | 5164 #endif |
5165 g_object_unref(G_OBJECT(loader)); | |
5166 smiley->loader = NULL; | |
5167 return; | |
5168 } | |
5169 | |
5170 for (current = smiley->anchors; current; current = g_slist_next(current)) { | |
5171 | |
5172 icon = gtk_image_new_from_animation(smiley->icon); | |
5173 | |
12682 | 5174 #ifdef DEBUG_CUSTOM_SMILEY |
5175 gaim_debug_info("custom-smiley", "gaim_gtkconv_custom_smiley_closed(): got GtkImage %p from GtkPixbufAnimation %p for smiley '%s'\n", | |
5176 icon, smiley->icon, smiley->smile); | |
12335 | 5177 #endif |
5178 if (icon) { | |
5179 gtk_widget_show(icon); | |
12682 | 5180 |
12335 | 5181 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
5182 | |
5183 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smiley->smile)), g_free); | |
5184 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley->smile), g_free); | |
12682 | 5185 |
12335 | 5186 if (smiley->imhtml) |
5187 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(smiley->imhtml), icon, anchor); | |
5188 } | |
5189 | |
5190 } | |
5191 | |
5192 g_slist_free(smiley->anchors); | |
5193 smiley->anchors = NULL; | |
12682 | 5194 |
12335 | 5195 g_object_unref(G_OBJECT(loader)); |
5196 smiley->loader = NULL; | |
5197 } | |
5198 | |
10526 | 5199 static gboolean |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5200 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
|
5201 { |
10526 | 5202 GtkIMHtmlSmiley *smiley; |
5203 GdkPixbufLoader *loader; | |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5204 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5205 smiley = gtk_imhtml_smiley_get(imhtml, sml, smile); |
10526 | 5206 |
5207 if (smiley) { | |
11525 | 5208 |
5209 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
5210 return FALSE; | |
5211 } | |
5212 | |
5213 /* Close the old GdkPixbufAnimation, then create a new one for | |
5214 * the smiley we are about to receive */ | |
5215 g_object_unref(G_OBJECT(smiley->icon)); | |
5216 | |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5217 /* XXX: Is it necessary to _unref the loader first? */ |
11525 | 5218 smiley->loader = gdk_pixbuf_loader_new(); |
12335 | 5219 smiley->icon = NULL; |
5220 | |
5221 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); | |
5222 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
5223 | |
11525 | 5224 return TRUE; |
10526 | 5225 } |
5226 | |
5227 loader = gdk_pixbuf_loader_new(); | |
5228 | |
5229 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
5230 /* 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
|
5231 GtkIMHtmlSmiley by opaque */ |
10526 | 5232 smiley = g_new0(GtkIMHtmlSmiley, 1); |
5233 smiley->file = NULL; | |
5234 smiley->smile = g_strdup(smile); | |
5235 smiley->loader = loader; | |
11525 | 5236 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 5237 |
12335 | 5238 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); |
5239 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
11525 | 5240 |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5241 gtk_imhtml_associate_smiley(imhtml, sml, smiley); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5242 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5243 return TRUE; |
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 static gboolean |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5247 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
|
5248 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5249 GaimGtkConversation *gtkconv; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5250 struct smiley_list *list; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5251 const char *sml = NULL, *conv_sml; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5252 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5253 if (!conv || !smile || !*smile) { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5254 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5255 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5256 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5257 /* If smileys are off, return false */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5258 if (gaim_gtkthemes_smileys_disabled()) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5259 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5260 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5261 /* If possible add this smiley to the current theme. |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5262 * 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
|
5263 conv_sml = gaim_account_get_protocol_name(conv->account); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5264 gtkconv = GAIM_GTK_CONVERSATION(conv); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5265 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5266 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
|
5267 if (!strcmp(list->sml, conv_sml)) { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5268 sml = list->sml; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5269 break; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5270 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5271 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5272 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5273 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
|
5274 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5275 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5276 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
|
5277 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
|
5278 return FALSE; |
10537 | 5279 |
10526 | 5280 return TRUE; |
5281 } | |
5282 | |
10537 | 5283 static void |
10526 | 5284 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 5285 const guchar *data, gsize size) |
10526 | 5286 { |
5287 GaimGtkConversation *gtkconv; | |
5288 GtkIMHtmlSmiley *smiley; | |
10537 | 5289 GdkPixbufLoader *loader; |
10526 | 5290 const char *sml; |
5291 | |
5292 sml = gaim_account_get_protocol_name(conv->account); | |
5293 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5294 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5295 | |
10537 | 5296 if (!smiley) |
10526 | 5297 return; |
10537 | 5298 |
10526 | 5299 loader = smiley->loader; |
10537 | 5300 if (!loader) |
10526 | 5301 return; |
5302 | |
5303 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
5304 } | |
5305 | |
5306 static void | |
5307 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
5308 { | |
5309 GaimGtkConversation *gtkconv; | |
5310 GtkIMHtmlSmiley *smiley; | |
5311 GdkPixbufLoader *loader; | |
5312 const char *sml; | |
5313 | |
5314 g_return_if_fail(conv != NULL); | |
5315 g_return_if_fail(smile != NULL); | |
5316 | |
5317 sml = gaim_account_get_protocol_name(conv->account); | |
5318 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5319 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5320 | |
10537 | 5321 if (!smiley) |
10526 | 5322 return; |
5323 | |
5324 loader = smiley->loader; | |
5325 | |
10537 | 5326 if (!loader) |
10526 | 5327 return; |
10537 | 5328 |
12335 | 5329 |
11525 | 5330 |
10526 | 5331 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
5332 | |
5333 gdk_pixbuf_loader_close(loader, NULL); | |
12335 | 5334 |
10526 | 5335 } |
5336 | |
11581 | 5337 /* |
5338 * Makes sure all the menu items and all the buttons are hidden/shown and | |
5339 * sensitive/insensitive. This is called after changing tabs and when an | |
5340 * account signs on or off. | |
5341 */ | |
5342 static void | |
5343 gray_stuff_out(GaimGtkConversation *gtkconv) | |
5344 { | |
5345 GaimGtkWindow *win; | |
5346 GaimConversation *conv = gtkconv->active_conv; | |
5347 GaimConnection *gc; | |
5348 GaimPluginProtocolInfo *prpl_info = NULL; | |
5349 GdkPixbuf *window_icon = NULL; | |
5350 GtkIMHtmlButtons buttons; | |
5351 GaimAccount *account; | |
5352 | |
5353 win = gaim_gtkconv_get_window(gtkconv); | |
5354 gc = gaim_conversation_get_gc(conv); | |
5355 account = gaim_conversation_get_account(conv); | |
5356 | |
5357 if (gc != NULL) | |
5358 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
5359 | |
11594 | 5360 if (win->menu.send_to != NULL) |
11734 | 5361 update_send_to_selection(win); |
11581 | 5362 |
5363 /* | |
5364 * Handle hiding and showing stuff based on what type of conv this is. | |
5365 * Stuff that Gaim IMs support in general should be shown for IM | |
5366 * conversations. Stuff that Gaim chats support in general should be | |
5367 * shown for chat conversations. It doesn't matter whether the PRPL | |
5368 * supports it or not--that only affects if the button or menu item | |
5369 * is sensitive or not. | |
5370 */ | |
5371 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
5372 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
5373 | |
5374 /* Deal with menu items */ | |
5375 gtk_widget_show(win->menu.view_log); | |
5376 gtk_widget_show(win->menu.send_file); | |
5377 gtk_widget_show(win->menu.add_pounce); | |
5378 gtk_widget_show(win->menu.get_info); | |
5379 gtk_widget_hide(win->menu.invite); | |
5380 gtk_widget_show(win->menu.alias); | |
5381 gtk_widget_show(win->menu.block); | |
5382 | |
13131 | 5383 if ((account == NULL) || gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { |
11581 | 5384 gtk_widget_show(win->menu.add); |
5385 gtk_widget_hide(win->menu.remove); | |
5386 } else { | |
5387 gtk_widget_show(win->menu.remove); | |
5388 gtk_widget_hide(win->menu.add); | |
5389 } | |
5390 | |
5391 gtk_widget_show(win->menu.insert_link); | |
5392 gtk_widget_show(win->menu.insert_image); | |
5393 gtk_widget_show(win->menu.show_icon); | |
5394 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
5395 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
5396 | |
5397 /* Deal with menu items */ | |
5398 gtk_widget_show(win->menu.view_log); | |
5399 gtk_widget_hide(win->menu.send_file); | |
5400 gtk_widget_hide(win->menu.add_pounce); | |
5401 gtk_widget_hide(win->menu.get_info); | |
5402 gtk_widget_show(win->menu.invite); | |
5403 gtk_widget_show(win->menu.alias); | |
5404 gtk_widget_hide(win->menu.block); | |
5405 gtk_widget_hide(win->menu.show_icon); | |
5406 | |
13131 | 5407 if ((account == NULL) || gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { |
11581 | 5408 /* If the chat is NOT in the buddy list */ |
5409 gtk_widget_show(win->menu.add); | |
5410 gtk_widget_hide(win->menu.remove); | |
5411 } else { | |
5412 /* If the chat IS in the buddy list */ | |
5413 gtk_widget_hide(win->menu.add); | |
5414 gtk_widget_show(win->menu.remove); | |
5415 } | |
5416 | |
5417 gtk_widget_show(win->menu.insert_link); | |
5418 gtk_widget_hide(win->menu.insert_image); | |
5419 } | |
5420 | |
5421 /* | |
5422 * Handle graying stuff out based on whether an account is connected | |
5423 * and what features that account supports. | |
5424 */ | |
5425 if ((gc != NULL) && | |
12012 | 5426 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
5427 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
5428 { | |
11581 | 5429 /* Account is online */ |
5430 /* Deal with the toolbar */ | |
12012 | 5431 if (conv->features & GAIM_CONNECTION_HTML) |
5432 { | |
5433 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
5434 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
5435 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
5436 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
5437 { | |
5438 buttons &= ~GTK_IMHTML_GROW; | |
5439 buttons &= ~GTK_IMHTML_SHRINK; | |
5440 } | |
5441 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
5442 buttons &= ~GTK_IMHTML_LINKDESC; | |
5443 } else { | |
12216 | 5444 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
12012 | 5445 } |
12216 | 5446 |
5447 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
5448 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
5449 buttons &= ~GTK_IMHTML_IMAGE; | |
5450 | |
12012 | 5451 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); |
13131 | 5452 if (account != NULL) |
5453 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 5454 |
5455 /* Deal with menu items */ | |
12012 | 5456 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5457 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5458 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
5459 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
5460 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
5461 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 5462 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 5463 |
5464 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
5465 { | |
5466 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
5467 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
5468 gtk_widget_set_sensitive(win->menu.send_file, | |
5469 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
5470 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
5471 gtk_widget_set_sensitive(win->menu.alias, | |
13131 | 5472 (account != NULL) && |
12012 | 5473 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); |
5474 } | |
5475 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5476 { | |
5477 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
5478 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
5479 gtk_widget_set_sensitive(win->menu.alias, | |
13131 | 5480 (account != NULL) && |
12012 | 5481 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); |
5482 } | |
11581 | 5483 |
5484 /* Deal with chat userlist buttons */ | |
12012 | 5485 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5486 { | |
5487 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
5488 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
5489 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
5490 } | |
5491 } else { | |
11581 | 5492 /* Account is offline */ |
5493 /* Or it's a chat that we've left. */ | |
5494 | |
5495 /* Then deal with menu items */ | |
12012 | 5496 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5497 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
5498 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5499 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
5500 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
5501 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
5502 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
5503 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
5504 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
5505 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
5506 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 5507 |
5508 /* Deal with chat userlist buttons */ | |
12012 | 5509 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5510 { | |
5511 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5512 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5513 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5514 } | |
5515 } | |
11581 | 5516 |
5517 /* | |
5518 * Update the window's icon | |
5519 */ | |
12171 | 5520 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5521 { |
12171 | 5522 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
5523 (gtkconv->u.im->anim)) | |
5524 { | |
5525 window_icon = | |
5526 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5527 g_object_ref(window_icon); | |
5528 } else { | |
5529 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5530 } | |
5531 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5532 if (window_icon != NULL) | |
5533 g_object_unref(G_OBJECT(window_icon)); | |
5534 } | |
11581 | 5535 } |
5536 | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5537 static void |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5538 gaim_gtkconv_update_fields(GaimConversation *conv, GaimGtkConvFields fields) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5539 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5540 GaimGtkConversation *gtkconv; |
11581 | 5541 GaimGtkWindow *win; |
10116 | 5542 |
4359 | 5543 gtkconv = GAIM_GTK_CONVERSATION(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5544 if (!gtkconv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5545 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5546 win = gaim_gtkconv_get_window(gtkconv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5547 if (!win) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5548 return; |
13090 | 5549 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5550 if (fields & GAIM_GTKCONV_SET_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5551 { |
4359 | 5552 gaim_conversation_autoset_title(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5553 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5554 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5555 if (fields & GAIM_GTKCONV_BUDDY_ICON) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5556 { |
11338 | 5557 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5558 gaim_gtkconv_update_buddy_icon(conv); |
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_MENU) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5562 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5563 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5564 generate_send_to_items(win); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5565 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5566 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5567 if (fields & GAIM_GTKCONV_TAB_ICON) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5568 { |
6395 | 5569 update_tab_icon(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5570 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
|
5571 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5572 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5573 if ((fields & GAIM_GTKCONV_TOPIC) && |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5574 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5575 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5576 const char *topic; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5577 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5578 GaimGtkChatPane *gtkchat = gtkconv->u.chat; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5579 |
13350
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5580 if (gtkchat->topic_text != NULL) |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5581 { |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5582 topic = gaim_conv_chat_get_topic(chat); |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5583 |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5584 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5585 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5586 topic ? topic : "", NULL); |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5587 } |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5588 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5589 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5590 if (fields & GAIM_GTKCONV_SMILEY_THEME) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5591 gaim_gtkthemes_smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5592 |
13131 | 5593 if ((fields & GAIM_GTKCONV_COLORIZE_TITLE) || |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5594 (fields & GAIM_GTKCONV_SET_TITLE)) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5595 { |
9472 | 5596 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5597 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5598 GaimAccount *account = gaim_conversation_get_account(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5599 /* 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
|
5600 char style[51]; |
4736 | 5601 |
11338 | 5602 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5603 im = GAIM_CONV_IM(conv); |
4359 | 5604 |
13131 | 5605 if ((account == NULL) || |
5606 !gaim_account_is_connected(account) || | |
5607 ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5608 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) | |
9472 | 5609 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); |
5610 else | |
5611 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5612 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5613 *style = '\0'; |
4359 | 5614 |
5615 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5616 gtk_widget_realize(gtkconv->tab_label); | |
5617 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5618 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5619 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5620 { |
11759 | 5621 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5622 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5623 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5624 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5625 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5626 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5627 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5628 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5629 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5630 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5631 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5632 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5633 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5634 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5635 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5636 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5637 { |
11758 | 5638 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5639 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5640 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5641 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5642 { |
8536 | 5643 char *html_title,*label; |
5644 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5645 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5646 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5647 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5648 style, html_title); |
8536 | 5649 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5650 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5651 g_free(label); |
4359 | 5652 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5653 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5654 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5655 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5656 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5657 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5658 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5659 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5660 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5661 gtk_window_set_title(GTK_WINDOW(win->window), title); |
9472 | 5662 |
5663 g_free(title); | |
4359 | 5664 } |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5665 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5666 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5667 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5668 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5669 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5670 GaimGtkConvFields flags = 0; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5671 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5672 g_return_if_fail(conv != NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5673 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5674 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5675 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5676 flags = GAIM_GTKCONV_ALL; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5677 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5678 else if (type == GAIM_CONV_UPDATE_TYPING || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5679 type == GAIM_CONV_UPDATE_UNSEEN || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5680 type == GAIM_CONV_UPDATE_TITLE) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5681 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5682 flags = GAIM_GTKCONV_COLORIZE_TITLE; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5683 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5684 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5685 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5686 flags = GAIM_GTKCONV_TOPIC; |
4359 | 5687 } |
5688 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5689 type == GAIM_CONV_ACCOUNT_OFFLINE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5690 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5691 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
|
5692 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5693 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5694 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5695 flags = GAIM_GTKCONV_TAB_ICON; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5696 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5697 else if (type == GAIM_CONV_UPDATE_ADD || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5698 type == GAIM_CONV_UPDATE_REMOVE || |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5699 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5700 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5701 flags = GAIM_GTKCONV_SET_TITLE | GAIM_GTKCONV_MENU; |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5702 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5703 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5704 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5705 flags = GAIM_GTKCONV_BUDDY_ICON; |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5706 } |
10665 | 5707 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5708 { | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5709 flags = GAIM_GTKCONV_MENU; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5710 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5711 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5712 gaim_gtkconv_update_fields(conv, flags); |
4359 | 5713 } |
5714 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5715 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5716 { |
11581 | 5717 gaim_gtkconv_new, |
4359 | 5718 gaim_gtkconv_destroy, /* destroy_conversation */ |
5719 gaim_gtkconv_write_chat, /* write_chat */ | |
5720 gaim_gtkconv_write_im, /* write_im */ | |
5721 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5722 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5723 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5724 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5725 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12618
diff
changeset
|
5726 gaim_gtkconv_present_conversation, /* present */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5727 gaim_gtkconv_has_focus, /* has_focus */ |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12618
diff
changeset
|
5728 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
10526 | 5729 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5730 gaim_gtkconv_custom_smiley_close /* custom_smiley_close */ |
4359 | 5731 }; |
5732 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5733 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5734 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5735 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5736 return &conversation_ui_ops; |
4359 | 5737 } |
5738 | |
5739 /************************************************************************** | |
5740 * Public conversation utility functions | |
5741 **************************************************************************/ | |
5742 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5743 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5744 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5745 GaimGtkConversation *gtkconv; |
11581 | 5746 GaimGtkWindow *win; |
4359 | 5747 |
10381 | 5748 GdkPixbufLoader *loader; |
5749 GdkPixbufAnimation *anim; | |
4359 | 5750 GError *err = NULL; |
5751 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5752 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5753 size_t len; |
4359 | 5754 |
5755 GdkPixbuf *buf; | |
5756 | |
5757 GtkWidget *event; | |
5758 GtkWidget *frame; | |
5759 GdkPixbuf *scale; | |
5760 GdkPixmap *pm; | |
5761 GdkBitmap *bm; | |
9318 | 5762 int scale_width, scale_height; |
5763 | |
5764 GaimAccount *account; | |
5765 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5766 |
9324 | 5767 GaimBuddyIcon *icon; |
5768 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5769 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5770 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5771 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5772 |
5773 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5774 win = gtkconv->win; |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5775 if (conv != gtkconv->active_conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5776 return; |
10175 | 5777 |
9687 | 5778 if (!gtkconv->u.im->show_icon) |
5779 return; | |
5780 | |
9318 | 5781 account = gaim_conversation_get_account(conv); |
5782 if(account && account->gc) | |
5783 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5784 |
9845 | 5785 /* Remove the current icon stuff */ |
9885 | 5786 if (gtkconv->u.im->icon_container != NULL) |
5787 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5788 gtkconv->u.im->icon_container = NULL; | |
9845 | 5789 |
5790 if (gtkconv->u.im->anim != NULL) | |
5791 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5792 | |
9887 | 5793 gtkconv->u.im->anim = NULL; |
5794 | |
9845 | 5795 if (gtkconv->u.im->icon_timer != 0) |
5796 g_source_remove(gtkconv->u.im->icon_timer); | |
5797 | |
5798 gtkconv->u.im->icon_timer = 0; | |
5799 | |
5800 if (gtkconv->u.im->iter != NULL) | |
5801 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5802 |
10116 | 5803 gtkconv->u.im->iter = NULL; |
5804 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5805 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5806 return; |
5807 | |
5808 if (gaim_conversation_get_gc(conv) == NULL) | |
5809 return; | |
5810 | |
9324 | 5811 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5812 | |
5813 if (icon == NULL) | |
5814 return; | |
5815 | |
5816 data = gaim_buddy_icon_get_data(icon, &len); | |
5817 | |
10381 | 5818 loader = gdk_pixbuf_loader_new(); |
5819 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
12601
e63fb8e9f4ac
[gaim-migrate @ 14935]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
5820 gdk_pixbuf_loader_close(loader, &err); |
10381 | 5821 anim = gdk_pixbuf_loader_get_animation(loader); |
5822 if (anim) | |
5823 g_object_ref(G_OBJECT(anim)); | |
5824 g_object_unref(loader); | |
5825 | |
5826 if (!anim) | |
9324 | 5827 return; |
10381 | 5828 gtkconv->u.im->anim = anim; |
9324 | 5829 |
4359 | 5830 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5831 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5832 "Buddy icon error: %s\n", err->message); |
4359 | 5833 g_error_free(err); |
5834 } | |
5835 | |
5836 if (!gtkconv->u.im->anim) | |
5837 return; | |
5838 | |
5839 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5840 gtkconv->u.im->iter = NULL; | |
5841 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5842 } else { | |
5843 gtkconv->u.im->iter = | |
8496 | 5844 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5845 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5846 if (gtkconv->u.im->animate) |
10810 | 5847 start_anim(NULL, gtkconv); |
4359 | 5848 } |
5849 | |
10483 | 5850 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5851 NULL, &scale_width, &scale_height); |
4359 | 5852 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5853 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5854 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5855 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5856 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5857 GDK_INTERP_BILINEAR); |
4359 | 5858 |
5859 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5860 g_object_unref(G_OBJECT(scale)); |
4359 | 5861 |
9885 | 5862 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5863 |
4359 | 5864 frame = gtk_frame_new(NULL); |
5865 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5866 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5867 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5868 FALSE, FALSE, 0); | |
8821 | 5869 |
4359 | 5870 event = gtk_event_box_new(); |
5871 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5872 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5873 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5874 gtk_widget_show(event); |
5875 | |
4635 | 5876 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5877 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5878 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5879 gtk_widget_show(gtkconv->u.im->icon); | |
5880 | |
4793 | 5881 g_object_unref(G_OBJECT(pm)); |
4359 | 5882 |
5883 if (bm) | |
4793 | 5884 g_object_unref(G_OBJECT(bm)); |
7143 | 5885 |
10356 | 5886 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5887 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5888 |
9885 | 5889 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5890 gtk_widget_show(frame); |
5891 | |
7143 | 5892 /* The buddy icon code needs badly to be fixed. */ |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5893 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
5894 { |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
5895 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); |
11581 | 5896 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
5897 } |
4359 | 5898 } |
5899 | |
5900 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5901 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5902 { |
11581 | 5903 GaimGtkWindow *win; |
4359 | 5904 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5905 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5906 return; |
5907 | |
11581 | 5908 win = GAIM_GTK_CONVERSATION(conv)->win; |
5909 | |
5910 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5911 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5912 } |
5913 | |
5914 int | |
11614 | 5915 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5916 { |
4359 | 5917 gint nb_x, nb_y, x_rel, y_rel; |
5918 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5919 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5920 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5921 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5922 gboolean horiz; |
4359 | 5923 |
11614 | 5924 if (to_right) |
5925 *to_right = FALSE; | |
5926 | |
11581 | 5927 notebook = GTK_NOTEBOOK(win->notebook); |
5928 | |
5929 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5930 x_rel = x - nb_x; |
5931 y_rel = y - nb_y; | |
5932 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5933 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5934 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5935 |
11780 | 5936 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5937 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5938 #else |
5939 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5940 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5941 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5942 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5943 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5944 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5945 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5946 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5947 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5948 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5949 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5950 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
|
5951 page_num = i; |
11614 | 5952 |
5953 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5954 *to_right = TRUE; | |
5955 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5956 break; |
4359 | 5957 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5958 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5959 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5960 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
|
5961 page_num = i; |
11614 | 5962 |
5963 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5964 *to_right = TRUE; | |
5965 | |
4359 | 5966 break; |
5967 } | |
5968 } | |
5969 } | |
5970 | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5971 if (page_num == -1) { |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5972 /* Add after the last tab */ |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5973 page_num = count - 1; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5974 } |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
5975 |
4359 | 5976 return page_num; |
5977 } | |
5978 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5979 static void |
12816 | 5980 close_on_tabs_pref_cb(const char *name, GaimPrefType type, |
5981 gconstpointer value, gpointer data) | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5982 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5983 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5984 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5985 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5986 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5987 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5988 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5989 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5990 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5991 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5992 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5993 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5994 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5995 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5996 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5997 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5998 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5999 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6000 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6001 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6002 static void |
12816 | 6003 spellcheck_pref_cb(const char *name, GaimPrefType type, |
6004 gconstpointer value, gpointer data) | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6005 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6006 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6007 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6008 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6009 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6010 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6011 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6012 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
6013 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6014 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6015 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6016 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6017 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6018 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6019 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6020 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6021 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6022 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6023 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6024 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6025 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6026 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6027 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6028 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6029 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6030 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6031 static void |
12816 | 6032 tab_side_pref_cb(const char *name, GaimPrefType type, |
6033 gconstpointer value, gpointer data) | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6034 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6035 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6036 GtkPositionType pos; |
11581 | 6037 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6038 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6039 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6040 |
11581 | 6041 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
6042 win = l->data; | |
6043 | |
11619 | 6044 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
|
6045 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6046 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6047 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6048 static void |
12188 | 6049 show_timestamps_pref_cb(const char *name, GaimPrefType type, |
12816 | 6050 gconstpointer value, gpointer data) |
12188 | 6051 { |
6052 GList *l; | |
6053 GaimConversation *conv; | |
6054 GaimGtkConversation *gtkconv; | |
6055 GaimGtkWindow *win; | |
6056 | |
6057 for (l = gaim_get_conversations(); l != NULL; l = l->next) | |
6058 { | |
6059 conv = (GaimConversation *)l->data; | |
6060 | |
6061 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
6062 continue; | |
6063 | |
6064 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6065 win = gtkconv->win; | |
6066 | |
6067 gtk_check_menu_item_set_active( | |
6068 GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
6069 (gboolean)GPOINTER_TO_INT(value)); | |
6070 | |
6071 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
6072 (gboolean)GPOINTER_TO_INT(value)); | |
6073 } | |
6074 } | |
6075 | |
6076 static void | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6077 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
12816 | 6078 gconstpointer value, gpointer data) |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6079 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6080 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6081 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6082 GaimGtkConversation *gtkconv; |
11581 | 6083 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6084 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6085 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6086 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6087 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6088 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6089 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6090 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6091 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6092 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 6093 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6094 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6095 gtk_check_menu_item_set_active( |
11581 | 6096 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
6097 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 6098 |
6099 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 6100 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6101 else |
8317 | 6102 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6103 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6104 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6105 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6106 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6107 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
12816 | 6108 gconstpointer value, gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6109 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6110 GList *l; |
8189 | 6111 GaimConversation *conv; |
6112 GaimGtkConversation *gtkconv; | |
11581 | 6113 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6114 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6115 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
|
6116 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6117 |
8189 | 6118 /* Set the "animate" flag for each icon based on the new preference */ |
6119 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
6120 conv = (GaimConversation *)l->data; | |
6121 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 6122 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6123 } |
8189 | 6124 |
6125 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 6126 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
6127 win = l->data; | |
6128 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 6129 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6130 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6131 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6132 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6133 static void |
12816 | 6134 show_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
6135 gconstpointer value, gpointer data) | |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6136 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6137 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6138 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6139 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6140 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6141 |
11338 | 6142 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 6143 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6144 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6145 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6146 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
6147 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6148 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
12816 | 6149 gconstpointer value, gpointer data) |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6150 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6151 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6152 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6153 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6154 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6155 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6156 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6157 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6158 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6159 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6160 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6161 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6162 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
|
6163 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6164 |
12310 | 6165 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
|
6166 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6167 |
13139
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6168 while ((l = hidden_convwin->gtkconvs) != NULL) |
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6169 { |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6170 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6171 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6172 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6173 |
12310 | 6174 if(!gaim_status_is_available( |
6175 gaim_account_get_active_status( | |
6176 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6177 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6178 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6179 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6180 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6181 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6182 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6183 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6184 static void |
12816 | 6185 hide_new_pref_cb(const char *name, GaimPrefType type, |
6186 gconstpointer value, gpointer data) | |
12116
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 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6189 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6190 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6191 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6192 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6193 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6194 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6195 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6196 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
|
6197 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6198 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6199 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
|
6200 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6201 |
13139
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6202 while ((l = hidden_convwin->gtkconvs) != NULL) |
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6203 { |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6204 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6205 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6206 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6207 |
12310 | 6208 if(when_away && !gaim_status_is_available( |
6209 gaim_account_get_active_status( | |
6210 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6211 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6212 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6213 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6214 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6215 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6216 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6217 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6218 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6219 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6220 conv_placement_pref_cb(const char *name, GaimPrefType type, |
12816 | 6221 gconstpointer value, gpointer data) |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6222 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6223 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6224 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6225 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6226 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6227 |
11581 | 6228 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6229 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6230 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6231 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6232 |
11581 | 6233 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6234 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6235 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6236 static GaimGtkConversation * |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6237 get_gtkconv_with_contact(GaimContact *contact) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6238 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6239 GaimBlistNode *node; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6240 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6241 node = ((GaimBlistNode*)contact)->child; |
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 for (; node; node = node->next) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6244 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6245 GaimBuddy *buddy = (GaimBuddy*)node; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6246 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6247 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
|
6248 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6249 return GAIM_GTK_CONVERSATION(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6250 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6251 return NULL; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6252 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6253 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6254 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6255 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6256 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6257 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6258 GaimAccount *account; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6259 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6260 account = gaim_connection_get_account(gc); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6261 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6262 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6263 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6264 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6265 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6266 /* 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
|
6267 * case of this account matching one of the other buddies in |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6268 * one of the contacts containing the buddy corresponding to |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6269 * a conversation. It's easier to just update them all. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6270 /* if (gaim_conversation_get_account(conv) == account) */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6271 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON | |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6272 GAIM_GTKCONV_MENU | GAIM_GTKCONV_COLORIZE_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6273 } |
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 gboolean |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6277 update_buddy_status_timeout(GaimBuddy *buddy) |
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 /* To remove the signing-on/off door icon */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6280 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6281 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6282 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
|
6283 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6284 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); |
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 return FALSE; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6287 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6288 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6289 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6290 update_buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *newstatus) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6291 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6292 GaimGtkConversation *gtkconv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6293 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6294 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6295 gtkconv = get_gtkconv_with_contact(gaim_buddy_get_contact(buddy)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6296 if (gtkconv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6297 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6298 conv = gtkconv->active_conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6299 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
|
6300 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
|
6301 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_MENU); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6302 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6303 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6304 /* 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
|
6305 g_timeout_add(11000, (GSourceFunc)update_buddy_status_timeout, buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6306 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6307 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6308 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6309 update_buddy_idle_changed(GaimBuddy *buddy, gboolean old, gboolean newidle) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6310 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6311 GaimConversation *conv; |
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 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
|
6314 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6315 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); |
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 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6318 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6319 update_buddy_icon(GaimBuddy *buddy) |
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 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6322 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6323 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
|
6324 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6325 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_BUDDY_ICON); |
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 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6328 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6329 update_buddy_sign(GaimBuddy *buddy, const char *which) |
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 GaimPresence *presence; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6332 GaimStatus *on, *off; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6333 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6334 presence = gaim_buddy_get_presence(buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6335 if (!presence) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6336 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6337 off = gaim_presence_get_status(presence, "offline"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6338 on = gaim_presence_get_status(presence, "available"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6339 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6340 if (*(which+1) == 'f') |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6341 update_buddy_status_changed(buddy, on, off); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6342 else |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6343 update_buddy_status_changed(buddy, off, on); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6344 } |
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 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6347 update_conversation_switched(GaimConversation *conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6348 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6349 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
|
6350 GAIM_GTKCONV_MENU | GAIM_GTKCONV_BUDDY_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6351 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6352 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6353 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6354 update_buddy_typing(GaimAccount *account, const char *who) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6355 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6356 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6357 GaimGtkConversation *gtkconv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6358 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6359 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
|
6360 if (!conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6361 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6362 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6363 gtkconv = GAIM_GTK_CONVERSATION(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6364 if (gtkconv && gtkconv->active_conv == conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6365 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_COLORIZE_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6366 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6367 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6368 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6369 update_chat(GaimConversation *conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6370 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6371 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TOPIC | |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6372 GAIM_GTKCONV_MENU | GAIM_GTKCONV_SET_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6373 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6374 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6375 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6376 update_chat_topic(GaimConversation *conv, const char *old, const char *new) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6377 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6378 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TOPIC); |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6379 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6380 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6381 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6382 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6383 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6384 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6385 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6386 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6387 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6388 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6389 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
6390 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6391 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6392 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6393 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6394 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6395 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6396 gaim_prefs_add_none("/gaim/gtk/conversations"); |
12553 | 6397 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
|
6398 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6399 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6400 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6401 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6402 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
6403 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
6404 |
12264 | 6405 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6406 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 6407 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 6408 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6409 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 6410 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 6411 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
6412 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6413 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6414 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6415 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6416 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
|
6417 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6418 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6419 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6420 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6421 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6422 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6423 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6424 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6425 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6426 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 6427 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6428 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 6429 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6430 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6431 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6432 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 6433 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
|
6434 |
12616
eee2042ad4f4
[gaim-migrate @ 14952]
Richard Laager <rlaager@wiktel.com>
parents:
12604
diff
changeset
|
6435 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
|
6436 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6437 /* Connect callbacks. */ |
10087 | 6438 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
|
6439 close_on_tabs_pref_cb, NULL); |
12188 | 6440 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
6441 show_timestamps_pref_cb, NULL); | |
10087 | 6442 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
|
6443 show_formatting_toolbar_pref_cb, NULL); |
10087 | 6444 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6445 spellcheck_pref_cb, NULL); |
10087 | 6446 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6447 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6448 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6449 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6450 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6451 |
10087 | 6452 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6453 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6454 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6455 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6456 /* IM callbacks */ |
10087 | 6457 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
|
6458 animate_buddy_icons_pref_cb, NULL); |
10087 | 6459 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
|
6460 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6461 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6462 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6463 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6464 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6465 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6466 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6467 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6468 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
6469 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6470 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
12837
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6471 gaim_value_new(GAIM_TYPE_BOXED, |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6472 "GaimGtkWindow *"), |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6473 gaim_value_new(GAIM_TYPE_BOXED, |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6474 "GaimGtkWindow *")); |
9167 | 6475 |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6476 gaim_signal_register(handle, "conversation-timestamp", |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6477 gaim_marshal_POINTER__POINTER_POINTER, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6478 gaim_value_new(GAIM_TYPE_POINTER), 2, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6479 gaim_value_new(GAIM_TYPE_SUBTYPE, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6480 GAIM_SUBTYPE_CONVERSATION), |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6481 gaim_value_new(GAIM_TYPE_POINTER)); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6482 |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6483 gaim_signal_register(handle, "displaying-im-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6484 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6485 gaim_value_new(GAIM_TYPE_BOOLEAN), 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6486 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6487 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6488 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6489 gaim_value_new_outgoing(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6490 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6491 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6492 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6493 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6494 gaim_signal_register(handle, "displayed-im-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6495 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6496 NULL, 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6497 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6498 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6499 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6500 gaim_value_new(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6501 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6502 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6503 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6504 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6505 gaim_signal_register(handle, "displaying-chat-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6506 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6507 gaim_value_new(GAIM_TYPE_BOOLEAN), 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6508 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6509 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6510 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6511 gaim_value_new_outgoing(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6512 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6513 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6514 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6515 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6516 gaim_signal_register(handle, "displayed-chat-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6517 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6518 NULL, 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6519 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6520 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6521 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6522 gaim_value_new(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6523 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6524 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6525 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6526 |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6527 gaim_signal_register(handle, "conversation-switched", |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6528 gaim_marshal_VOID__POINTER_POINTER, NULL, 1, |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6529 gaim_value_new(GAIM_TYPE_SUBTYPE, |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6530 GAIM_SUBTYPE_CONVERSATION)); |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6531 |
9167 | 6532 /********************************************************************** |
6533 * Register commands | |
6534 **********************************************************************/ | |
9829 | 6535 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
6536 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
6537 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 6538 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
6539 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6540 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 6541 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
6542 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6543 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
|
6544 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6545 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6546 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 6547 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 6548 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
6549 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 6550 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6551 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6552 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6553 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6554 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6555 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6556 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6557 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6558 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6559 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6560 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6561 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6562 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6563 handle, G_CALLBACK(received_im_msg_cb), NULL); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6564 |
11581 | 6565 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6566 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6567 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6568 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6569 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6570 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6571 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6572 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6573 /* Callbacks to update a conversation */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6574 gaim_signal_connect(blist_handle, "buddy-added", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6575 G_CALLBACK(buddy_update_cb), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6576 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6577 G_CALLBACK(buddy_update_cb), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6578 gaim_signal_connect(blist_handle, "buddy-signed-on", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6579 handle, GAIM_CALLBACK(update_buddy_sign), "on"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6580 gaim_signal_connect(blist_handle, "buddy-signed-off", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6581 handle, GAIM_CALLBACK(update_buddy_sign), "off"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6582 gaim_signal_connect(blist_handle, "buddy-status-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6583 handle, GAIM_CALLBACK(update_buddy_status_changed), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6584 gaim_signal_connect(blist_handle, "buddy-idle-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6585 handle, GAIM_CALLBACK(update_buddy_idle_changed), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6586 gaim_signal_connect(blist_handle, "buddy-icon-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6587 handle, GAIM_CALLBACK(update_buddy_icon), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6588 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6589 handle, GAIM_CALLBACK(update_buddy_typing), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6590 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing-stopped", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6591 handle, GAIM_CALLBACK(update_buddy_typing), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6592 gaim_signal_connect(gaim_gtk_conversations_get_handle(), "conversation-switched", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6593 handle, GAIM_CALLBACK(update_conversation_switched), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6594 gaim_signal_connect(gaim_conversations_get_handle(), "chat-left", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6595 GAIM_CALLBACK(update_chat), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6596 gaim_signal_connect(gaim_conversations_get_handle(), "chat-joined", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6597 GAIM_CALLBACK(update_chat), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6598 gaim_signal_connect(gaim_conversations_get_handle(), "chat-topic-changed", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6599 GAIM_CALLBACK(update_chat_topic), NULL); |
12806
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6600 gaim_signal_connect_priority(gaim_conversations_get_handle(), "conversation-updated", handle, |
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6601 GAIM_CALLBACK(gaim_gtkconv_updated), NULL, |
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6602 GAIM_SIGNAL_PRIORITY_LOWEST); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6603 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6604 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6605 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6606 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6607 { |
10443 | 6608 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 6609 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6610 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6611 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6612 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6613 } |
11581 | 6614 |
6615 | |
6616 | |
6617 | |
6618 | |
6619 | |
6620 | |
6621 | |
6622 | |
6623 | |
6624 | |
6625 | |
6626 | |
6627 | |
6628 | |
6629 | |
6630 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
6631 * and touch each others' private members all day long */ | |
6632 | |
6633 /** | |
6634 * @file gtkconvwin.c GTK+ Conversation Window API | |
6635 * @ingroup gtkui | |
6636 * | |
6637 * gaim | |
6638 * | |
6639 * Gaim is the legal property of its developers, whose names are too numerous | |
6640 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6641 * source distribution. | |
6642 * | |
6643 * This program is free software; you can redistribute it and/or modify | |
6644 * it under the terms of the GNU General Public License as published by | |
6645 * the Free Software Foundation; either version 2 of the License, or | |
6646 * (at your option) any later version. | |
6647 * | |
6648 * This program is distributed in the hope that it will be useful, | |
6649 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
6650 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
6651 * GNU General Public License for more details. | |
6652 * | |
6653 * You should have received a copy of the GNU General Public License | |
6654 * along with this program; if not, write to the Free Software | |
6655 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
6656 * | |
6657 */ | |
6658 #include "internal.h" | |
6659 #include "gtkgaim.h" | |
6660 | |
6661 | |
6662 #include <gdk/gdkkeysyms.h> | |
6663 | |
6664 #include "account.h" | |
6665 #include "cmds.h" | |
6666 #include "debug.h" | |
6667 #include "imgstore.h" | |
6668 #include "log.h" | |
6669 #include "notify.h" | |
6670 #include "prpl.h" | |
6671 #include "request.h" | |
6672 #include "util.h" | |
6673 | |
6674 #include "gtkdnd-hints.h" | |
6675 #include "gtkblist.h" | |
6676 #include "gtkconv.h" | |
6677 #include "gtkdialogs.h" | |
6678 #include "gtkmenutray.h" | |
6679 #include "gtkpounce.h" | |
6680 #include "gtkprefs.h" | |
6681 #include "gtkprivacy.h" | |
6682 #include "gtkutils.h" | |
6683 #include "gtkstock.h" | |
6684 #include "gtkimhtml.h" | |
6685 #include "gtkimhtmltoolbar.h" | |
6686 | |
6687 static void | |
6688 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
6689 { | |
6690 gtk_widget_destroy(warn_close_dialog); | |
6691 warn_close_dialog = NULL; | |
6692 | |
6693 if (resp == GTK_RESPONSE_OK) | |
6694 gaim_gtk_conv_window_destroy(win); | |
6695 } | |
6696 | |
6697 static void | |
6698 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
6699 { | |
6700 GtkWidget *label; | |
6701 GtkWidget *vbox, *hbox; | |
6702 GtkWidget *img; | |
6703 | |
6704 g_return_if_fail(warn_close_dialog == NULL); | |
6705 | |
6706 | |
6707 warn_close_dialog = gtk_dialog_new_with_buttons( | |
12660 | 6708 _("Confirm close"), |
6709 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
6710 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
6711 GAIM_STOCK_CLOSE_TABS, GTK_RESPONSE_OK, NULL); | |
11581 | 6712 |
6713 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
6714 GTK_RESPONSE_OK); | |
6715 | |
6716 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
6717 6); | |
6718 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
6719 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
6720 FALSE); | |
6721 | |
6722 /* Setup the outside spacing. */ | |
6723 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
6724 | |
6725 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
6726 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
6727 | |
6728 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
6729 GTK_ICON_SIZE_DIALOG); | |
6730 /* Setup the inner hbox and put the dialog's icon in it. */ | |
6731 hbox = gtk_hbox_new(FALSE, 12); | |
6732 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
6733 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
6734 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
6735 | |
6736 /* Setup the right vbox. */ | |
6737 vbox = gtk_vbox_new(FALSE, 12); | |
6738 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
6739 | |
6740 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
6741 gtk_widget_set_size_request(label, 350, -1); | |
6742 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
6743 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
6744 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
6745 | |
6746 /* Connect the signals. */ | |
6747 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
6748 G_CALLBACK(do_close), gtkwin); | |
6749 | |
6750 } | |
6751 | |
6752 /************************************************************************** | |
6753 * Callbacks | |
6754 **************************************************************************/ | |
6755 | |
6756 static gboolean | |
6757 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
6758 { | |
6759 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6760 GList *l; |
11581 | 6761 |
6762 /* If there are unread messages then show a warning dialog */ | |
6763 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
6764 l != NULL; l = l->next) | |
6765 { | |
6766 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6767 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
|
6768 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6769 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6770 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6771 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6772 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6773 return TRUE; |
11581 | 6774 } |
6775 } | |
6776 | |
6777 gaim_gtk_conv_window_destroy(win); | |
6778 | |
6779 return TRUE; | |
6780 } | |
6781 | |
11604 | 6782 static void |
6783 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
6784 { | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6785 if (state == GAIM_UNSEEN_NONE) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6786 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6787 gtkconv->unseen_count = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6788 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6789 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6790 else |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6791 { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6792 if (state >= GAIM_UNSEEN_TEXT) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6793 gtkconv->unseen_count++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6794 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6795 if (state > gtkconv->unseen_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6796 gtkconv->unseen_state = state; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6797 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6798 |
12806
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6799 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
|
6800 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6801 |
11581 | 6802 /* |
6803 * When a conversation window is focused, we know the user | |
6804 * has looked at it so we know there are no longer unseen | |
6805 * messages. | |
6806 */ | |
6807 static gint | |
6808 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6809 { | |
6810 GaimGtkWindow *win = d; | |
11604 | 6811 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6812 | |
6813 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6814 |
6815 return FALSE; | |
6816 } | |
6817 | |
11851 | 6818 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6819 /* Courtesy of Galeon! */ |
6820 static void | |
6821 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6822 { | |
6823 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6824 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6825 } | |
11851 | 6826 #endif |
11581 | 6827 |
6828 static void | |
6829 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6830 { | |
6831 static GdkCursor *cursor = NULL; | |
6832 | |
6833 gtkwin->in_drag = TRUE; | |
6834 | |
6835 if (gtkwin->drag_leave_signal) { | |
6836 g_signal_handler_disconnect(G_OBJECT(widget), | |
6837 gtkwin->drag_leave_signal); | |
6838 gtkwin->drag_leave_signal = 0; | |
6839 } | |
6840 | |
6841 if (cursor == NULL) | |
6842 cursor = gdk_cursor_new(GDK_FLEUR); | |
6843 | |
6844 /* Grab the pointer */ | |
6845 gtk_grab_add(gtkwin->notebook); | |
6846 #ifndef _WIN32 | |
6847 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6848 always be true after a button press. */ | |
6849 if (!gdk_pointer_is_grabbed()) | |
6850 #endif | |
6851 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6852 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6853 NULL, cursor, GDK_CURRENT_TIME); | |
6854 } | |
6855 | |
6856 static gboolean | |
6857 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6858 { | |
6859 | |
6860 /* | |
6861 * Make sure the user moved the mouse far enough for the | |
6862 * drag to be initiated. | |
6863 */ | |
6864 if (win->in_predrag) { | |
6865 if (e->x_root < win->drag_min_x || | |
6866 e->x_root >= win->drag_max_x || | |
6867 e->y_root < win->drag_min_y || | |
6868 e->y_root >= win->drag_max_y) { | |
6869 | |
6870 win->in_predrag = FALSE; | |
6871 notebook_init_grab(win, widget); | |
6872 } | |
6873 } | |
6874 else { /* Otherwise, draw the arrows. */ | |
6875 GaimGtkWindow *dest_win; | |
6876 GtkNotebook *dest_notebook; | |
6877 GtkWidget *tab; | |
6878 gint nb_x, nb_y, page_num; | |
6879 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6880 gboolean horiz_tabs = FALSE; | |
11614 | 6881 GaimGtkConversation *gtkconv; |
6882 gboolean to_right = FALSE; | |
11581 | 6883 |
6884 /* Get the window that the cursor is over. */ | |
6885 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6886 | |
6887 if (dest_win == NULL) { | |
6888 dnd_hints_hide_all(); | |
6889 | |
6890 return TRUE; | |
6891 } | |
6892 | |
6893 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6894 | |
6895 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6896 | |
6897 arrow1_x = arrow2_x = nb_x; | |
6898 arrow1_y = arrow2_y = nb_y; | |
6899 | |
6900 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6901 e->x_root, e->y_root, &to_right); |
6902 to_right = to_right && (win != dest_win); | |
11581 | 6903 |
6904 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6905 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6906 | |
6907 horiz_tabs = TRUE; | |
6908 } | |
6909 | |
11614 | 6910 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6911 tab = gtkconv->tabby; | |
11581 | 6912 |
6913 if (horiz_tabs) { | |
6914 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6915 | |
11614 | 6916 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6917 arrow1_x += tab->allocation.width; |
6918 arrow2_x += tab->allocation.width; | |
6919 } | |
6920 | |
6921 arrow1_y = nb_y + tab->allocation.y; | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6922 arrow2_y = nb_y + tab->allocation.y + tab->allocation.height; |
11581 | 6923 } else { |
6924 arrow1_x = nb_x + tab->allocation.x; | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6925 arrow2_x = nb_x + tab->allocation.x + tab->allocation.width; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6926 arrow1_y = arrow2_y = nb_y + tab->allocation.y; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6927 |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6928 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6929 arrow1_y += tab->allocation.height; |
6930 arrow2_y += tab->allocation.height; | |
6931 } | |
6932 } | |
6933 | |
6934 if (horiz_tabs) { | |
6935 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6936 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6937 } else { | |
6938 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6939 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6940 } | |
6941 } | |
6942 | |
6943 return TRUE; | |
6944 } | |
6945 | |
6946 static gboolean | |
6947 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6948 { | |
6949 if (win->in_drag) | |
6950 return FALSE; | |
6951 | |
6952 if (e->x_root < win->drag_min_x || | |
6953 e->x_root >= win->drag_max_x || | |
6954 e->y_root < win->drag_min_y || | |
6955 e->y_root >= win->drag_max_y) { | |
6956 | |
6957 win->in_predrag = FALSE; | |
6958 notebook_init_grab(win, widget); | |
6959 } | |
6960 | |
6961 return TRUE; | |
6962 } | |
6963 | |
6964 /* | |
6965 * THANK YOU GALEON! | |
6966 */ | |
6967 static gboolean | |
6968 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6969 { | |
6970 gint nb_x, nb_y, x_rel, y_rel; | |
6971 int tab_clicked; | |
6972 GtkWidget *page; | |
6973 GtkWidget *tab; | |
6974 | |
6975 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6976 return FALSE; | |
6977 | |
6978 | |
6979 if (win->in_drag) { | |
6980 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6981 "Already in the middle of a window drag at tab_press_cb\n"); | |
6982 return TRUE; | |
6983 } | |
6984 | |
6985 /* | |
6986 * Make sure a tab was actually clicked. The arrow buttons | |
6987 * mess things up. | |
6988 */ | |
11614 | 6989 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6990 |
6991 if (tab_clicked == -1) | |
6992 return FALSE; | |
6993 | |
6994 /* | |
6995 * Get the relative position of the press event, with regards to | |
6996 * the position of the notebook. | |
6997 */ | |
6998 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6999 | |
7000 x_rel = e->x_root - nb_x; | |
7001 y_rel = e->y_root - nb_y; | |
7002 | |
7003 /* Reset the min/max x/y */ | |
7004 win->drag_min_x = 0; | |
7005 win->drag_min_y = 0; | |
7006 win->drag_max_x = 0; | |
7007 win->drag_max_y = 0; | |
7008 | |
7009 /* Find out which tab was dragged. */ | |
7010 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
7011 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
7012 | |
7013 win->drag_min_x = tab->allocation.x + nb_x; | |
7014 win->drag_min_y = tab->allocation.y + nb_y; | |
7015 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
7016 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
7017 | |
7018 /* Make sure the click occurred in the tab. */ | |
7019 if (e->x_root < win->drag_min_x || | |
7020 e->x_root >= win->drag_max_x || | |
7021 e->y_root < win->drag_min_y || | |
7022 e->y_root >= win->drag_max_y) { | |
7023 | |
7024 return FALSE; | |
7025 } | |
7026 | |
7027 win->in_predrag = TRUE; | |
7028 win->drag_tab = tab_clicked; | |
7029 | |
7030 /* Connect the new motion signals. */ | |
7031 win->drag_motion_signal = | |
7032 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
7033 G_CALLBACK(notebook_motion_cb), win); | |
7034 | |
7035 win->drag_leave_signal = | |
7036 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
7037 G_CALLBACK(notebook_leave_cb), win); | |
7038 | |
7039 return FALSE; | |
7040 } | |
7041 | |
7042 static gboolean | |
7043 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
7044 { | |
7045 GaimGtkWindow *dest_win; | |
7046 GaimConversation *conv; | |
7047 GaimGtkConversation *gtkconv; | |
7048 gint dest_page_num = 0; | |
7049 gboolean new_window = FALSE; | |
11614 | 7050 gboolean to_right = FALSE; |
11581 | 7051 |
7052 /* | |
7053 * Don't check to make sure that the event's window matches the | |
7054 * widget's, because we may be getting an event passed on from the | |
7055 * close button. | |
7056 */ | |
7057 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
7058 return FALSE; | |
7059 | |
7060 if (gdk_pointer_is_grabbed()) { | |
7061 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
7062 gtk_grab_remove(widget); | |
7063 } | |
7064 | |
7065 if (!win->in_predrag && !win->in_drag) | |
7066 return FALSE; | |
7067 | |
7068 /* Disconnect the motion signal. */ | |
7069 if (win->drag_motion_signal) { | |
7070 g_signal_handler_disconnect(G_OBJECT(widget), | |
7071 win->drag_motion_signal); | |
7072 | |
7073 win->drag_motion_signal = 0; | |
7074 } | |
7075 | |
7076 /* | |
7077 * If we're in a pre-drag, we'll also need to disconnect the leave | |
7078 * signal. | |
7079 */ | |
7080 if (win->in_predrag) { | |
7081 win->in_predrag = FALSE; | |
7082 | |
7083 if (win->drag_leave_signal) { | |
7084 g_signal_handler_disconnect(G_OBJECT(widget), | |
7085 win->drag_leave_signal); | |
7086 | |
7087 win->drag_leave_signal = 0; | |
7088 } | |
7089 } | |
7090 | |
7091 /* If we're not in drag... */ | |
7092 /* We're perfectly normal people! */ | |
7093 if (!win->in_drag) | |
7094 return FALSE; | |
7095 | |
7096 win->in_drag = FALSE; | |
7097 | |
7098 dnd_hints_hide_all(); | |
7099 | |
7100 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
7101 | |
7102 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
7103 | |
7104 if (dest_win == NULL) { | |
7105 /* If the current window doesn't have any other conversations, | |
7106 * there isn't much point transferring the conv to a new window. */ | |
7107 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
7108 /* Make a new window to stick this to. */ | |
7109 dest_win = gaim_gtk_conv_window_new(); | |
7110 new_window = TRUE; | |
7111 } | |
7112 } | |
7113 | |
7114 if (dest_win == NULL) | |
7115 return FALSE; | |
7116 | |
7117 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
7118 "conversation-dragging", win, dest_win); | |
7119 | |
7120 /* Get the destination page number. */ | |
7121 if (!new_window) | |
7122 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 7123 e->x_root, e->y_root, &to_right); |
11581 | 7124 |
7125 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7126 | |
7127 if (win == dest_win) { | |
7128 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
7129 } else { | |
7130 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
7131 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 7132 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 7133 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
7134 if (new_window) { | |
7135 gint win_width, win_height; | |
7136 | |
7137 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
7138 &win_width, &win_height); | |
7139 | |
7140 gtk_window_move(GTK_WINDOW(dest_win->window), | |
7141 e->x_root - (win_width / 2), | |
7142 e->y_root - (win_height / 2)); | |
7143 | |
7144 gaim_gtk_conv_window_show(dest_win); | |
7145 } | |
7146 } | |
7147 | |
7148 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
7149 | |
7150 return TRUE; | |
7151 } | |
7152 | |
7153 | |
7154 static void | |
7155 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
7156 gpointer user_data) | |
7157 { | |
7158 GaimGtkWindow *win; | |
7159 GaimConversation *conv; | |
7160 GaimGtkConversation *gtkconv; | |
7161 | |
7162 win = user_data; | |
7163 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
7164 | |
7165 g_return_if_fail(conv != NULL); | |
7166 | |
7167 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
7168 return; | |
7169 | |
7170 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7171 | |
7172 stop_anim(NULL, gtkconv); | |
7173 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7174 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7175 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7176 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7177 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7178 } |
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 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7181 detach_tab_cb(GtkWidget *w, GObject *menu) |
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 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7184 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7185 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7186 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7187 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7188 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7189 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7190 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7191 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7192 /* 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
|
7193 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7194 return; |
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 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7197 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7198 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7199 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7200 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7201 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7202 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7203 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7204 close_others_cb(GtkWidget *w, GObject *menu) |
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 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7207 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7208 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 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7211 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7212 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7213 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7214 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7215 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7216 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7217 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
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 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7220 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7221 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7222 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7223 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7224 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7225 } |
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 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7228 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7229 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7230 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7231 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7232 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7233 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7234 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7235 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7236 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7237 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7238 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7239 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7240 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7241 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7242 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7243 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7244 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7245 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7246 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7247 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7248 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
7249 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
|
7250 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7251 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7252 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7253 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7254 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7255 } |
12188 | 7256 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7257 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7258 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7259 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7260 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7261 |
13326 | 7262 item = gtk_menu_item_new_with_label(_("Close other tabs")); |
12824
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7263 gtk_widget_show(item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7264 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7265 g_signal_connect(G_OBJECT(item), "activate", |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7266 G_CALLBACK(close_others_cb), menu); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7267 |
13326 | 7268 item = gtk_menu_item_new_with_label(_("Close all tabs")); |
12824
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7269 gtk_widget_show(item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7270 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7271 g_signal_connect(G_OBJECT(item), "activate", |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7272 G_CALLBACK(close_window), win); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7273 |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7274 gaim_separator(menu); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7275 |
13326 | 7276 item = gtk_menu_item_new_with_label(_("Detach this tab")); |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7277 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7278 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7279 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7280 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7281 |
13326 | 7282 item = gtk_menu_item_new_with_label(_("Close this tab")); |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7283 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7284 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7285 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7286 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7287 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7288 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7289 } |
11581 | 7290 |
7291 static void | |
7292 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
7293 gpointer user_data) | |
7294 { | |
7295 GaimGtkWindow *win; | |
7296 GaimConversation *conv; | |
7297 GaimGtkConversation *gtkconv; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7298 const char *sound_method; |
11581 | 7299 |
7300 win = user_data; | |
7301 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
7302 conv = gtkconv->active_conv; | |
7303 | |
7304 g_return_if_fail(conv != NULL); | |
7305 | |
7306 /* | |
7307 * Only set "unseen" to "none" if the window has focus | |
7308 */ | |
7309 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 7310 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 7311 |
7312 /* Update the menubar */ | |
7313 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
7314 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
|
7315 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
7316 |
11594 | 7317 generate_send_to_items(win); |
7318 | |
11604 | 7319 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 7320 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7321 sound_method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7322 if (strcmp(sound_method, "none") != 0) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7323 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
|
7324 gtkconv->make_sound); |
11581 | 7325 |
7326 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
7327 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
7328 | |
7329 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
12188 | 7330 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
11581 | 7331 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7332 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM && |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7333 gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7334 { |
11581 | 7335 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
7336 gtkconv->u.im->show_icon); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7337 } |
11604 | 7338 |
11581 | 7339 /* |
7340 * We pause icons when they are not visible. If this icon should | |
7341 * be animated then start it back up again. | |
7342 */ | |
7343 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
7344 (gtkconv->u.im->animate)) | |
7345 start_anim(NULL, gtkconv); | |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
7346 |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
7347 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-switched", conv); |
11581 | 7348 } |
7349 | |
7350 /************************************************************************** | |
7351 * GTK+ window ops | |
7352 **************************************************************************/ | |
7353 | |
7354 GList * | |
7355 gaim_gtk_conv_windows_get_list() | |
7356 { | |
7357 return window_list; | |
7358 } | |
7359 | |
7360 GaimGtkWindow * | |
7361 gaim_gtk_conv_window_new() | |
7362 { | |
7363 GaimGtkWindow *win; | |
7364 GtkPositionType pos; | |
7365 GtkWidget *testidea; | |
7366 GtkWidget *menubar; | |
7367 | |
7368 win = g_malloc0(sizeof(GaimGtkWindow)); | |
7369 | |
7370 window_list = g_list_append(window_list, win); | |
7371 | |
7372 /* Create the window. */ | |
7373 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
7374 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
7375 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
7376 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
7377 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
7378 | |
7379 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
7380 G_CALLBACK(close_win_cb), win); | |
7381 | |
7382 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
7383 G_CALLBACK(focus_win_cb), win); | |
7384 | |
7385 /* Create the notebook. */ | |
7386 win->notebook = gtk_notebook_new(); | |
7387 | |
7388 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
7389 | |
7390 #if 0 | |
7391 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
7392 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
7393 #endif | |
7394 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
7395 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
7396 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
7397 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
7398 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
7399 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7400 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7401 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7402 |
11581 | 7403 gtk_widget_show(win->notebook); |
7404 | |
7405 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
7406 G_CALLBACK(before_switch_conv_cb), win); | |
7407 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
7408 G_CALLBACK(switch_conv_cb), win); | |
7409 | |
7410 /* Setup the tab drag and drop signals. */ | |
7411 gtk_widget_add_events(win->notebook, | |
7412 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
7413 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
7414 G_CALLBACK(notebook_press_cb), win); | |
7415 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
7416 G_CALLBACK(notebook_release_cb), win); | |
7417 | |
7418 testidea = gtk_vbox_new(FALSE, 0); | |
7419 | |
7420 /* Setup the menubar. */ | |
7421 menubar = setup_menubar(win); | |
7422 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
7423 | |
7424 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
7425 | |
7426 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
7427 | |
7428 gtk_widget_show(testidea); | |
7429 | |
7430 return win; | |
7431 } | |
7432 | |
7433 void | |
7434 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
7435 { | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7436 gaim_prefs_disconnect_by_handle(win); |
11581 | 7437 window_list = g_list_remove(window_list, win); |
7438 | |
11611 | 7439 if (win->gtkconvs) { |
7440 while (win->gtkconvs) { | |
7441 GList *nextgtk = win->gtkconvs->next; | |
7442 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
7443 GList *nextcore = gtkconv->convs->next; | |
7444 GaimConversation *conv = gtkconv->convs->data; | |
7445 gaim_conversation_destroy(conv); | |
7446 if (!nextgtk && !nextcore) | |
7447 /* we'll end up invoking ourselves when we destroy our last child */ | |
7448 /* so don't destroy ourselves right now */ | |
7449 return; | |
7450 } | |
7451 return; | |
7452 } | |
11581 | 7453 gtk_widget_destroy(win->window); |
7454 | |
7455 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
7456 | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
7457 gaim_notify_close_with_handle(win); |
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
7458 |
11581 | 7459 g_free(win); |
7460 } | |
7461 | |
7462 void | |
7463 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
7464 { | |
7465 gtk_widget_show(win->window); | |
7466 } | |
7467 | |
7468 void | |
7469 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
7470 { | |
7471 gtk_widget_hide(win->window); | |
7472 } | |
7473 | |
7474 void | |
7475 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
7476 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
7477 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 7478 } |
7479 | |
7480 void | |
7481 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
7482 { | |
7483 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
7484 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
7485 gtkconv->tab_cont)); | |
7486 } | |
7487 | |
7488 void | |
7489 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
7490 { | |
7491 GaimConversation *conv = gtkconv->active_conv; | |
7492 GaimGtkConversation *focus_gtkconv; | |
7493 GtkWidget *tabby, *menu_tabby; | |
7494 GtkWidget *tab_cont = gtkconv->tab_cont; | |
7495 GtkWidget *close_image; | |
7496 GaimConversationType conv_type; | |
7497 const char *name; | |
7498 const gchar *tmp_lab; | |
7499 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 7500 gboolean tabs_side = FALSE; |
7501 gint angle = 0; | |
11581 | 7502 |
7503 name = gaim_conversation_get_name(conv); | |
7504 conv_type = gaim_conversation_get_type(conv); | |
7505 | |
7506 | |
7507 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
7508 gtkconv->win = win; | |
7509 | |
11619 | 7510 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
7511 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
7512 tabs_side = TRUE; | |
7513 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
7514 angle = 90; | |
7515 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
7516 angle = 270; | |
7517 | |
7518 if (angle) | |
7519 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
7520 else | |
7521 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 7522 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
7523 | |
7524 /* Close button. */ | |
7525 gtkconv->close = gtk_button_new(); | |
7526 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
7527 if (gtk_check_version(2, 4, 2) == NULL) { | |
7528 /* Need to account for extra padding around the gtkbutton */ | |
7529 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
7530 "focus-line-width", &focus_width, | |
7531 "focus-padding", &focus_pad, | |
7532 NULL); | |
7533 close_button_width += (focus_width + focus_pad) * 2; | |
7534 close_button_height += (focus_width + focus_pad) * 2; | |
7535 } | |
7536 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
7537 close_button_width, close_button_height); | |
7538 | |
7539 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
7540 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
7541 gtk_widget_show(close_image); | |
7542 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
7543 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
7544 _("Close conversation"), NULL); | |
7545 | |
7546 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
7547 G_CALLBACK(close_conv_cb), gtkconv); | |
7548 | |
11851 | 7549 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 7550 /* |
7551 * I love Galeon. They have a fix for that stupid annoying visible | |
7552 * border bug. I love you guys! -- ChipX86 | |
7553 */ | |
11851 | 7554 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 7555 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
7556 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 7557 #endif |
11581 | 7558 |
7559 /* Status icon. */ | |
7560 gtkconv->icon = gtk_image_new(); | |
7561 gtkconv->menu_icon = gtk_image_new(); | |
7562 update_tab_icon(conv); | |
7563 | |
7564 /* Tab label. */ | |
7565 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 7566 |
11581 | 7567 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 7568 if (!angle) |
7569 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 7570 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 7571 if (tabs_side) { |
7572 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
7573 } | |
7574 if (angle) | |
7575 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 7576 #endif |
7577 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
7578 #if 0 | |
7579 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
7580 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
7581 #endif | |
7582 | |
7583 /* Pack it all together. */ | |
11619 | 7584 if (angle == 90) |
7585 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
7586 else | |
7587 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 7588 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
7589 FALSE, FALSE, 0); | |
7590 | |
7591 gtk_widget_show_all(gtkconv->icon); | |
7592 gtk_widget_show_all(gtkconv->menu_icon); | |
7593 | |
7594 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
7595 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
7596 gtk_widget_show(gtkconv->tab_label); | |
7597 gtk_widget_show(gtkconv->menu_label); | |
7598 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
7599 | |
11619 | 7600 if (angle == 90) |
7601 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
7602 else | |
7603 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 7604 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
7605 gtk_widget_show(gtkconv->close); | |
7606 | |
7607 gtk_widget_show(tabby); | |
7608 gtk_widget_show(menu_tabby); | |
7609 | |
7610 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
7611 gaim_gtkconv_update_buddy_icon(conv); | |
7612 | |
7613 /* Add this pane to the conversation's notebook. */ | |
7614 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 7615 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 7616 |
7617 | |
7618 gtk_widget_show(tab_cont); | |
7619 | |
7620 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
7621 /* Er, bug in notebooks? Switch to the page manually. */ | |
7622 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
7623 | |
7624 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7625 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7626 } else | |
7627 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
7628 | |
7629 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
7630 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
7631 gtk_widget_grab_focus(focus_gtkconv->entry); | |
7632 | |
7633 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 7634 update_send_to_selection(win); |
11581 | 7635 } |
7636 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7637 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7638 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
11581 | 7639 { |
7640 unsigned int index; | |
7641 GaimConversationType conv_type; | |
7642 | |
7643 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
7644 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
7645 | |
7646 g_object_ref(gtkconv->tab_cont); | |
7647 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
7648 | |
7649 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
7650 | |
7651 /* go back to tabless if need be */ | |
7652 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
7653 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7654 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7655 } | |
7656 | |
7657 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 7658 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7659 if (!win->gtkconvs && win != hidden_convwin) |
11582 | 7660 gaim_gtk_conv_window_destroy(win); |
11581 | 7661 } |
7662 | |
7663 GaimGtkConversation * | |
7664 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
7665 { | |
7666 GtkWidget *tab_cont; | |
7667 | |
7668 if (index == -1) | |
7669 index = 0; | |
7670 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 7671 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 7672 } |
7673 | |
7674 GaimGtkConversation * | |
7675 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
7676 { | |
7677 int index; | |
7678 GtkWidget *tab_cont; | |
7679 | |
7680 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
7681 if (index == -1) | |
7682 index = 0; | |
7683 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
7684 if (!tab_cont) | |
7685 return NULL; | |
7686 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
7687 } | |
7688 | |
7689 | |
7690 GaimConversation * | |
7691 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
7692 { | |
7693 GaimGtkConversation *gtkconv; | |
7694 | |
7695 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
7696 return gtkconv ? gtkconv->active_conv : NULL; | |
7697 } | |
7698 | |
7699 gboolean | |
7700 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
7701 { | |
7702 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
7703 } | |
7704 | |
7705 gboolean | |
7706 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
7707 { | |
7708 gboolean has_focus = FALSE; | |
7709 | |
7710 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
7711 | |
7712 return has_focus; | |
7713 } | |
7714 | |
7715 GaimGtkWindow * | |
7716 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
7717 { | |
7718 GaimGtkWindow *win; | |
7719 GdkWindow *gdkwin; | |
7720 GList *l; | |
7721 | |
7722 gdkwin = gdk_window_at_pointer(&x, &y); | |
7723 | |
7724 if (gdkwin) | |
7725 gdkwin = gdk_window_get_toplevel(gdkwin); | |
7726 | |
7727 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
7728 win = l->data; | |
7729 | |
7730 if (gdkwin == win->window->window) | |
7731 return win; | |
7732 } | |
7733 | |
7734 return NULL; | |
7735 } | |
7736 | |
7737 GList * | |
7738 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
7739 { | |
7740 return win->gtkconvs; | |
7741 } | |
7742 | |
7743 guint | |
7744 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
7745 { | |
7746 return g_list_length(win->gtkconvs); | |
7747 } | |
7748 | |
7749 GaimGtkWindow * | |
7750 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
7751 { | |
7752 GList *wins, *convs; | |
7753 GaimGtkWindow *win; | |
7754 GaimGtkConversation *conv; | |
7755 | |
7756 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7757 return NULL; | |
7758 | |
7759 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7760 win = wins->data; | |
7761 | |
7762 for (convs = win->gtkconvs; | |
7763 convs != NULL; | |
7764 convs = convs->next) { | |
7765 | |
7766 conv = convs->data; | |
7767 | |
7768 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7769 return win; | |
7770 } | |
7771 } | |
7772 | |
7773 return NULL; | |
7774 } | |
7775 | |
7776 GaimGtkWindow * | |
7777 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
7778 { | |
7779 GList *wins, *convs; | |
7780 GaimGtkWindow *win; | |
7781 GaimGtkConversation *conv; | |
7782 | |
7783 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7784 return NULL; | |
7785 | |
7786 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7787 wins != NULL; | |
7788 wins = wins->prev) { | |
7789 | |
7790 win = wins->data; | |
7791 | |
7792 for (convs = win->gtkconvs; | |
7793 convs != NULL; | |
7794 convs = convs->next) { | |
7795 | |
7796 conv = convs->data; | |
7797 | |
7798 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7799 return win; | |
7800 } | |
7801 } | |
7802 | |
7803 return NULL; | |
7804 } | |
7805 | |
7806 | |
7807 /************************************************************************** | |
7808 * Conversation placement functions | |
7809 **************************************************************************/ | |
7810 typedef struct | |
7811 { | |
7812 char *id; | |
7813 char *name; | |
7814 GaimConvPlacementFunc fnc; | |
7815 | |
7816 } ConvPlacementData; | |
7817 | |
7818 static GList *conv_placement_fncs = NULL; | |
7819 static GaimConvPlacementFunc place_conv = NULL; | |
7820 | |
7821 /* This one places conversations in the last made window. */ | |
7822 static void | |
7823 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7824 { | |
7825 GaimGtkWindow *win; | |
7826 | |
7827 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7828 win = l ? l->data : NULL;; | |
7829 | |
7830 if (win == NULL) { | |
7831 win = gaim_gtk_conv_window_new(); | |
7832 | |
7833 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7834 gaim_gtk_conv_window_show(win); | |
7835 } else { | |
7836 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7837 } | |
7838 } | |
7839 | |
7840 /* This one places conversations in the last made window of the same type. */ | |
7841 static void | |
7842 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7843 { | |
7844 GaimGtkWindow *win; | |
7845 | |
7846 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7847 | |
7848 if (win == NULL) { | |
7849 win = gaim_gtk_conv_window_new(); | |
7850 | |
7851 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7852 gaim_gtk_conv_window_show(win); | |
7853 } else | |
7854 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7855 } | |
7856 | |
7857 /* This one places each conversation in its own window. */ | |
7858 static void | |
7859 conv_placement_new_window(GaimGtkConversation *conv) | |
7860 { | |
7861 GaimGtkWindow *win; | |
7862 | |
7863 win = gaim_gtk_conv_window_new(); | |
7864 | |
7865 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7866 | |
7867 gaim_gtk_conv_window_show(win); | |
7868 } | |
7869 | |
7870 static GaimGroup * | |
7871 conv_get_group(GaimGtkConversation *conv) | |
7872 { | |
7873 GaimGroup *group = NULL; | |
7874 | |
7875 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7876 GaimBuddy *buddy; | |
7877 | |
7878 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7879 gaim_conversation_get_name(conv->active_conv)); | |
7880 | |
7881 if (buddy != NULL) | |
12088 | 7882 group = gaim_buddy_get_group(buddy); |
11581 | 7883 |
7884 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7885 GaimChat *chat; | |
7886 | |
7887 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7888 gaim_conversation_get_name(conv->active_conv)); | |
7889 | |
7890 if (chat != NULL) | |
7891 group = gaim_chat_get_group(chat); | |
7892 } | |
7893 | |
7894 return group; | |
7895 } | |
7896 | |
7897 /* | |
7898 * This groups things by, well, group. Buddies from groups will always be | |
7899 * grouped together, and a buddy from a group not belonging to any currently | |
7900 * open windows will get a new window. | |
7901 */ | |
7902 static void | |
7903 conv_placement_by_group(GaimGtkConversation *conv) | |
7904 { | |
7905 GaimConversationType type; | |
7906 GaimGroup *group = NULL; | |
7907 GList *wl, *cl; | |
7908 | |
7909 type = gaim_conversation_get_type(conv->active_conv); | |
7910 | |
7911 group = conv_get_group(conv); | |
7912 | |
7913 /* Go through the list of IMs and find one with this group. */ | |
7914 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7915 GaimGtkWindow *win2; | |
7916 GaimGtkConversation *conv2; | |
7917 GaimGroup *group2 = NULL; | |
7918 | |
7919 win2 = wl->data; | |
7920 | |
7921 for (cl = win2->gtkconvs; | |
7922 cl != NULL; | |
7923 cl = cl->next) { | |
7924 conv2 = cl->data; | |
7925 | |
7926 group2 = conv_get_group(conv2); | |
7927 | |
7928 if (group == group2) { | |
7929 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7930 | |
7931 return; | |
7932 } | |
7933 } | |
7934 } | |
7935 | |
7936 /* Make a new window. */ | |
7937 conv_placement_new_window(conv); | |
7938 } | |
7939 | |
7940 /* This groups things by account. Otherwise, the same semantics as above */ | |
7941 static void | |
7942 conv_placement_by_account(GaimGtkConversation *conv) | |
7943 { | |
7944 GaimConversationType type; | |
7945 GList *wins, *convs; | |
7946 GaimAccount *account; | |
7947 | |
7948 account = gaim_conversation_get_account(conv->active_conv); | |
7949 type = gaim_conversation_get_type(conv->active_conv); | |
7950 | |
7951 /* Go through the list of IMs and find one with this group. */ | |
7952 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7953 GaimGtkWindow *win2; | |
7954 GaimGtkConversation *conv2; | |
7955 | |
7956 win2 = wins->data; | |
7957 | |
7958 for (convs = win2->gtkconvs; | |
7959 convs != NULL; | |
7960 convs = convs->next) { | |
7961 conv2 = convs->data; | |
7962 | |
7963 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7964 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7965 return; | |
7966 } | |
7967 } | |
7968 } | |
7969 | |
7970 /* Make a new window. */ | |
7971 conv_placement_new_window(conv); | |
7972 } | |
7973 | |
7974 static ConvPlacementData * | |
7975 get_conv_placement_data(const char *id) | |
7976 { | |
7977 ConvPlacementData *data = NULL; | |
7978 GList *n; | |
7979 | |
7980 for (n = conv_placement_fncs; n; n = n->next) { | |
7981 data = n->data; | |
7982 if (!strcmp(data->id, id)) | |
7983 return data; | |
7984 } | |
7985 | |
7986 return NULL; | |
7987 } | |
7988 | |
7989 static void | |
7990 add_conv_placement_fnc(const char *id, const char *name, | |
7991 GaimConvPlacementFunc fnc) | |
7992 { | |
7993 ConvPlacementData *data; | |
7994 | |
7995 data = g_new(ConvPlacementData, 1); | |
7996 | |
7997 data->id = g_strdup(id); | |
7998 data->name = g_strdup(name); | |
7999 data->fnc = fnc; | |
8000 | |
8001 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
8002 } | |
8003 | |
8004 static void | |
8005 ensure_default_funcs(void) | |
8006 { | |
8007 if (conv_placement_fncs == NULL) { | |
8008 add_conv_placement_fnc("last", _("Last created window"), | |
8009 conv_placement_last_created_win); | |
8010 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
8011 conv_placement_last_created_win_type); | |
8012 add_conv_placement_fnc("new", _("New window"), | |
8013 conv_placement_new_window); | |
8014 add_conv_placement_fnc("group", _("By group"), | |
8015 conv_placement_by_group); | |
8016 add_conv_placement_fnc("account", _("By account"), | |
8017 conv_placement_by_account); | |
8018 } | |
8019 } | |
8020 | |
8021 GList * | |
8022 gaim_gtkconv_placement_get_options(void) | |
8023 { | |
8024 GList *n, *list = NULL; | |
8025 ConvPlacementData *data; | |
8026 | |
8027 ensure_default_funcs(); | |
8028 | |
8029 for (n = conv_placement_fncs; n; n = n->next) { | |
8030 data = n->data; | |
8031 list = g_list_append(list, data->name); | |
8032 list = g_list_append(list, data->id); | |
8033 } | |
8034 | |
8035 return list; | |
8036 } | |
8037 | |
8038 | |
8039 void | |
8040 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
8041 GaimConvPlacementFunc fnc) | |
8042 { | |
8043 g_return_if_fail(id != NULL); | |
8044 g_return_if_fail(name != NULL); | |
8045 g_return_if_fail(fnc != NULL); | |
8046 | |
8047 ensure_default_funcs(); | |
8048 | |
8049 add_conv_placement_fnc(id, name, fnc); | |
8050 } | |
8051 | |
8052 void | |
8053 gaim_gtkconv_placement_remove_fnc(const char *id) | |
8054 { | |
8055 ConvPlacementData *data = get_conv_placement_data(id); | |
8056 | |
8057 if (data == NULL) | |
8058 return; | |
8059 | |
8060 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
8061 | |
8062 g_free(data->id); | |
8063 g_free(data->name); | |
8064 g_free(data); | |
8065 } | |
8066 | |
8067 const char * | |
8068 gaim_gtkconv_placement_get_name(const char *id) | |
8069 { | |
8070 ConvPlacementData *data; | |
8071 | |
8072 ensure_default_funcs(); | |
8073 | |
8074 data = get_conv_placement_data(id); | |
8075 | |
8076 if (data == NULL) | |
8077 return NULL; | |
8078 | |
8079 return data->name; | |
8080 } | |
8081 | |
8082 GaimConvPlacementFunc | |
8083 gaim_gtkconv_placement_get_fnc(const char *id) | |
8084 { | |
8085 ConvPlacementData *data; | |
8086 | |
8087 ensure_default_funcs(); | |
8088 | |
8089 data = get_conv_placement_data(id); | |
8090 | |
8091 if (data == NULL) | |
8092 return NULL; | |
8093 | |
8094 return data->fnc; | |
8095 } | |
8096 | |
8097 void | |
8098 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
8099 { | |
8100 g_return_if_fail(func != NULL); | |
8101 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8102 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8103 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8104 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8105 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8106 place_conv = NULL; |
11581 | 8107 } |
8108 | |
8109 GaimConvPlacementFunc | |
8110 gaim_gtkconv_placement_get_current_func(void) | |
8111 { | |
8112 return place_conv; | |
8113 } | |
8114 | |
8115 void | |
8116 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
8117 { | |
8118 if (place_conv) | |
8119 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8120 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8121 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8122 } |
12239 | 8123 |
8124 gboolean | |
8125 gaim_gtkconv_is_hidden(GaimGtkConversation *gtkconv) | |
8126 { | |
8127 g_return_val_if_fail(gtkconv != NULL, FALSE); | |
8128 | |
8129 return (gtkconv->win == hidden_convwin); | |
8130 } | |
12345
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 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8133 /* Algorithm from http://www.w3.org/TR/AERT#color-contrast */ |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
8134 static gboolean |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8135 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
|
8136 { |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8137 gulong fg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8138 gulong bg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8139 gulong br_diff; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8140 gulong col_diff; |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8141 int fred, fgreen, fblue, bred, bgreen, bblue; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8142 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8143 /* 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
|
8144 * GTK on the other hand has values between 0 and 65535 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8145 * Err suggested I >> 8, which grabbed the high bits. |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8146 */ |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8147 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8148 fred = foreground.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8149 fgreen = foreground.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8150 fblue = foreground.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8151 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8152 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8153 bred = background.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8154 bgreen = background.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8155 bblue = background.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8156 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8157 fg_brightness = (fred * 299 + fgreen * 587 + fblue * 114) / 1000; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8158 bg_brightness = (bred * 299 + bgreen * 587 + bblue * 114) / 1000; |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8159 br_diff = abs(fg_brightness - bg_brightness); |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8160 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8161 col_diff = abs(fred - bred) + abs(fgreen - bgreen) + abs(fblue - bblue); |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8162 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8163 return ((col_diff > color_contrast) && (br_diff > brightness_contrast)); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8164 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8165 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8166 |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
8167 static GdkColor* |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8168 generate_nick_colors(guint *color_count, GdkColor background) |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8169 { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8170 guint numcolors = *color_count; |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8171 guint i = 0, j = 0; |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8172 GdkColor *colors = g_new(GdkColor, numcolors); |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8173 GdkColor nick_highlight; |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8174 GdkColor send_color; |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8175 time_t breakout_time; |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8176 |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8177 gdk_color_parse(HIGHLIGHT_COLOR, &nick_highlight); |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8178 gdk_color_parse(SEND_COLOR, &send_color); |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8179 |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8180 srand(background.red + background.green + background.blue + 1); |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8181 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8182 breakout_time = time(NULL) + 3; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8183 |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8184 /* 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
|
8185 * 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
|
8186 * numcolors of them that do |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8187 */ |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8188 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
|
8189 { |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8190 GdkColor color = nick_seed_colors[j]; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8191 |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8192 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
|
8193 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8194 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8195 { |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8196 colors[i] = color; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8197 i++; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8198 } |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8199 j++; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8200 } |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8201 |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8202 /* 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
|
8203 * 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
|
8204 * 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
|
8205 * conflict with each other. |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8206 */ |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8207 while(i < numcolors && time(NULL) < breakout_time) |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8208 { |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8209 GdkColor color = { 0, rand() % 65536, rand() % 65536, rand() % 65536 }; |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8210 |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8211 gaim_debug(GAIM_DEBUG_WARNING, NULL, |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8212 "Looking for random colors to fill the list, I have found %i so far.\n",i); |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8213 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8214 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
|
8215 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8216 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8217 { |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8218 colors[i] = color; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8219 i++; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8220 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8221 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8222 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8223 if (i < numcolors) { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8224 GdkColor *c = colors; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8225 gaim_debug(GAIM_DEBUG_WARNING, NULL, "Unable to generate enough random colors before timeout. %u colors found.\n", i); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8226 colors = g_memdup(c, i * sizeof(GdkColor)); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8227 g_free(c); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8228 *color_count = i; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8229 |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8230 } |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8231 |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8232 return colors; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8233 } |