Mercurial > pidgin
annotate src/gtkconv.c @ 14154:c55e46e26781
[gaim-migrate @ 16799]
Use the proper setting-name.
"seanegan: sadrul: Looks good. You may want to set the non-global-buddyicon account setting if use-global-buddyicon is not set"
Also, if the user sets the buddy-icon from a per-account box, it unsets the use-global-budduicon setting for that account.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 16 Aug 2006 19:38:57 +0000 |
parents | 7f276f375789 |
children | ff3db5cdeb9f |
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); |
13965 | 157 static void add_chat_buddy_common(GaimConversation *conv, GaimConvChatBuddy *cb, const char *old_name); |
9605 | 158 static gboolean tab_complete(GaimConversation *conv); |
11604 | 159 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); |
11613 | 160 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); |
10810 | 161 static void update_typing_icon(GaimGtkConversation *gtkconv); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
162 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
|
163 gboolean gaim_gtkconv_has_focus(GaimConversation *conv); |
12335 | 164 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data); |
165 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
|
166 static GdkColor* generate_nick_colors(guint *numcolors, GdkColor background); |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
167 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
|
168 static void gaim_gtkconv_update_fields(GaimConversation *conv, GaimGtkConvFields fields); |
4359 | 169 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
170 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
171 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
172 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
173 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
174 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
175 col = nick_colors[g_str_hash(name) % nbr_nick_colors]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
176 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
177 (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
|
178 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
179 /* 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
|
180 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
181 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
182 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
183 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
184 } |
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 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
187 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
188 |
4359 | 189 /************************************************************************** |
190 * Callbacks | |
191 **************************************************************************/ | |
10971 | 192 |
4359 | 193 static gint |
10810 | 194 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 195 { |
14035 | 196 GList *list = g_list_copy(gtkconv->convs); |
197 | |
198 g_list_foreach(list, (GFunc)gaim_conversation_destroy, NULL); | |
10810 | 199 g_list_free(list); |
11508 | 200 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
201 return TRUE; |
4359 | 202 } |
203 | |
8914 | 204 static gboolean |
10810 | 205 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 206 { |
10810 | 207 GaimConversation *conv = gtkconv->active_conv; |
11508 | 208 |
8914 | 209 if (!GTK_WIDGET_VISIBLE(w)) |
210 return FALSE; | |
211 | |
212 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
213 return FALSE; | |
214 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
215 /* 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
|
216 * 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
|
217 * 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
|
218 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
219 /* 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
|
220 * negate it anyway. --luke */ |
11338 | 221 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 222 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
223 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
224 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
|
225 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
|
226 } |
8914 | 227 if (w == gtkconv->entry) |
228 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
229 } | |
11338 | 230 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 231 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
232 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
233 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
|
234 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
|
235 } |
8914 | 236 if (w == gtkconv->entry) |
237 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
238 } | |
239 | |
240 return FALSE; | |
241 } | |
242 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
243 static void |
10810 | 244 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
245 { |
10810 | 246 GaimConversation *conv = c->active_conv; |
11508 | 247 |
10665 | 248 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
249 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
250 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
251 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
252 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
253 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
|
254 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
255 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
256 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
|
257 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
259 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
|
260 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
261 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
262 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
264 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
266 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
267 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
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 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
|
270 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
271 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
272 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
273 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
274 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
275 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
276 fg_color.blue / 256); |
8061 | 277 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
278 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
279 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
280 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
281 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
282 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
283 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
284 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
285 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
286 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
287 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
288 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
289 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
290 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
291 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
292 bg_color.blue / 256); |
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 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
295 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
296 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
297 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
298 g_free(color); |
8677 | 299 |
9025 | 300 |
10665 | 301 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 302 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
303 else | |
304 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 305 } |
306 } | |
9130 | 307 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
308 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
309 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
310 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
311 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
312 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
313 |
9130 | 314 static const char * |
315 gaim_gtk_get_cmd_prefix(void) | |
316 { | |
317 return "/"; | |
318 } | |
319 | |
9167 | 320 static GaimCmdRet |
9829 | 321 say_command_cb(GaimConversation *conv, |
322 const char *cmd, char **args, char **error, void *data) | |
323 { | |
11338 | 324 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 325 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 326 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 327 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
328 | |
329 return GAIM_CMD_RET_OK; | |
330 } | |
331 | |
332 static GaimCmdRet | |
9167 | 333 me_command_cb(GaimConversation *conv, |
9597 | 334 const char *cmd, char **args, char **error, void *data) |
9167 | 335 { |
336 char *tmp; | |
337 | |
338 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 339 |
11338 | 340 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 341 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 342 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 343 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
344 | |
345 g_free(tmp); | |
346 return GAIM_CMD_RET_OK; | |
347 } | |
348 | |
9212 | 349 static GaimCmdRet |
350 debug_command_cb(GaimConversation *conv, | |
9597 | 351 const char *cmd, char **args, char **error, void *data) |
9212 | 352 { |
353 char *tmp, *markup; | |
354 GaimCmdStatus status; | |
355 | |
356 if (!g_ascii_strcasecmp(args[0], "version")) { | |
13369 | 357 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
|
358 markup = g_markup_escape_text(tmp, -1); |
9212 | 359 |
360 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
361 | |
362 g_free(tmp); | |
363 g_free(markup); | |
364 return status; | |
365 } else { | |
366 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
367 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
368 return GAIM_CMD_STATUS_OK; | |
369 } | |
370 } | |
371 | |
9213 | 372 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
373 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
374 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
375 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
376 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
377 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
378 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
379 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
380 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
381 return GAIM_CMD_STATUS_OK; |
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 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
384 static GaimCmdRet |
9213 | 385 help_command_cb(GaimConversation *conv, |
9597 | 386 const char *cmd, char **args, char **error, void *data) |
9213 | 387 { |
9597 | 388 GList *l, *text; |
9213 | 389 GString *s; |
9597 | 390 |
391 if (args[0] != NULL) { | |
392 s = g_string_new(""); | |
393 text = gaim_cmd_help(conv, args[0]); | |
394 | |
395 if (text) { | |
396 for (l = text; l; l = l->next) | |
397 if (l->next) | |
9816 | 398 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 399 else |
9816 | 400 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 401 } else { |
402 g_string_append(s, _("No such command (in this context).")); | |
403 } | |
404 } else { | |
405 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
406 "The following commands are available in this context:\n")); | |
407 | |
408 text = gaim_cmd_list(conv); | |
409 for (l = text; l; l = l->next) | |
9213 | 410 if (l->next) |
9597 | 411 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 412 else |
9597 | 413 g_string_append_printf(s, "%s.", (char *)l->data); |
13972
69496f235130
[gaim-migrate @ 16530]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
13969
diff
changeset
|
414 g_list_free(text); |
9213 | 415 } |
416 | |
417 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
418 g_string_free(s, TRUE); | |
419 | |
420 return GAIM_CMD_STATUS_OK; | |
421 } | |
422 | |
4359 | 423 static void |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
424 send_history_add(GaimGtkConversation *gtkconv, const char *message) |
9374 | 425 { |
426 GList *first; | |
427 | |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
428 first = g_list_first(gtkconv->send_history); |
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
429 g_free(first->data); |
9374 | 430 first->data = g_strdup(message); |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
431 gtkconv->send_history = g_list_prepend(first, NULL); |
9374 | 432 } |
433 | |
9832 | 434 static gboolean |
435 check_for_and_do_command(GaimConversation *conv) | |
436 { | |
437 GaimGtkConversation *gtkconv; | |
438 char *cmd; | |
439 const char *prefix; | |
440 GtkTextIter start; | |
441 | |
442 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
443 prefix = gaim_gtk_get_cmd_prefix(); | |
444 | |
445 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
446 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
447 | |
448 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
449 && !gtk_text_iter_get_child_anchor(&start)) { | |
450 GaimCmdStatus status; | |
451 char *error, *cmdline, *markup, *send_history; | |
452 GtkTextIter end; | |
453 | |
454 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
455 send_history_add(gtkconv, send_history); |
9832 | 456 g_free(send_history); |
457 | |
458 cmdline = cmd + strlen(prefix); | |
459 | |
460 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
461 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
462 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
463 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
464 g_free(cmd); | |
465 g_free(markup); | |
466 | |
467 switch (status) { | |
468 case GAIM_CMD_STATUS_OK: | |
469 return TRUE; | |
470 case GAIM_CMD_STATUS_NOT_FOUND: | |
471 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
472 gaim_conversation_write(conv, "", _("No such command."), | |
473 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
474 | |
475 return TRUE; | |
476 } | |
477 return FALSE; | |
478 case GAIM_CMD_STATUS_WRONG_ARGS: | |
479 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
480 "to that command."), | |
481 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
482 return TRUE; | |
483 case GAIM_CMD_STATUS_FAILED: | |
484 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
485 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
14035 | 486 g_free(error); |
9832 | 487 return TRUE; |
488 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 489 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 490 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 491 GAIM_MESSAGE_NO_LOG, time(NULL)); |
492 else | |
10843 | 493 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 494 GAIM_MESSAGE_NO_LOG, time(NULL)); |
495 return TRUE; | |
496 case GAIM_CMD_STATUS_WRONG_PRPL: | |
497 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
498 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
499 return TRUE; | |
500 } | |
501 } | |
502 | |
503 g_free(cmd); | |
504 return FALSE; | |
505 } | |
506 | |
9374 | 507 static void |
10810 | 508 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 509 { |
10810 | 510 GaimConversation *conv = gtkconv->active_conv; |
8655 | 511 GaimAccount *account; |
8677 | 512 GaimConnection *gc; |
12216 | 513 GaimMessageFlags flags = 0; |
8448 | 514 char *buf, *clean; |
4359 | 515 |
8655 | 516 account = gaim_conversation_get_account(conv); |
9130 | 517 |
9471 | 518 if (!gaim_account_is_connected(account)) |
519 return; | |
520 | |
11338 | 521 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 522 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 523 return; |
524 | |
9832 | 525 if (check_for_and_do_command(conv)) { |
526 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
527 return; | |
9130 | 528 } |
529 | |
8442 | 530 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 531 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 532 |
4359 | 533 gtk_widget_grab_focus(gtkconv->entry); |
534 | |
8448 | 535 if (strlen(clean) == 0) { |
13782
f4f68315a07a
[gaim-migrate @ 16194]
Richard Laager <rlaager@wiktel.com>
parents:
13781
diff
changeset
|
536 g_free(buf); |
8448 | 537 g_free(clean); |
4359 | 538 return; |
539 } | |
540 | |
12272 | 541 gaim_idle_touch(); |
542 | |
12216 | 543 /* XXX: is there a better way to tell if the message has images? */ |
544 if (GTK_IMHTML(gtkconv->entry)->im_images != NULL) | |
545 flags |= GAIM_MESSAGE_IMAGES; | |
546 | |
8677 | 547 gc = gaim_account_get_connection(account); |
10665 | 548 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 549 char **bufs; |
550 int i; | |
551 | |
552 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
553 for (i = 0; bufs[i]; i++) { | |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
554 send_history_add(gtkconv, bufs[i]); |
11338 | 555 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 556 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), bufs[i], flags); |
11338 | 557 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 558 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), bufs[i], flags); |
8677 | 559 } |
560 | |
561 g_strfreev(bufs); | |
562 | |
563 } else { | |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
564 send_history_add(gtkconv, buf); |
11338 | 565 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 566 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), buf, flags); |
11338 | 567 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 568 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), buf, flags); |
8677 | 569 } |
4359 | 570 |
8677 | 571 g_free(clean); |
4359 | 572 g_free(buf); |
573 | |
8061 | 574 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 575 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 576 } |
577 | |
578 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
579 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 580 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
581 GaimAccount *account; |
4359 | 582 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
583 GaimConversation *conv = gtkconv->active_conv; |
4359 | 584 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
585 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
586 name = gaim_conversation_get_name(conv); |
7879 | 587 |
11338 | 588 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 589 GaimBuddy *b; |
590 | |
591 b = gaim_find_buddy(account, name); | |
592 if (b != NULL) | |
9730 | 593 gaim_gtkdialogs_remove_buddy(b); |
7859 | 594 else if (account != NULL && gaim_account_is_connected(account)) |
595 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 596 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 597 GaimChat *c; |
598 | |
599 c = gaim_blist_find_chat(account, name); | |
600 if (c != NULL) | |
9730 | 601 gaim_gtkdialogs_remove_chat(c); |
7859 | 602 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 603 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 604 } |
4359 | 605 |
606 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
607 } | |
608 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
609 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 610 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
611 GaimConversation *conv = gtkconv->active_conv; |
7975 | 612 GaimPluginProtocolInfo *prpl_info = NULL; |
613 GaimConnection *gc; | |
614 | |
615 if ((gc = gaim_conversation_get_gc(conv))) { | |
616 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
617 | |
618 /* | |
619 * If there are special needs for getting info on users in | |
620 * buddy chat "rooms"... | |
621 */ | |
622 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
623 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
624 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
625 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
626 } |
7975 | 627 else |
628 prpl_info->get_info(gc, who); | |
629 } | |
630 } | |
631 | |
632 | |
4359 | 633 static void |
10810 | 634 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 635 { |
10810 | 636 GaimConversation *conv = gtkconv->active_conv; |
4359 | 637 |
11338 | 638 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 639 serv_get_info(gaim_conversation_get_gc(conv), |
640 gaim_conversation_get_name(conv)); | |
641 | |
642 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 643 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 644 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
645 GaimGtkChatPane *gtkchat; |
4359 | 646 GtkTreeIter iter; |
647 GtkTreeModel *model; | |
648 GtkTreeSelection *sel; | |
9554 | 649 char *name; |
4359 | 650 |
651 gtkchat = gtkconv->u.chat; | |
652 | |
653 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
654 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
655 | |
656 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 657 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 658 else |
659 return; | |
660 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
661 chat_do_info(gtkconv, name); |
9554 | 662 g_free(name); |
4359 | 663 } |
664 } | |
665 | |
666 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
667 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 668 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
669 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
670 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
671 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
672 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
673 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
674 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
675 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 676 |
677 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
678 } | |
679 | |
680 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
681 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 682 { |
683 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
684 GaimGtkConversation *gtkconv; |
4359 | 685 |
686 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
687 | |
688 if (resp == GTK_RESPONSE_OK) { | |
689 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
690 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
691 | |
10113 | 692 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 693 return; |
694 | |
695 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
696 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 697 message, buddy); |
698 } | |
699 | |
700 gtk_widget_destroy(invite_dialog); | |
701 invite_dialog = NULL; | |
702 | |
703 g_free(info); | |
704 } | |
705 | |
706 static void | |
9909 | 707 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
708 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
709 { | |
710 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
711 const char *convprotocol; | |
712 | |
713 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
714 | |
715 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
716 { | |
717 GaimBlistNode *node = NULL; | |
718 GaimBuddy *buddy; | |
719 | |
720 memcpy(&node, sd->data, sizeof(node)); | |
721 | |
722 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
723 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
724 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
725 buddy = (GaimBuddy *)node; | |
726 else | |
727 return; | |
728 | |
729 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
730 { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
731 gaim_notify_error(GAIM_GTK_CONVERSATION(info->conv), NULL, |
9909 | 732 _("That buddy is not on the same protocol as this " |
10843 | 733 "chat."), NULL); |
9909 | 734 } |
735 else | |
736 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
737 | |
738 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
739 } | |
740 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
741 { | |
742 char *protocol = NULL; | |
743 char *username = NULL; | |
744 GaimAccount *account; | |
745 | |
11137 | 746 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 747 &protocol, &username, NULL)) |
748 { | |
749 if (account == NULL) | |
750 { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
751 gaim_notify_error(GAIM_GTK_CONVERSATION(info->conv), NULL, |
9909 | 752 _("You are not currently signed on with an account that " |
753 "can invite that buddy."), NULL); | |
754 } | |
755 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
756 { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
757 gaim_notify_error(GAIM_GTK_CONVERSATION(info->conv), NULL, |
9909 | 758 _("That buddy is not on the same protocol as this " |
10843 | 759 "chat."), NULL); |
9909 | 760 } |
761 else | |
762 { | |
763 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
764 } | |
765 } | |
766 | |
14035 | 767 g_free(username); |
768 g_free(protocol); | |
9909 | 769 |
770 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
771 } | |
772 } | |
773 | |
774 static const GtkTargetEntry dnd_targets[] = | |
775 { | |
776 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
777 {"application/x-im-contact", 0, 1} | |
778 }; | |
779 | |
780 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
781 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 782 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
783 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
784 InviteBuddyInfo *info = NULL; |
4359 | 785 |
786 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
787 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
788 GaimGtkWindow *gtkwin; |
4359 | 789 GtkWidget *label; |
790 GtkWidget *vbox, *hbox; | |
791 GtkWidget *table; | |
792 GtkWidget *img; | |
793 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
794 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 795 GTK_ICON_SIZE_DIALOG); |
4359 | 796 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
797 info = g_new0(InviteBuddyInfo, 1); |
4359 | 798 info->conv = conv; |
799 | |
11581 | 800 gc = gaim_conversation_get_gc(conv); |
801 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 802 |
803 /* Create the new dialog. */ | |
804 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 805 _("Invite Buddy Into Chat Room"), |
7879 | 806 GTK_WINDOW(gtkwin->window), 0, |
807 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
808 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 809 |
810 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 811 GTK_RESPONSE_OK); |
11243 | 812 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 813 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
814 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
815 | |
9909 | 816 info->window = GTK_WIDGET(invite_dialog); |
817 | |
4359 | 818 /* Setup the outside spacing. */ |
819 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
820 | |
11243 | 821 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
822 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 823 |
824 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 825 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 826 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
827 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
828 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
829 | |
830 /* Setup the right vbox. */ | |
831 vbox = gtk_vbox_new(FALSE, 0); | |
832 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
833 | |
834 /* Put our happy label in it. */ | |
835 label = gtk_label_new(_("Please enter the name of the user you wish " | |
836 "to invite, along with an optional invite " | |
837 "message.")); | |
838 gtk_widget_set_size_request(label, 350, -1); | |
839 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
840 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
841 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
842 | |
843 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 844 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 845 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
846 | |
847 /* Setup the table we're going to use to lay stuff out. */ | |
848 table = gtk_table_new(2, 2, FALSE); | |
11243 | 849 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
850 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
851 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 852 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
853 | |
854 /* Now the Buddy label */ | |
855 label = gtk_label_new(NULL); | |
856 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
857 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
858 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
859 | |
860 /* Now the Buddy drop-down entry field. */ | |
861 info->entry = gtk_combo_new(); | |
862 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
863 gtk_entry_set_activates_default( | |
864 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
865 | |
866 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
867 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
868 | |
869 /* Fill in the names. */ | |
870 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
871 generate_invite_user_names(gc)); | |
872 | |
873 | |
874 /* Now the label for "Message" */ | |
875 label = gtk_label_new(NULL); | |
876 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
877 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
878 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
879 | |
880 | |
881 /* And finally, the Message entry field. */ | |
882 info->message = gtk_entry_new(); | |
883 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
884 | |
885 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
886 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
887 | |
888 /* Connect the signals. */ | |
889 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
890 G_CALLBACK(do_invite), info); | |
9909 | 891 /* Setup drag-and-drop */ |
892 gtk_drag_dest_set(info->window, | |
893 GTK_DEST_DEFAULT_MOTION | | |
894 GTK_DEST_DEFAULT_DROP, | |
895 dnd_targets, | |
896 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
897 GDK_ACTION_COPY); | |
898 gtk_drag_dest_set(info->entry, | |
899 GTK_DEST_DEFAULT_MOTION | | |
900 GTK_DEST_DEFAULT_DROP, | |
901 dnd_targets, | |
902 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
903 GDK_ACTION_COPY); | |
904 | |
905 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
906 G_CALLBACK(invite_dnd_recv), info); | |
907 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
908 G_CALLBACK(invite_dnd_recv), info); | |
909 | |
4359 | 910 } |
911 | |
912 gtk_widget_show_all(invite_dialog); | |
913 | |
914 if (info != NULL) | |
915 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
916 } | |
917 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
918 static void |
7748 | 919 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
920 { | |
9714 | 921 gaim_gtkdialogs_im(); |
7748 | 922 } |
923 | |
924 static void | |
9504 | 925 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 926 { |
9504 | 927 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 928 FILE *fp; |
929 const char *name; | |
10849 | 930 gchar *text; |
9489 | 931 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
932 if ((fp = g_fopen(filename, "w+")) == NULL) { |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
933 gaim_notify_error(GAIM_GTK_CONVERSATION(conv), NULL, _("Unable to open file."), NULL); |
9489 | 934 return; |
935 } | |
936 | |
937 name = gaim_conversation_get_name(conv); | |
10849 | 938 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 939 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 940 |
941 text = gtk_imhtml_get_markup( | |
942 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
943 fprintf(fp, "%s", text); | |
944 g_free(text); | |
945 | |
946 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 947 fclose(fp); |
948 } | |
949 | |
10849 | 950 /* |
951 * It would be kinda cool if this gave the option of saving a | |
952 * plaintext v. HTML file. | |
953 */ | |
9489 | 954 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
955 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
956 { |
11581 | 957 GaimGtkWindow *win = data; |
958 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 959 gchar *buf; |
960 | |
961 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 962 |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
963 gaim_request_file(GAIM_GTK_CONVERSATION(conv), _("Save Conversation"), |
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
964 gaim_escape_filename(buf), |
10849 | 965 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); |
9489 | 966 |
967 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
968 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
969 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
970 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
971 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
972 { |
11581 | 973 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
974 GaimConversation *conv; |
9917 | 975 GaimLogType type; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
976 GaimGtkBuddyList *gtkblist; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
977 GdkCursor *cursor; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
978 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
979 GaimAccount *account; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
980 GSList *buddies; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
981 GSList *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
982 |
11581 | 983 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
984 |
11338 | 985 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 986 type = GAIM_LOG_IM; |
11338 | 987 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 988 type = GAIM_LOG_CHAT; |
989 else | |
990 return; | |
991 | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
992 gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13424
diff
changeset
|
993 |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
994 cursor = gdk_cursor_new(GDK_WATCH); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
995 gdk_window_set_cursor(gtkblist->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
996 gdk_window_set_cursor(win->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
997 gdk_cursor_unref(cursor); |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13424
diff
changeset
|
998 #if GTK_CHECK_VERSION(2,4,0) |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13424
diff
changeset
|
999 gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window))); |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13424
diff
changeset
|
1000 #else |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13424
diff
changeset
|
1001 gdk_flush(); |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13424
diff
changeset
|
1002 #endif |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1003 |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1004 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1005 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1006 |
10845 | 1007 buddies = gaim_find_buddies(account, name); |
1008 for (cur = buddies; cur != NULL; cur = cur->next) | |
1009 { | |
1010 GaimBlistNode *node = cur->data; | |
10846 | 1011 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 1012 { |
1013 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
1014 g_slist_free(buddies); | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1015 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1016 gdk_window_set_cursor(win->window->window, NULL); |
10845 | 1017 return; |
1018 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1019 } |
10845 | 1020 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1021 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1022 gaim_gtk_log_show(type, name, account); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1023 |
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); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1026 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1027 |
8974 | 1028 static void |
1029 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
1030 { | |
11581 | 1031 GaimGtkWindow *win = data; |
8974 | 1032 GaimConversation *conv; |
1033 GaimGtkConversation *gtkconv; | |
1034 | |
11581 | 1035 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 1036 gtkconv = GAIM_GTK_CONVERSATION(conv); |
1037 | |
1038 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1039 } | |
1040 | |
7295 | 1041 struct _search { |
1042 GaimGtkConversation *gtkconv; | |
1043 GtkWidget *entry; | |
1044 }; | |
1045 | |
7929 | 1046 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 1047 { |
7929 | 1048 switch (resp) { |
1049 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1050 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1051 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1052 break; |
1053 | |
1054 case GTK_RESPONSE_DELETE_EVENT: | |
1055 case GTK_RESPONSE_CLOSE: | |
1056 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1057 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1058 s->gtkconv->dialogs.search = NULL; | |
1059 g_free(s); | |
1060 break; | |
1061 } | |
7295 | 1062 } |
1063 | |
1064 static void | |
7751 | 1065 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1066 { |
11581 | 1067 GaimGtkWindow *gtkwin = data; |
1068 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1069 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1070 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1071 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1072 GTK_ICON_SIZE_DIALOG); |
7929 | 1073 GtkWidget *label; |
7295 | 1074 struct _search *s; |
1075 | |
7798 | 1076 if (gtkconv->dialogs.search) { |
1077 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1078 return; |
7798 | 1079 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1080 |
7295 | 1081 s = g_malloc(sizeof(struct _search)); |
1082 s->gtkconv = gtkconv; | |
7929 | 1083 |
1084 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1085 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1086 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1087 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1088 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1089 GTK_RESPONSE_OK); |
7929 | 1090 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1091 G_CALLBACK(do_search_cb), s); | |
1092 | |
11243 | 1093 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1094 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1095 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1096 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
|
1097 gtk_container_set_border_width( |
11243 | 1098 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1099 | |
1100 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1101 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1102 hbox); |
7929 | 1103 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1104 | |
1105 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1106 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1107 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1108 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1109 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1110 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1111 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1112 | |
1113 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1114 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1115 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1116 g_signal_connect(G_OBJECT(s->entry), "changed", |
1117 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1118 gtkconv->dialogs.search); | |
1119 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
|
1120 |
7295 | 1121 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1122 gtk_widget_grab_focus(s->entry); |
7295 | 1123 } |
1124 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1125 static void |
9468 | 1126 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1127 { | |
11581 | 1128 GaimGtkWindow *win = data; |
1129 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1130 |
11338 | 1131 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1132 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1133 } | |
1134 | |
1135 } | |
1136 | |
1137 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1138 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1139 { |
11581 | 1140 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1141 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1142 |
11581 | 1143 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
|
1144 |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1145 gaim_gtk_pounce_editor_show(gaim_conversation_get_account(conv), |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1146 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1147 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1148 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1149 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1150 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1151 { |
11581 | 1152 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1153 GaimGtkConversation *gtkconv; |
8756 | 1154 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1155 |
11581 | 1156 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1157 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1158 | |
1159 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1160 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1161 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1162 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1163 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1164 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1165 { |
11581 | 1166 GaimGtkWindow *win = data; |
8756 | 1167 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1168 GaimGtkConversation *gtkconv; |
8756 | 1169 GtkIMHtmlToolbar *toolbar; |
1170 | |
11581 | 1171 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1172 conv = gtkconv->active_conv; | |
8756 | 1173 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1174 | |
1175 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1176 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1177 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1178 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1179 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1180 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1181 { |
11581 | 1182 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1183 GaimConversation *conv; |
7879 | 1184 GaimAccount *account; |
1185 const char *name; | |
1186 | |
11581 | 1187 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1188 account = gaim_conversation_get_account(conv); |
1189 name = gaim_conversation_get_name(conv); | |
1190 | |
11338 | 1191 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1192 GaimBuddy *b; |
1193 | |
1194 b = gaim_find_buddy(account, name); | |
1195 if (b != NULL) | |
9730 | 1196 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1197 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1198 GaimChat *c; |
1199 | |
1200 c = gaim_blist_find_chat(account, name); | |
1201 if (c != NULL) | |
9730 | 1202 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1203 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1204 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1205 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1206 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1207 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1208 { |
11581 | 1209 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1210 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 |
11581 | 1212 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 |
10810 | 1214 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1216 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1218 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1219 { |
11581 | 1220 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1221 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1222 |
11581 | 1223 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1224 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1225 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1226 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1227 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1228 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1229 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1230 { |
11581 | 1231 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1232 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1233 |
11581 | 1234 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1235 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1236 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1237 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1238 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1239 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1240 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1241 { |
11581 | 1242 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1243 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1244 |
11581 | 1245 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1246 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1247 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1248 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1249 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1250 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1251 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1252 { |
11581 | 1253 GaimGtkWindow *win = data; |
1254 | |
1255 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
|
1256 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1257 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1258 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1259 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1260 { |
11581 | 1261 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1262 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1263 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1264 |
11581 | 1265 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1266 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1267 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1268 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1269 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1270 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
|
1271 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1272 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1273 return; |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1274 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1275 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1276 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1277 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1278 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1279 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1280 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1281 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1282 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1283 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1284 time(NULL)); |
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 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1287 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1288 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1289 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1290 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1291 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1292 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1293 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1294 /* 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
|
1295 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1296 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1297 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1298 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1299 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1300 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1301 { |
10377 | 1302 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1303 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
|
1304 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1305 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1306 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1307 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 { |
11581 | 1309 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1310 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1311 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1312 |
11581 | 1313 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1314 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1315 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1316 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1317 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1318 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1319 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1320 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1321 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1322 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1323 |
7961 | 1324 static void |
9188 | 1325 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1326 { | |
12188 | 1327 gaim_prefs_set_bool("/gaim/gtk/conversations/show_timestamps", |
9188 | 1328 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
1329 } | |
1330 | |
1331 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1332 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1333 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1334 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1335 GaimAccount *account; |
1336 GaimConnection *gc; | |
7961 | 1337 GaimPluginProtocolInfo *prpl_info = NULL; |
1338 char *real_who; | |
1339 | |
1340 account = gaim_conversation_get_account(conv); | |
10431 | 1341 g_return_if_fail(account != NULL); |
1342 | |
1343 gc = gaim_account_get_connection(account); | |
1344 g_return_if_fail(gc != NULL); | |
1345 | |
1346 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1347 | |
1348 if (prpl_info && prpl_info->get_cb_real_name) | |
1349 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1350 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1351 else | |
1352 real_who = g_strdup(who); | |
1353 | |
1354 if(!real_who) | |
1355 return; | |
1356 | |
10431 | 1357 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1358 |
1359 g_free(real_who); | |
1360 } | |
1361 | |
1362 static void | |
10810 | 1363 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1364 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1365 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1366 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1367 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1368 GtkTreeSelection *sel; |
9554 | 1369 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1370 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1371 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1372 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1373 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1374 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1375 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1376 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1377 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
|
1378 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1379 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1380 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1381 chat_do_im(gtkconv, name); |
9554 | 1382 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1383 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1384 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1385 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1386 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1387 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1388 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1389 GaimGtkChatPane *gtkchat; |
13965 | 1390 GaimConvChatBuddy *cbuddy; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1391 GaimConvChat *chat; |
11869 | 1392 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1393 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1394 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1395 GtkTreeSelection *sel; |
10504 | 1396 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1397 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1398 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1399 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 gtkchat = gtkconv->u.chat; |
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 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1403 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1404 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1405 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1406 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1407 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1408 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1409 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1410 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1411 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1412 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1413 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1414 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1415 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1416 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1417 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1418 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1419 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1420 |
13965 | 1421 cbuddy = gaim_conv_chat_cb_new(name, alias, flags); |
14035 | 1422 |
13965 | 1423 add_chat_buddy_common(conv, cbuddy, NULL); |
10504 | 1424 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1425 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1426 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1427 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1428 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1429 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1430 { |
1431 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1432 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1433 chat_do_im(gtkconv, who); |
5908
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 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1436 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1437 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1438 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1439 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1440 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1441 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1442 | |
1443 serv_send_file(gc, who, NULL); | |
1444 } | |
1445 | |
1446 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1447 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1448 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1449 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1450 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1451 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1452 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1453 chat_do_info(gtkconv, who); |
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_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1458 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1459 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1460 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1461 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1462 char *who; |
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 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1465 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1466 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1467 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1468 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1469 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1470 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1471 * 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
|
1472 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1473 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1474 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1475 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1476 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1477 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1478 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1479 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1480 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1481 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1482 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1483 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1484 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1485 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1486 GaimAccount *account; |
6695 | 1487 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1488 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1489 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1490 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1491 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1492 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1493 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1494 if (b != NULL) |
9730 | 1495 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1496 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1497 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
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 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
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 |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1502 static GtkTextMark * |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1503 get_mark_for_user(GaimGtkConversation *gtkconv, const char *who) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1504 { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1505 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
|
1506 char *tmp = g_strconcat("user:", who, NULL); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1507 GtkTextMark *mark = gtk_text_buffer_get_mark(buf, tmp); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1508 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1509 g_free(tmp); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1510 return mark; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1511 } |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1512 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1513 static void |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1514 menu_last_said_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1515 { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1516 GtkTextMark *mark; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1517 const char *who; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1518 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1519 who = g_object_get_data(G_OBJECT(w), "user_data"); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1520 mark = get_mark_for_user(gtkconv, who); |
14035 | 1521 |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1522 if (mark != NULL) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1523 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
|
1524 else |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1525 g_return_if_reached(); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1526 } |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1527 |
8143 | 1528 static GtkWidget * |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1529 create_chat_menu(GaimConversation *conv, const char *who, GaimConnection *gc) |
8143 | 1530 { |
1531 static GtkWidget *menu = NULL; | |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1532 GaimPluginProtocolInfo *prpl_info = NULL; |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1533 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1534 gboolean is_me = FALSE; |
8143 | 1535 GtkWidget *button; |
13781
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
1536 GaimBuddy *buddy = NULL; |
8143 | 1537 |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1538 if (gc != NULL) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1539 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1540 |
8143 | 1541 /* |
1542 * If a menu already exists, destroy it before creating a new one, | |
1543 * thus freeing-up the memory it occupied. | |
1544 */ | |
1545 if (menu) | |
1546 gtk_widget_destroy(menu); | |
1547 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1548 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1549 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1550 |
8143 | 1551 menu = gtk_menu_new(); |
1552 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1553 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1554 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1555 G_CALLBACK(menu_chat_im_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1556 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1557 if (gc == NULL) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1558 gtk_widget_set_sensitive(button, FALSE); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1559 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1560 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1561 |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1562 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1563 if (prpl_info && prpl_info->send_file) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1564 { |
11508 | 1565 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1566 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1567 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1568 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1569 if (gc == NULL || prpl_info == NULL || |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1570 !(!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1571 { |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1572 gtk_widget_set_sensitive(button, FALSE); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1573 } |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1574 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1575 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
|
1576 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1577 |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1578 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1579 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
|
1580 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
|
1581 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1582 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1583 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1584 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1585 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1586 if (gc == NULL) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1587 gtk_widget_set_sensitive(button, FALSE); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1588 |
10504 | 1589 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1590 } |
9498 | 1591 |
13445 | 1592 if (prpl_info && (prpl_info->get_info || prpl_info->get_cb_info)) { |
10221 | 1593 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
|
1594 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1595 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1596 if (gc == NULL) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1597 gtk_widget_set_sensitive(button, FALSE); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1598 |
10504 | 1599 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1600 } |
1601 | |
13445 | 1602 if (prpl_info && prpl_info->get_cb_away) { |
10221 | 1603 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
|
1604 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1605 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1606 if (gc == NULL) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1607 gtk_widget_set_sensitive(button, FALSE); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1608 |
10504 | 1609 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1610 } |
1611 | |
13457
1eed4ec0912d
[gaim-migrate @ 15832]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
13445
diff
changeset
|
1612 if (!is_me && prpl_info && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
13781
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
1613 if ((buddy = gaim_find_buddy(conv->account, who)) != NULL) |
10221 | 1614 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
|
1615 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1616 else |
10221 | 1617 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
|
1618 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1619 |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1620 if (gc == NULL) |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1621 gtk_widget_set_sensitive(button, FALSE); |
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1622 |
10504 | 1623 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1624 } |
1625 | |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1626 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
|
1627 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
|
1628 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
|
1629 if (!get_mark_for_user(GAIM_GTK_CONVERSATION(conv), who)) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1630 gtk_widget_set_sensitive(button, FALSE); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1631 |
13781
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
1632 if (buddy != NULL) |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
1633 { |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
1634 if (gaim_account_is_connected(conv->account)) |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
1635 gaim_gtk_append_blist_node_proto_menu(menu, conv->account->gc, |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
1636 (GaimBlistNode *)buddy); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
1637 gaim_gtk_append_blist_node_extended_menu(menu, (GaimBlistNode *)buddy); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
1638 gtk_widget_show_all(menu); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
1639 } |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
1640 |
8143 | 1641 return menu; |
1642 } | |
1643 | |
1644 | |
1645 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1646 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1647 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1648 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1649 GaimGtkChatPane *gtkchat; |
1650 GaimConnection *gc; | |
1651 GaimAccount *account; | |
1652 GtkTreeSelection *sel; | |
1653 GtkTreeIter iter; | |
1654 GtkTreeModel *model; | |
1655 GtkWidget *menu; | |
1656 gchar *who; | |
1657 | |
1658 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1659 gtkchat = gtkconv->u.chat; | |
1660 account = gaim_conversation_get_account(conv); | |
1661 gc = account->gc; | |
1662 | |
1663 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1664 | |
1665 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1666 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1667 return FALSE; | |
1668 | |
9498 | 1669 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1670 menu = create_chat_menu (conv, who, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1671 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1672 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1673 0, GDK_CURRENT_TIME); |
10504 | 1674 g_free(who); |
8143 | 1675 |
1676 return TRUE; | |
1677 } | |
1678 | |
1679 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1680 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1681 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1682 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1683 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1684 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1685 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1686 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1687 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1688 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1689 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1690 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1691 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1692 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1693 int 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 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1696 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1697 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1698 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1699 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
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_view_get_path_at_pos(GTK_TREE_VIEW(gtkchat->list), |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1702 event->x, event->y, &path, &column, &x, &y); |
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 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1705 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1706 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1707 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1708 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1709 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1710 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1711 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
|
1712 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1713 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1714 chat_do_im(gtkconv, who); |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1715 } else if (event->button == 2 && event->type == GDK_BUTTON_PRESS) { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1716 /* Move to user's anchor */ |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1717 GtkTextMark *mark = get_mark_for_user(gtkconv, who); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1718 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1719 if(mark != NULL) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
1720 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(gtkconv->imhtml), mark, 0.1, FALSE, 0, 0); |
7398 | 1721 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
1722 GtkWidget *menu = create_chat_menu (conv, who, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1723 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1724 event->button, event->time); |
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 |
10504 | 1727 g_free(who); |
1728 gtk_tree_path_free(path); | |
1729 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1730 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1731 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1732 |
8133 | 1733 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1734 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1735 { |
10827 | 1736 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1737 GaimGtkWindow *win; |
13714
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1738 int initial, i, total, diff; |
8133 | 1739 |
11581 | 1740 win = gtkconv->win; |
13714
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1741 initial = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1742 gtkconv->tab_cont); |
11581 | 1743 total = gaim_gtk_conv_window_get_gtkconv_count(win); |
13714
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1744 /* By adding total here, the moduli calculated later will always have two |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1745 * positive arguments. x % y where x < 0 is not guaranteed to return a |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1746 * positive number. |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1747 */ |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1748 diff = (forward ? 1 : -1) + total; |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1749 |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1750 for (i = (initial + diff) % total; i != initial; i = (i + diff) % total) { |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1751 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1752 if (next_gtkconv->unseen_state > 0) |
13714
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1753 break; |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1754 } |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1755 |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1756 if (i == initial) { /* no new messages */ |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1757 i = (i + diff) % total; |
4cf1db3ffada
[gaim-migrate @ 16122]
Richard Laager <rlaager@wiktel.com>
parents:
13690
diff
changeset
|
1758 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i); |
8133 | 1759 } |
1760 | |
10827 | 1761 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1762 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1763 } |
1764 | |
4359 | 1765 static gboolean |
8105 | 1766 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1767 { |
11581 | 1768 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1769 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1770 GaimGtkConversation *gtkconv; |
8105 | 1771 int curconv; |
1772 | |
10810 | 1773 gtkconv = (GaimGtkConversation *)data; |
10849 | 1774 conv = gtkconv->active_conv; |
11581 | 1775 win = gtkconv->win; |
1776 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1777 |
8105 | 1778 /* If CTRL was held down... */ |
1779 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1780 switch (event->keyval) { |
1781 case GDK_Up: | |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
1782 if (!gtkconv->send_history) |
4359 | 1783 break; |
1784 | |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
1785 if (!gtkconv->send_history->prev) { |
4359 | 1786 GtkTextIter start, end; |
1787 | |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
1788 g_free(gtkconv->send_history->data); |
4359 | 1789 |
1790 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1791 &start); | |
1792 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1793 | |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
1794 gtkconv->send_history->data = |
8506 | 1795 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1796 } |
8677 | 1797 |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
1798 if (gtkconv->send_history->next && gtkconv->send_history->next->data) { |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1799 GObject *object; |
8677 | 1800 GtkTextIter iter; |
1801 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1802 |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
1803 gtkconv->send_history = gtkconv->send_history->next; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1804 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1805 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1806 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1807 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
|
1808 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1809 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1810 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1811 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1812 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
|
1813 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1814 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1815 |
8061 | 1816 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1817 gtk_imhtml_append_text_with_images( |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
1818 GTK_IMHTML(gtkconv->entry), gtkconv->send_history->data, |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1819 0, NULL); |
8677 | 1820 /* this is mainly just a hack so the formatting at the |
1821 * cursor gets picked up. */ | |
1822 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1823 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1824 } |
1825 | |
8105 | 1826 return TRUE; |
4359 | 1827 break; |
1828 | |
1829 case GDK_Down: | |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
1830 if (!gtkconv->send_history) |
4359 | 1831 break; |
1832 | |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
1833 if (gtkconv->send_history->prev && gtkconv->send_history->prev->data) { |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1834 GObject *object; |
8677 | 1835 GtkTextIter iter; |
1836 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1837 |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
1838 gtkconv->send_history = gtkconv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1839 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1840 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1841 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1842 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
|
1843 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1844 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1845 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1846 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1847 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
|
1848 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1849 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1850 |
8105 | 1851 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1852 gtk_imhtml_append_text_with_images( |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
1853 GTK_IMHTML(gtkconv->entry), gtkconv->send_history->data, |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1854 0, NULL); |
8677 | 1855 /* this is mainly just a hack so the formatting at the |
1856 * cursor gets picked up. */ | |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
1857 if (*(char *)gtkconv->send_history->data) { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1858 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1859 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1860 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1861 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1862 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1863 } |
4359 | 1864 } |
1865 | |
8105 | 1866 return TRUE; |
4359 | 1867 break; |
8105 | 1868 |
13354
da2179c099f0
[gaim-migrate @ 15726]
Richard Laager <rlaager@wiktel.com>
parents:
13352
diff
changeset
|
1869 case GDK_Page_Down: |
8143 | 1870 case ']': |
11581 | 1871 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1872 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1873 else |
11581 | 1874 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1875 return TRUE; |
1876 break; | |
1877 | |
13354
da2179c099f0
[gaim-migrate @ 15726]
Richard Laager <rlaager@wiktel.com>
parents:
13352
diff
changeset
|
1878 case GDK_Page_Up: |
8143 | 1879 case '[': |
11581 | 1880 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1881 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1882 else |
11581 | 1883 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1884 return TRUE; |
1885 break; | |
1886 | |
8108 | 1887 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1888 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1889 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1890 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1891 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1892 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1893 } |
8108 | 1894 |
1895 return TRUE; | |
1896 break; | |
1897 | |
11252 | 1898 case GDK_comma: |
11581 | 1899 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1900 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1901 curconv - 1); |
1902 break; | |
1903 | |
1904 case GDK_period: | |
11581 | 1905 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1906 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1907 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1908 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1909 #else |
1910 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1911 #endif | |
11252 | 1912 break; |
1913 | |
8105 | 1914 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1915 } |
8758 | 1916 |
8105 | 1917 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1918 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1919 { |
10864 | 1920 if (event->keyval > '0' && event->keyval <= '9') |
1921 { | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1922 guint switchto = event->keyval - '1'; |
11581 | 1923 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1924 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1925 |
1926 return TRUE; | |
1927 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1928 } |
8758 | 1929 |
8105 | 1930 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1931 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1932 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1933 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1934 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1935 case GDK_Tab: |
9605 | 1936 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1937 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1938 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1939 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1940 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1941 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1942 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1943 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1944 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1945 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1946 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1947 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1948 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1949 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1950 } |
4359 | 1951 return FALSE; |
1952 } | |
1953 | |
1954 /* | |
1955 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1956 * 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
|
1957 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1958 * 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
|
1959 * going all the way down to the notebook. I suspect a bug in |
4359 | 1960 * GtkTextView, but I'm not ready to point any fingers yet. |
1961 */ | |
1962 static gboolean | |
1963 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1964 { | |
1965 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1966 /* Right single click */ | |
1967 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1968 | |
1969 return TRUE; | |
1970 } | |
1971 | |
1972 return FALSE; | |
1973 } | |
1974 | |
8173 | 1975 /* |
1976 * If someone tries to type into the conversation backlog of a | |
1977 * conversation window then we yank focus from the conversation backlog | |
1978 * and give it to the text entry box so that people can type | |
1979 * all the live long day and it will get entered into the entry box. | |
1980 */ | |
6057 | 1981 static gboolean |
8105 | 1982 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1983 { |
1984 GaimGtkConversation *gtkconv = data; | |
1985 | |
8237 | 1986 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1987 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1988 (event->keyval == GDK_F10) || |
1989 (event->keyval == GDK_Shift_L) || | |
1990 (event->keyval == GDK_Shift_R) || | |
1991 (event->keyval == GDK_Escape) || | |
8177 | 1992 (event->keyval == GDK_Up) || |
1993 (event->keyval == GDK_Down) || | |
1994 (event->keyval == GDK_Left) || | |
8191 | 1995 (event->keyval == GDK_Right) || |
1996 (event->keyval == GDK_Home) || | |
9297 | 1997 (event->keyval == GDK_End) || |
1998 (event->keyval == GDK_Tab) || | |
1999 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 2000 return FALSE; |
2001 | |
2002 if (event->type == GDK_KEY_RELEASE) | |
2003 gtk_widget_grab_focus(gtkconv->entry); | |
2004 | |
2005 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
2006 | |
2007 return TRUE; | |
6057 | 2008 } |
2009 | |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
2010 void |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
2011 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2012 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2013 GaimGtkConversation *gtkconv; |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2014 GaimConversation *old_conv; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2015 GtkIMHtml *entry; |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2016 const char *protocol_name; |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2017 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2018 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2019 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2020 gtkconv = GAIM_GTK_CONVERSATION(conv); |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2021 old_conv = gtkconv->active_conv; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2022 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2023 if (old_conv == conv) |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2024 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2025 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2026 gaim_conversation_close_logs(old_conv); |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2027 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2028 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2029 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
2030 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
|
2031 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2032 entry = GTK_IMHTML(gtkconv->entry); |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2033 protocol_name = gaim_account_get_protocol_name(conv->account); |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2034 gtk_imhtml_set_protocol_name(entry, protocol_name); |
12831
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2035 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol_name); |
1bb4837b527e
[gaim-migrate @ 15179]
Richard Laager <rlaager@wiktel.com>
parents:
12824
diff
changeset
|
2036 |
12899
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2037 if (!(conv->features & GAIM_CONNECTION_HTML)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2038 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2039 else if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO && |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2040 !(old_conv->features & GAIM_CONNECTION_FORMATTING_WBFO)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2041 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2042 /* The old conversation allowed formatting on parts of the |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2043 * buffer, but the new one only allows it on the whole |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2044 * buffer. This code saves the formatting from the current |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2045 * position of the cursor, clears the formatting, then |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2046 * applies the saved formatting to the entire buffer. */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2047 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2048 gboolean bold; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2049 gboolean italic; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2050 gboolean underline; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2051 char *fontface = gtk_imhtml_get_current_fontface(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2052 char *forecolor = gtk_imhtml_get_current_forecolor(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2053 char *backcolor = gtk_imhtml_get_current_backcolor(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2054 char *background = gtk_imhtml_get_current_background(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2055 gint fontsize = gtk_imhtml_get_current_fontsize(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2056 gboolean bold2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2057 gboolean italic2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2058 gboolean underline2; |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2059 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2060 gtk_imhtml_get_current_format(entry, &bold, &italic, &underline); |
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 /* Clear existing formatting */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2063 gtk_imhtml_clear_formatting(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2064 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2065 /* Apply saved formatting to the whole buffer. */ |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2066 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2067 gtk_imhtml_get_current_format(entry, &bold2, &italic2, &underline2); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2068 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2069 if (bold != bold2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2070 gtk_imhtml_toggle_bold(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2071 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2072 if (italic != italic2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2073 gtk_imhtml_toggle_italic(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2074 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2075 if (underline != underline2) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2076 gtk_imhtml_toggle_underline(entry); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2077 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2078 gtk_imhtml_toggle_fontface(entry, fontface); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2079 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2080 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2081 gtk_imhtml_font_set_size(entry, fontsize); |
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 gtk_imhtml_toggle_forecolor(entry, forecolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2084 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2085 if (!(conv->features & GAIM_CONNECTION_NO_BGCOLOR)) |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2086 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2087 gtk_imhtml_toggle_backcolor(entry, backcolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2088 gtk_imhtml_toggle_background(entry, background); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2089 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2090 |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2091 g_free(fontface); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2092 g_free(forecolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2093 g_free(backcolor); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2094 g_free(background); |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2095 } |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2096 else |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2097 { |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2098 /* 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
|
2099 * 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
|
2100 * 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
|
2101 * 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
|
2102 gtk_imhtml_set_whole_buffer_formatting_only(entry, |
83de40f1c0df
[gaim-migrate @ 15252]
Richard Laager <rlaager@wiktel.com>
parents:
12897
diff
changeset
|
2103 (conv->features & GAIM_CONNECTION_FORMATTING_WBFO)); |
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 |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
2106 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-switched", conv); |
11604 | 2107 |
2108 gray_stuff_out(gtkconv); | |
2109 update_typing_icon(gtkconv); | |
2110 | |
2111 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
2112 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
2113 } | |
2114 | |
2115 static void | |
4673 | 2116 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 2117 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2118 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 2119 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2120 GaimConversation *conv; |
4359 | 2121 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2122 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2123 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2124 |
11594 | 2125 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 2126 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 2127 } |
2128 | |
2129 static void | |
2130 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
2131 gchar *new_text, gint new_text_length, gpointer user_data) | |
2132 { | |
10810 | 2133 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2134 GaimConversation *conv; | |
2135 | |
2136 g_return_if_fail(gtkconv != NULL); | |
11508 | 2137 |
10810 | 2138 conv = gtkconv->active_conv; |
4359 | 2139 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2140 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2141 return; |
2142 | |
10810 | 2143 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2144 gtk_text_iter_is_end(position))); | |
4359 | 2145 } |
2146 | |
2147 static void | |
2148 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2149 GtkTextIter *end_pos, gpointer user_data) | |
2150 { | |
10810 | 2151 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2152 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2153 GaimConvIm *im; |
4359 | 2154 |
10810 | 2155 g_return_if_fail(gtkconv != NULL); |
11508 | 2156 |
10810 | 2157 conv = gtkconv->active_conv; |
4359 | 2158 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2159 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2160 return; |
2161 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2162 im = GAIM_CONV_IM(conv); |
4359 | 2163 |
2164 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2165 | |
2166 /* We deleted all the text, so turn off typing. */ | |
13842 | 2167 gaim_conv_im_stop_send_typed_timeout(im); |
4359 | 2168 |
2169 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2170 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2171 GAIM_NOT_TYPING); |
4359 | 2172 } |
2173 else { | |
2174 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2175 got_typing_keypress(gtkconv, FALSE); |
4359 | 2176 } |
2177 } | |
2178 | |
8189 | 2179 /************************************************************************** |
2180 * A bunch of buddy icon functions | |
2181 **************************************************************************/ | |
11581 | 2182 GdkPixbuf * |
2183 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2184 { |
10116 | 2185 GaimAccount *account = NULL; |
2186 const char *name = NULL; | |
7143 | 2187 GdkPixbuf *status = NULL; |
14138 | 2188 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); |
7143 | 2189 |
10116 | 2190 g_return_val_if_fail(conv != NULL, NULL); |
2191 | |
2192 account = gaim_conversation_get_account(conv); | |
2193 name = gaim_conversation_get_name(conv); | |
2194 | |
2195 g_return_val_if_fail(account != NULL, NULL); | |
2196 g_return_val_if_fail(name != NULL, NULL); | |
2197 | |
13090 | 2198 /* Use the buddy icon, if possible */ |
11338 | 2199 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2200 GaimBuddy *b = gaim_find_buddy(account, name); |
2201 if (b != NULL) { | |
14138 | 2202 /* I hate this hack. It fixes a bug where the pending message icon |
2203 * displays in the conv tab even though it shouldn't. | |
2204 * A better solution would be great. */ | |
2205 if (ops && ops->update) | |
2206 ops->update(NULL, (GaimBlistNode*)b); | |
2207 | |
7143 | 2208 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2209 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2210 } |
2211 } | |
2212 | |
13090 | 2213 /* If they don't have a buddy icon, then use the PRPL icon */ |
2214 if (status == NULL) | |
2215 status = gaim_gtk_create_prpl_icon(account, small_icon ? 0.5 : 1.0); | |
2216 | |
7143 | 2217 return status; |
2218 } | |
2219 | |
8189 | 2220 static void |
2221 update_tab_icon(GaimConversation *conv) | |
2222 { | |
2223 GaimGtkConversation *gtkconv; | |
11581 | 2224 GaimGtkWindow *win; |
8189 | 2225 GdkPixbuf *status = NULL; |
2226 | |
10116 | 2227 g_return_if_fail(conv != NULL); |
2228 | |
8189 | 2229 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2230 win = gtkconv->win; |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2231 if (conv != gtkconv->active_conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2232 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
2233 |
11581 | 2234 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2235 |
10116 | 2236 g_return_if_fail(status != NULL); |
2237 | |
8189 | 2238 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2239 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2240 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2241 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2242 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2243 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2244 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2245 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2246 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2247 { |
11581 | 2248 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2249 | |
2250 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2251 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2252 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2253 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2254 } |
8189 | 2255 } |
2256 | |
2257 static gboolean | |
2258 redraw_icon(gpointer data) | |
2259 { | |
10810 | 2260 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2261 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2262 GaimAccount *account; |
2263 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2264 |
2265 GdkPixbuf *buf; | |
2266 GdkPixbuf *scale; | |
2267 gint delay; | |
9318 | 2268 int scale_width, scale_height; |
8189 | 2269 |
2270 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2271 account = gaim_conversation_get_account(conv); |
2272 if(account && account->gc) | |
2273 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2274 |
2275 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2276 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2277 | |
10483 | 2278 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2279 NULL, &scale_width, &scale_height); |
2280 | |
2281 /* this code is ugly, and scares me */ | |
8189 | 2282 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2283 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2284 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2285 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2286 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2287 GDK_INTERP_BILINEAR); |
8189 | 2288 |
13690
6a86f4ec744e
[gaim-migrate @ 16093]
Richard Laager <rlaager@wiktel.com>
parents:
13663
diff
changeset
|
2289 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->u.im->icon), scale); |
8189 | 2290 g_object_unref(G_OBJECT(scale)); |
2291 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2292 | |
9131 | 2293 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2294 |
2295 if (delay < 100) | |
9131 | 2296 delay = 100; |
2297 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2298 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2299 |
2300 return FALSE; | |
2301 } | |
2302 | |
2303 static void | |
10810 | 2304 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2305 { |
2306 int delay; | |
2307 | |
8228 | 2308 if (gtkconv->u.im->anim == NULL) |
2309 return; | |
2310 | |
8202 | 2311 if (gtkconv->u.im->icon_timer != 0) |
2312 return; | |
2313 | |
8189 | 2314 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2315 return; | |
2316 | |
10639 | 2317 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2318 | |
2319 if (delay < 100) | |
2320 delay = 100; | |
2321 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2322 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2323 } |
2324 | |
2325 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2326 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2327 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2328 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2329 GaimGtkWindow *gtkwin; |
2330 | |
2331 g_return_if_fail(conv != NULL); | |
2332 | |
9887 | 2333 if (gtkconv->u.im->icon_container != NULL) |
2334 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2335 |
2336 if (gtkconv->u.im->anim != NULL) | |
2337 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2338 | |
2339 if (gtkconv->u.im->icon_timer != 0) | |
2340 g_source_remove(gtkconv->u.im->icon_timer); | |
2341 | |
2342 if (gtkconv->u.im->iter != NULL) | |
2343 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2344 | |
2345 gtkconv->u.im->icon_timer = 0; | |
2346 gtkconv->u.im->icon = NULL; | |
2347 gtkconv->u.im->anim = NULL; | |
2348 gtkconv->u.im->iter = NULL; | |
10456 | 2349 gtkconv->u.im->icon_container = NULL; |
9687 | 2350 gtkconv->u.im->show_icon = FALSE; |
10456 | 2351 |
11581 | 2352 gtkwin = gtkconv->win; |
10456 | 2353 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2354 } |
2355 | |
9497 | 2356 static void |
9504 | 2357 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2358 { |
10810 | 2359 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2360 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2361 FILE *fp; |
2362 GaimBuddyIcon *icon; | |
2363 const void *data; | |
2364 size_t len; | |
2365 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2366 if ((fp = g_fopen(filename, "wb")) == NULL) { |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
2367 gaim_notify_error(gtkconv, NULL, _("Unable to open file."), NULL); |
9497 | 2368 return; |
2369 } | |
2370 | |
2371 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2372 data = gaim_buddy_icon_get_data(icon, &len); | |
2373 | |
2374 if ((len <= 0) || (data == NULL)) { | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
2375 gaim_notify_error(gtkconv, NULL, _("Unable to save icon file to disk."), NULL); |
13405 | 2376 fclose(fp); |
9497 | 2377 return; |
2378 } | |
2379 | |
2380 fwrite(data, 1, len, fp); | |
2381 fclose(fp); | |
2382 } | |
2383 | |
2384 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2385 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2386 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2387 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2388 const gchar *ext; |
9497 | 2389 gchar *buf; |
2390 | |
2391 g_return_if_fail(conv != NULL); | |
9504 | 2392 |
10953 | 2393 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2394 if (ext == NULL) | |
2395 ext = "icon"; | |
2396 | |
2397 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2398 |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
2399 gaim_request_file(gtkconv, _("Save Icon"), buf, TRUE, |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2400 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2401 |
2402 g_free(buf); | |
2403 } | |
2404 | |
11581 | 2405 static void |
2406 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2407 { | |
2408 if (gtkconv->u.im->icon_timer != 0) | |
2409 g_source_remove(gtkconv->u.im->icon_timer); | |
2410 | |
2411 gtkconv->u.im->icon_timer = 0; | |
2412 } | |
2413 | |
2414 | |
2415 static void | |
2416 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2417 { | |
2418 gtkconv->u.im->animate = | |
2419 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2420 | |
2421 if (gtkconv->u.im->animate) | |
2422 start_anim(NULL, gtkconv); | |
2423 else | |
2424 stop_anim(NULL, gtkconv); | |
2425 } | |
2426 | |
8189 | 2427 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2428 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2429 { |
2430 static GtkWidget *menu = NULL; | |
13570
41e4b22c0afb
[gaim-migrate @ 15949]
Richard Laager <rlaager@wiktel.com>
parents:
13536
diff
changeset
|
2431 GtkWidget *item; |
8189 | 2432 |
2433 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2434 return FALSE; | |
2435 | |
2436 /* | |
2437 * If a menu already exists, destroy it before creating a new one, | |
2438 * thus freeing-up the memory it occupied. | |
2439 */ | |
2440 if (menu != NULL) | |
2441 gtk_widget_destroy(menu); | |
2442 | |
2443 menu = gtk_menu_new(); | |
2444 | |
2445 if (gtkconv->u.im->anim && | |
2446 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2447 { | |
2448 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2449 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2450 gtkconv->u.im->icon_timer); |
2451 } | |
2452 | |
13570
41e4b22c0afb
[gaim-migrate @ 15949]
Richard Laager <rlaager@wiktel.com>
parents:
13536
diff
changeset
|
2453 item = gtk_menu_item_new_with_label(_("Hide Icon")); |
41e4b22c0afb
[gaim-migrate @ 15949]
Richard Laager <rlaager@wiktel.com>
parents:
13536
diff
changeset
|
2454 g_signal_connect_swapped(G_OBJECT(item), "activate", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2455 G_CALLBACK(remove_icon), gtkconv); |
13570
41e4b22c0afb
[gaim-migrate @ 15949]
Richard Laager <rlaager@wiktel.com>
parents:
13536
diff
changeset
|
2456 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
41e4b22c0afb
[gaim-migrate @ 15949]
Richard Laager <rlaager@wiktel.com>
parents:
13536
diff
changeset
|
2457 gtk_widget_show(item); |
8189 | 2458 |
2459 gaim_new_item_from_stock(menu, _("Save Icon As..."), GTK_STOCK_SAVE_AS, | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2460 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2461 0, 0, NULL); |
2462 | |
2463 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2464 | |
2465 return TRUE; | |
2466 } | |
10456 | 2467 |
2468 static void | |
2469 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2470 { | |
11581 | 2471 GaimGtkWindow *win = data; |
10456 | 2472 GaimConversation *conv; |
2473 GaimGtkConversation *gtkconv; | |
2474 gboolean active; | |
2475 | |
11581 | 2476 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2477 |
2478 if (!conv) | |
2479 return; | |
2480 | |
11338 | 2481 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2482 |
2483 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2484 | |
2485 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2486 gtkconv->u.im->show_icon = active; | |
2487 if (active) | |
2488 gaim_gtkconv_update_buddy_icon(conv); | |
2489 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2490 remove_icon(gtkconv); |
10456 | 2491 } |
2492 | |
8189 | 2493 /************************************************************************** |
2494 * End of the bunch of buddy icon functions | |
2495 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2496 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2497 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2498 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2499 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2500 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2501 if(gtkconv->win==hidden_convwin) { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
2502 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2503 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2504 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2505 |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
2506 gaim_gtkconv_switch_active_conversation(conv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2507 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2508 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2509 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2510 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2511 GList * |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2512 gaim_gtk_conversations_find_unseen_list(GaimConversationType type, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2513 GaimUnseenState min_state, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2514 gboolean hidden_only, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2515 guint max_count) |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2516 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2517 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2518 GList *r = NULL; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2519 guint c = 0; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2520 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2521 if (type == GAIM_CONV_TYPE_IM) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2522 l = gaim_get_ims(); |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2523 } else if (type == GAIM_CONV_TYPE_CHAT) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2524 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2525 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2526 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2527 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2528 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2529 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
|
2530 GaimConversation *conv = (GaimConversation*)l->data; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2531 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2532 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2533 if(gtkconv->active_conv != conv) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2534 continue; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2535 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2536 if (gtkconv->unseen_state >= min_state |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2537 && (!hidden_only || |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2538 (hidden_only && gtkconv->win == hidden_convwin))) { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2539 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2540 r = g_list_prepend(r, conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2541 c++; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2542 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2543 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2544 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2545 return r; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2546 } |
8189 | 2547 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2548 static void |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2549 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2550 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2551 g_return_if_fail(conv != NULL); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2552 gaim_gtkconv_present_conversation(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2553 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2554 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2555 guint |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2556 gaim_gtk_conversations_fill_menu(GtkWidget *menu, GList *convs) |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2557 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2558 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2559 guint ret=0; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2560 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2561 g_return_val_if_fail(menu != NULL, 0); |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2562 g_return_val_if_fail(convs != NULL, 0); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2563 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2564 for (l = convs; l != NULL ; l = l->next) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2565 GaimConversation *conv = (GaimConversation*)l->data; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2566 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2567 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2568 GtkWidget *icon = gtk_image_new(); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2569 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2570 GtkWidget *item; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2571 gchar *text = g_strdup_printf("%s (%d)", |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2572 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2573 gtkconv->unseen_count); |
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 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2576 g_object_unref(pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2577 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2578 item = gtk_image_menu_item_new_with_label(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2579 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
|
2580 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
|
2581 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2582 g_free(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2583 ret++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2584 } |
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 return ret; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2587 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2588 |
11581 | 2589 GaimGtkWindow * |
2590 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2591 { | |
2592 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2593 return gtkconv->win; | |
2594 } | |
2595 | |
2596 static GtkItemFactoryEntry menu_items[] = | |
2597 { | |
2598 /* Conversation menu */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2599 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>", NULL }, |
11581 | 2600 |
2601 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2602 0, "<StockItem>", GAIM_STOCK_IM }, | |
2603 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2604 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2605 |
2606 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2607 "<StockItem>", GTK_STOCK_FIND }, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2608 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", GAIM_STOCK_LOG }, |
11581 | 2609 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2610 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
12897
e9b0c90ce58a
[gaim-migrate @ 15250]
Richard Laager <rlaager@wiktel.com>
parents:
12867
diff
changeset
|
2611 { N_("/Conversation/Clea_r Scrollback"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
11581 | 2612 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2613 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2614 |
2615 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2616 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2617 0, "<StockItem>", GAIM_STOCK_POUNCE }, |
11581 | 2618 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2619 "<StockItem>", GAIM_STOCK_INFO }, | |
2620 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2621 "<StockItem>", GAIM_STOCK_INVITE }, | |
13781
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2622 { N_("/Conversation/M_ore"), NULL, NULL, 0, "<Branch>", NULL }, |
11581 | 2623 |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2624 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2625 |
2626 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2627 "<StockItem>", GAIM_STOCK_EDIT }, | |
2628 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2629 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2630 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2631 "<StockItem>", GTK_STOCK_ADD }, | |
2632 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2633 "<StockItem>", GTK_STOCK_REMOVE }, | |
2634 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2635 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2636 |
2637 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2638 "<StockItem>", GAIM_STOCK_LINK }, | |
2639 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2640 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2641 | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2642 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>", NULL }, |
11581 | 2643 |
2644 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2645 "<StockItem>", GTK_STOCK_CLOSE }, | |
2646 | |
2647 /* Options */ | |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2648 { N_("/_Options"), NULL, NULL, 0, "<Branch>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2649 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2650 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2651 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2652 { "/Options/sep0", NULL, NULL, 0, "<Separator>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2653 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>", NULL }, |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12594
diff
changeset
|
2654 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>", NULL }, |
11581 | 2655 }; |
2656 | |
2657 static const int menu_item_count = | |
2658 sizeof(menu_items) / sizeof(*menu_items); | |
2659 | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2660 static const char * |
11581 | 2661 item_factory_translate_func (const char *path, gpointer func_data) |
2662 { | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2663 return _(path); |
11581 | 2664 } |
2665 | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2666 static void |
12816 | 2667 sound_method_pref_changed_cb(const char *name, GaimPrefType type, |
2668 gconstpointer value, gpointer data) | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2669 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2670 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2671 const char *method = value; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2672 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2673 if (!strcmp(method, "none")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2674 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2675 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2676 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2677 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2678 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2679 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2680 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2681 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2682 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2683 if (gtkconv != NULL) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2684 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2685 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2686 gtk_widget_set_sensitive(win->menu.sounds, TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2687 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2688 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2689 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2690 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2691 static void |
12816 | 2692 show_buddy_icons_pref_changed_cb(const char *name, GaimPrefType type, |
2693 gconstpointer value, gpointer data) | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2694 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2695 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2696 gboolean show_icons = GPOINTER_TO_INT(value); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2697 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2698 if (!show_icons) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2699 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2700 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2701 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2702 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2703 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2704 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2705 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2706 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2707 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2708 if (gtkconv != NULL) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2709 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2710 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2711 gtk_widget_set_sensitive(win->menu.show_icon, TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2712 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2713 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2714 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2715 |
13781
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2716 static void |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2717 regenerate_options_items(GaimGtkWindow *win) |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2718 { |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2719 GtkWidget *menu; |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2720 GList *list; |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2721 GaimGtkConversation *gtkconv; |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2722 GaimConversation *conv; |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2723 GaimBuddy *buddy; |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2724 |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2725 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2726 conv = gtkconv->active_conv; |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2727 buddy = gaim_find_buddy(conv->account, conv->name); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2728 |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2729 menu = gtk_item_factory_get_widget(win->menu.item_factory, N_("/Conversation/More")); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2730 |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2731 /* Remove the previous entries */ |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2732 for (list = gtk_container_get_children(GTK_CONTAINER(menu)); list; ) |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2733 { |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2734 GtkWidget *w = list->data; |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2735 list = list->next; |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2736 gtk_widget_destroy(w); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2737 } |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2738 |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2739 /* Now add the stuff */ |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2740 if (buddy) |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2741 { |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2742 if (gaim_account_is_connected(conv->account)) |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2743 gaim_gtk_append_blist_node_proto_menu(menu, conv->account->gc, |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2744 (GaimBlistNode *)buddy); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2745 gaim_gtk_append_blist_node_extended_menu(menu, (GaimBlistNode *)buddy); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2746 } |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2747 |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2748 if ((list = gtk_container_get_children(GTK_CONTAINER(menu))) == NULL) |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2749 { |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2750 GtkWidget *item = gtk_menu_item_new_with_label(_("No actions available")); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2751 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2752 gtk_widget_set_sensitive(item, FALSE); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2753 } |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2754 |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2755 gtk_widget_show_all(menu); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2756 } |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2757 |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2758 static void menubar_activated(GtkWidget *item, gpointer data) |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2759 { |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2760 regenerate_options_items(data); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2761 g_signal_handlers_block_by_func(G_OBJECT(item), G_CALLBACK(menubar_activated), data); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2762 } |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2763 |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2764 static void |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2765 focus_out_from_menubar(GtkWidget *wid, GaimGtkWindow *win) |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2766 { |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2767 GtkWidget *menuitem = gtk_item_factory_get_item(win->menu.item_factory, N_("/Conversation")); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2768 g_signal_handlers_unblock_by_func(G_OBJECT(menuitem), G_CALLBACK(menubar_activated), win); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2769 } |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2770 |
11581 | 2771 static GtkWidget * |
2772 setup_menubar(GaimGtkWindow *win) | |
2773 { | |
2774 GtkAccelGroup *accel_group; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2775 const char *method; |
13781
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2776 GtkWidget *menuitem; |
11581 | 2777 |
2778 accel_group = gtk_accel_group_new (); | |
2779 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2780 g_object_unref(accel_group); | |
2781 | |
2782 win->menu.item_factory = | |
2783 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2784 | |
2785 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2786 (GtkTranslateFunc)item_factory_translate_func, |
11581 | 2787 NULL, NULL); |
2788 | |
2789 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2790 menu_items, win); | |
2791 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2792 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2793 | |
13781
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2794 menuitem = gtk_item_factory_get_item(win->menu.item_factory, N_("/Conversation")); |
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2795 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menubar_activated), win); |
11581 | 2796 |
2797 win->menu.menubar = | |
2798 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2799 | |
13781
743e38a3182b
[gaim-migrate @ 16193]
Richard Laager <rlaager@wiktel.com>
parents:
13769
diff
changeset
|
2800 g_signal_connect(G_OBJECT(win->menu.menubar), "deactivate", G_CALLBACK(focus_out_from_menubar), win); |
11581 | 2801 |
2802 win->menu.view_log = | |
2803 gtk_item_factory_get_widget(win->menu.item_factory, | |
2804 N_("/Conversation/View Log")); | |
2805 | |
2806 /* --- */ | |
2807 | |
2808 win->menu.send_file = | |
2809 gtk_item_factory_get_widget(win->menu.item_factory, | |
2810 N_("/Conversation/Send File...")); | |
2811 | |
2812 win->menu.add_pounce = | |
2813 gtk_item_factory_get_widget(win->menu.item_factory, | |
2814 N_("/Conversation/Add Buddy Pounce...")); | |
2815 | |
2816 /* --- */ | |
2817 | |
2818 win->menu.get_info = | |
2819 gtk_item_factory_get_widget(win->menu.item_factory, | |
2820 N_("/Conversation/Get Info")); | |
2821 | |
2822 win->menu.invite = | |
2823 gtk_item_factory_get_widget(win->menu.item_factory, | |
2824 N_("/Conversation/Invite...")); | |
2825 | |
2826 /* --- */ | |
2827 | |
2828 win->menu.alias = | |
2829 gtk_item_factory_get_widget(win->menu.item_factory, | |
2830 N_("/Conversation/Alias...")); | |
2831 | |
2832 win->menu.block = | |
2833 gtk_item_factory_get_widget(win->menu.item_factory, | |
2834 N_("/Conversation/Block...")); | |
2835 | |
2836 win->menu.add = | |
2837 gtk_item_factory_get_widget(win->menu.item_factory, | |
2838 N_("/Conversation/Add...")); | |
2839 | |
2840 win->menu.remove = | |
2841 gtk_item_factory_get_widget(win->menu.item_factory, | |
2842 N_("/Conversation/Remove...")); | |
2843 | |
2844 /* --- */ | |
2845 | |
2846 win->menu.insert_link = | |
2847 gtk_item_factory_get_widget(win->menu.item_factory, | |
2848 N_("/Conversation/Insert Link...")); | |
2849 | |
2850 win->menu.insert_image = | |
2851 gtk_item_factory_get_widget(win->menu.item_factory, | |
2852 N_("/Conversation/Insert Image...")); | |
2853 | |
2854 /* --- */ | |
2855 | |
2856 win->menu.logging = | |
2857 gtk_item_factory_get_widget(win->menu.item_factory, | |
2858 N_("/Options/Enable Logging")); | |
2859 win->menu.sounds = | |
2860 gtk_item_factory_get_widget(win->menu.item_factory, | |
2861 N_("/Options/Enable Sounds")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2862 method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2863 if (!strcmp(method, "none")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2864 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2865 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
|
2866 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2867 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2868 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2869 gaim_prefs_connect_callback(win, "/gaim/gtk/sound/method", |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2870 sound_method_pref_changed_cb, win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2871 |
11581 | 2872 win->menu.show_formatting_toolbar = |
2873 gtk_item_factory_get_widget(win->menu.item_factory, | |
2874 N_("/Options/Show Formatting Toolbars")); | |
2875 win->menu.show_timestamps = | |
2876 gtk_item_factory_get_widget(win->menu.item_factory, | |
2877 N_("/Options/Show Timestamps")); | |
2878 win->menu.show_icon = | |
2879 gtk_item_factory_get_widget(win->menu.item_factory, | |
2880 N_("/Options/Show Buddy Icon")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2881 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
|
2882 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2883 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
|
2884 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2885 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2886 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2887 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
|
2888 show_buddy_icons_pref_changed_cb, win); |
11581 | 2889 |
2890 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2891 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2892 win->menu.tray); | |
2893 gtk_widget_show(win->menu.tray); | |
2894 | |
2895 gtk_widget_show(win->menu.menubar); | |
2896 | |
2897 return win->menu.menubar; | |
2898 } | |
2899 | |
4359 | 2900 |
2901 /************************************************************************** | |
2902 * Utility functions | |
2903 **************************************************************************/ | |
2904 | |
2905 static void | |
10810 | 2906 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2907 { |
10810 | 2908 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2909 GaimConvIm *im; |
4685 | 2910 |
4359 | 2911 /* |
2912 * 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
|
2913 * send GAIM_TYPED any time soon. |
4359 | 2914 */ |
2915 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2916 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2917 |
13842 | 2918 gaim_conv_im_stop_send_typed_timeout(im); |
2919 gaim_conv_im_start_send_typed_timeout(im); | |
2920 | |
2921 /* Check if we need to send another GAIM_TYPING message */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2922 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
13842 | 2923 time(NULL) > gaim_conv_im_get_type_again(im))) |
2924 { | |
2925 unsigned int timeout; | |
2926 timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2927 gaim_conversation_get_name(conv), | |
2928 GAIM_TYPING); | |
2929 gaim_conv_im_set_type_again(im, timeout); | |
4359 | 2930 } |
2931 } | |
2932 | |
4736 | 2933 static void |
10810 | 2934 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2935 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2936 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2937 GaimConvIm *im = NULL; |
10810 | 2938 GaimConversation *conv = gtkconv->active_conv; |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2939 char *stock_id; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
2940 const char *tooltip; |
11508 | 2941 |
11581 | 2942 gtkwin = gtkconv->win; |
4736 | 2943 |
12008 | 2944 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2945 im = GAIM_CONV_IM(conv); |
4736 | 2946 |
12008 | 2947 if (gtkwin->menu.typing_icon) { |
2948 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2949 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2950 |
12008 | 2951 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2952 return; | |
2953 | |
2954 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2955 stock_id = GAIM_STOCK_TYPING; | |
2956 tooltip = _("User is typing..."); | |
2957 } else { | |
2958 stock_id = GAIM_STOCK_TYPED; | |
2959 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2960 } |
12008 | 2961 |
2962 if (gtkwin->menu.typing_icon == NULL) | |
2963 { | |
2964 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
|
2965 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
|
2966 gtkwin->menu.typing_icon, |
12008 | 2967 tooltip); |
4736 | 2968 } |
12008 | 2969 else |
2970 { | |
2971 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2972 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2973 gtkwin->menu.typing_icon, | |
2974 tooltip); | |
2975 } | |
2976 | |
2977 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2978 } |
2979 | |
4685 | 2980 static gboolean |
11594 | 2981 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2982 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2983 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2984 GaimConversation *conv; |
4359 | 2985 GtkWidget *menu; |
2986 GList *child; | |
11594 | 2987 GaimBuddy *b; |
11581 | 2988 |
2989 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2990 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2991 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2992 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2993 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2994 account = gaim_conversation_get_account(conv); |
11581 | 2995 |
13131 | 2996 if (account == NULL) |
2997 return FALSE; | |
2998 | |
11594 | 2999 if (win->menu.send_to == NULL) |
4685 | 3000 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
3001 |
11594 | 3002 if (!(b = gaim_find_buddy(account, conv->name))) |
3003 return FALSE; | |
3004 | |
3005 | |
3006 gtk_widget_show(win->menu.send_to); | |
4359 | 3007 |
3008 menu = gtk_menu_item_get_submenu( | |
11594 | 3009 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 3010 |
3011 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
3012 child != NULL; | |
3013 child = child->next) { | |
3014 | |
3015 GtkWidget *item = child->data; | |
11594 | 3016 GaimBuddy *item_buddy; |
3017 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
3018 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
3019 "gaim_buddy_name"); | |
3020 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
3021 | |
3022 if (b == item_buddy) { | |
4359 | 3023 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
3024 break; | |
3025 } | |
3026 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
3027 |
4685 | 3028 return FALSE; |
4359 | 3029 } |
3030 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3031 static gboolean |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3032 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
|
3033 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3034 gtk_widget_set_sensitive(GTK_WIDGET(label), TRUE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3035 return FALSE; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3036 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3037 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3038 static gboolean |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3039 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
|
3040 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3041 gtk_widget_set_sensitive(GTK_WIDGET(label), FALSE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3042 return FALSE; |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3043 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3044 |
4359 | 3045 static void |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3046 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
|
3047 { |
11594 | 3048 GtkWidget *box; |
3049 GtkWidget *label; | |
3050 GtkWidget *image; | |
3051 GtkWidget *menuitem; | |
11625 | 3052 GdkPixbuf *pixbuf; |
11616 | 3053 gchar *text; |
11594 | 3054 |
3055 /* Create a pixmap for the protocol icon. */ | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3056 if (buddy != NULL) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3057 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
|
3058 else |
13090 | 3059 pixbuf = gaim_gtk_create_prpl_icon(account, 0.5); |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3060 |
11594 | 3061 /* Now convert it to GtkImage */ |
3062 if (pixbuf == NULL) | |
3063 image = gtk_image_new(); | |
3064 else | |
13090 | 3065 { |
11625 | 3066 image = gtk_image_new_from_pixbuf(pixbuf); |
13090 | 3067 g_object_unref(G_OBJECT(pixbuf)); |
3068 } | |
11594 | 3069 |
3070 gtk_size_group_add_widget(sg, image); | |
3071 | |
3072 /* Make our menu item */ | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3073 text = g_strdup_printf("%s (%s)", name, gaim_account_get_username(account)); |
11616 | 3074 menuitem = gtk_radio_menu_item_new_with_label(*group, text); |
3075 g_free(text); | |
11594 | 3076 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
3077 | |
3078 /* Do some evil, see some evil, speak some evil. */ | |
3079 box = gtk_hbox_new(FALSE, 0); | |
3080 | |
3081 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
3082 g_object_ref(label); | |
3083 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
3084 | |
3085 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
3086 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
3087 | |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3088 if (buddy != NULL && |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3089 !gaim_presence_is_online(gaim_buddy_get_presence(buddy)) && |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3090 !gaim_account_supports_offline_message(account, buddy)) |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3091 { |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3092 gtk_widget_set_sensitive(label, FALSE); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3093 |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3094 /* Set the label sensitive when the menuitem is highlighted and |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3095 * insensitive again when the mouse leaves it. This way, it |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3096 * doesn't appear weird from the highlighting of the embossed |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3097 * (insensitive style) text.*/ |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3098 g_signal_connect(menuitem, "enter-notify-event", |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3099 G_CALLBACK(send_to_item_enter_notify_cb), label); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3100 g_signal_connect(menuitem, "leave-notify-event", |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3101 G_CALLBACK(send_to_item_leave_notify_cb), label); |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3102 } |
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12639
diff
changeset
|
3103 |
11594 | 3104 g_object_unref(label); |
3105 | |
3106 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
3107 | |
3108 gtk_widget_show(label); | |
3109 gtk_widget_show(image); | |
3110 gtk_widget_show(box); | |
3111 | |
3112 /* Set our data and callbacks. */ | |
3113 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3114 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(name), g_free); |
11594 | 3115 |
3116 g_signal_connect(G_OBJECT(menuitem), "activate", | |
3117 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
3118 | |
3119 gtk_widget_show(menuitem); | |
3120 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3121 } | |
3122 | |
3123 static void | |
3124 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 3125 { |
4359 | 3126 GtkWidget *menu; |
3127 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3128 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 3129 GaimGtkConversation *gtkconv; |
3130 GSList *l, *buds; | |
3131 | |
3132 g_return_if_fail(win != NULL); | |
3133 | |
3134 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
3135 | |
11604 | 3136 g_return_if_fail(gtkconv != NULL); |
3137 | |
11594 | 3138 if (win->menu.send_to != NULL) |
3139 gtk_widget_destroy(win->menu.send_to); | |
3140 | |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12272
diff
changeset
|
3141 /* Build the Send To menu */ |
11594 | 3142 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
3143 gtk_widget_show(win->menu.send_to); | |
4359 | 3144 |
3145 menu = gtk_menu_new(); | |
11581 | 3146 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 3147 win->menu.send_to, 2); |
3148 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 3149 |
3150 gtk_widget_show(menu); | |
3151 | |
11604 | 3152 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
3153 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
|
3154 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3155 if (buds == NULL) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3156 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3157 /* The user isn't on the buddy list. */ |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3158 create_sendto_item(menu, sg, &group, NULL, gtkconv->active_conv->account, gtkconv->active_conv->name); |
11604 | 3159 } |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3160 else |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3161 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3162 GList *list = NULL, *iter; |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3163 for (l = buds; l != NULL; l = l->next) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3164 { |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3165 GaimBlistNode *node; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3166 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3167 node = (GaimBlistNode *) gaim_buddy_get_contact((GaimBuddy *)l->data); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3168 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3169 for (node = node->child; node != NULL; node = node->next) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3170 { |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
3171 GaimBuddy *buddy = (GaimBuddy *)node; |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3172 GaimAccount *account; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3173 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3174 if (!GAIM_BLIST_NODE_IS_BUDDY(node)) |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3175 continue; |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3176 |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3177 account = gaim_buddy_get_account(buddy); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3178 if (gaim_account_is_connected(account)) |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3179 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3180 /* Use the GaimPresence to get unique buddies. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3181 GaimPresence *presence = gaim_buddy_get_presence(buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3182 if (!g_list_find(list, presence)) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3183 list = g_list_prepend(list, presence); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3184 } |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3185 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3186 } |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3187 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3188 /* 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
|
3189 * since we did a g_list_prepend() earlier. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3190 for (iter = g_list_last(list); iter != NULL; iter = iter->prev) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3191 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3192 GaimPresence *pre = iter->data; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3193 GaimBuddy *buddy = gaim_presence_get_buddies(pre)->data; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3194 create_sendto_item(menu, sg, &group, buddy, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3195 gaim_buddy_get_account(buddy), gaim_buddy_get_name(buddy)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3196 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
3197 g_list_free(list); |
12638
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3198 g_slist_free(buds); |
7a2a2ca48703
[gaim-migrate @ 14974]
Richard Laager <rlaager@wiktel.com>
parents:
12636
diff
changeset
|
3199 } |
4359 | 3200 } |
3201 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3202 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3203 |
11594 | 3204 gtk_widget_show(win->menu.send_to); |
12455 | 3205 /* TODO: This should never be insensitive. Possibly hidden or not. */ |
11594 | 3206 if (!group) |
3207 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
3208 update_send_to_selection(win); | |
4359 | 3209 } |
3210 | |
3211 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3212 generate_invite_user_names(GaimConnection *gc) |
4359 | 3213 { |
6695 | 3214 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 3215 static GList *tmp = NULL; |
3216 | |
14035 | 3217 g_list_free(tmp); |
4359 | 3218 |
3219 tmp = g_list_append(NULL, ""); | |
3220 | |
3221 if (gc != NULL) { | |
4785 | 3222 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
3223 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
3224 continue; | |
6695 | 3225 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3226 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 3227 continue; |
6695 | 3228 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
3229 GaimBuddy *buddy; | |
3230 | |
3231 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
3232 continue; | |
3233 | |
3234 buddy = (GaimBuddy *)bnode; | |
3235 | |
3236 if (buddy->account == gc->account && | |
3237 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 3238 tmp = g_list_insert_sorted(tmp, buddy->name, |
3239 (GCompareFunc)g_utf8_collate); | |
6695 | 3240 } |
4359 | 3241 } |
3242 } | |
3243 } | |
3244 | |
3245 return tmp; | |
3246 } | |
3247 | |
9498 | 3248 static GdkPixbuf * |
9554 | 3249 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 3250 { |
9554 | 3251 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 3252 char *filename; |
10274 | 3253 const char *image = NULL; |
9554 | 3254 |
3255 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 3256 image = "founder.png"; |
9554 | 3257 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 3258 image = "op.png"; |
9554 | 3259 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 3260 image = "halfop.png"; |
9554 | 3261 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 3262 image = "voice.png"; |
9554 | 3263 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 3264 image = "ignored.png"; |
3265 } else { | |
3266 return NULL; | |
9554 | 3267 } |
10274 | 3268 |
3269 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
3270 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
3271 g_free(filename); | |
3272 | |
3273 if (!pixbuf) | |
3274 return NULL; | |
3275 | |
3276 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
3277 g_object_unref(pixbuf); | |
3278 | |
3279 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
3280 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 3281 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
3282 g_free(filename); | |
10274 | 3283 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 3284 g_object_unref(pixbuf); |
10274 | 3285 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
3286 g_object_unref(scale2); | |
9498 | 3287 } |
3288 | |
10274 | 3289 return scale; |
9498 | 3290 } |
3291 | |
4359 | 3292 static void |
13965 | 3293 add_chat_buddy_common(GaimConversation *conv, GaimConvChatBuddy *cb, const char *old_name) |
4359 | 3294 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3295 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3296 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3297 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3298 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3299 GaimPluginProtocolInfo *prpl_info; |
4359 | 3300 GtkListStore *ls; |
9498 | 3301 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3302 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3303 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3304 gboolean is_buddy; |
13965 | 3305 gchar *alias_key, *name, *alias; |
3306 int flags; | |
3307 | |
3308 alias = cb->alias; | |
3309 name = cb->name; | |
3310 flags = GPOINTER_TO_INT(cb->flags); | |
4359 | 3311 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3312 chat = GAIM_CONV_CHAT(conv); |
4359 | 3313 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3314 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3315 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3316 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3317 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3318 return; |
4359 | 3319 |
3320 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3321 | |
9554 | 3322 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 3323 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3324 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
|
3325 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3326 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3327 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3328 |
13965 | 3329 alias_key = g_utf8_collate_key(alias, strlen(alias)); |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3330 |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3331 if (is_me) |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3332 { |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3333 GdkColor send_color; |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3334 gdk_color_parse(SEND_COLOR, &send_color); |
13965 | 3335 |
3336 #if GTK_CHECK_VERSION(2,6,0) | |
3337 gtk_list_store_insert_with_values | |
3338 (ls, | |
3339 &iter, | |
3340 /* | |
3341 * The GTK docs are mute about the effects of the "row" value for performance. | |
3342 * X-Chat hardcodes their value to 0 (prepend) and -1 (append), so we will too. | |
3343 * It *might* be faster to search the gtk_list_store and set row accurately, | |
3344 * but no one in #gtk+ seems to know anything about it either. | |
3345 * Inserting in the "wrong" location has no visible ill effects. - F.P. | |
3346 */ | |
3347 -1, /* "row" */ | |
3348 CHAT_USERS_ICON_COLUMN, pixbuf, | |
3349 CHAT_USERS_ALIAS_COLUMN, alias, | |
3350 CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, | |
3351 CHAT_USERS_NAME_COLUMN, name, | |
3352 CHAT_USERS_FLAGS_COLUMN, flags, | |
3353 CHAT_USERS_COLOR_COLUMN, &send_color, | |
3354 CHAT_USERS_BUDDY_COLUMN, is_buddy, | |
3355 -1); | |
3356 } | |
3357 else { | |
3358 gtk_list_store_insert_with_values | |
3359 (ls, | |
3360 &iter, | |
3361 -1, /* "row" */ | |
3362 CHAT_USERS_ICON_COLUMN, pixbuf, | |
3363 CHAT_USERS_ALIAS_COLUMN, alias, | |
3364 CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, | |
3365 CHAT_USERS_NAME_COLUMN, name, | |
3366 CHAT_USERS_FLAGS_COLUMN, flags, | |
3367 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, name), | |
3368 CHAT_USERS_BUDDY_COLUMN, is_buddy, | |
3369 -1); | |
3370 | |
3371 #else | |
3372 gtk_list_store_append(ls, &iter); | |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3373 gtk_list_store_set(ls, &iter, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3374 CHAT_USERS_ICON_COLUMN, pixbuf, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3375 CHAT_USERS_ALIAS_COLUMN, alias, |
13965 | 3376 CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3377 CHAT_USERS_NAME_COLUMN, name, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3378 CHAT_USERS_FLAGS_COLUMN, flags, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3379 CHAT_USERS_COLOR_COLUMN, &send_color, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3380 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3381 -1); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3382 } |
13965 | 3383 |
3384 else { | |
3385 | |
3386 gtk_list_store_append(ls, &iter); | |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3387 gtk_list_store_set(ls, &iter, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3388 CHAT_USERS_ICON_COLUMN, pixbuf, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3389 CHAT_USERS_ALIAS_COLUMN, alias, |
13965 | 3390 CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3391 CHAT_USERS_NAME_COLUMN, name, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3392 CHAT_USERS_FLAGS_COLUMN, flags, |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
3393 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, name), |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3394 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3395 -1); |
13965 | 3396 #endif |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3397 } |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3398 |
9554 | 3399 if (pixbuf) |
3400 g_object_unref(pixbuf); | |
13969 | 3401 g_free(alias_key); |
4359 | 3402 } |
3403 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3404 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3405 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
|
3406 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3407 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3408 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3409 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3410 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3411 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3412 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3413 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3414 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3415 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3416 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3417 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3418 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3419 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3420 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3421 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3422 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3423 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3424 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3425 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3426 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3427 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3428 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3429 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3430 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3431 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3432 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3433 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3434 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3435 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3436 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3437 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3438 (GCompareFunc)gaim_utf8_strcasecmp); |
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 |
9605 | 3441 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3442 tab_complete(GaimConversation *conv) |
4359 | 3443 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3444 GaimGtkConversation *gtkconv; |
4359 | 3445 GtkTextIter cursor, word_start, start_buffer; |
3446 int start; | |
3447 int most_matched = -1; | |
3448 char *entered, *partial = NULL; | |
3449 char *text; | |
8021 | 3450 char *nick_partial; |
9605 | 3451 const char *prefix; |
4359 | 3452 GList *matches = NULL; |
9605 | 3453 gboolean command = FALSE; |
4359 | 3454 |
3455 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3456 | |
3457 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3458 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3459 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3460 | |
3461 word_start = cursor; | |
3462 | |
3463 /* if there's nothing there just return */ | |
3464 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3465 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
|
3466 |
4359 | 3467 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3468 &cursor, FALSE); | |
3469 | |
3470 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3471 start = strlen(text) - 1; | |
3472 | |
8021 | 3473 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3474 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3475 start-=2; |
3476 } | |
4359 | 3477 |
3478 /* find the start of the word that we're tabbing */ | |
3479 while (start >= 0 && text[start] != ' ') { | |
3480 gtk_text_iter_backward_char(&word_start); | |
3481 start--; | |
3482 } | |
3483 | |
9605 | 3484 prefix = gaim_gtk_get_cmd_prefix(); |
3485 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3486 command = TRUE; | |
3487 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3488 } | |
3489 | |
4359 | 3490 g_free(text); |
3491 | |
3492 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3493 &cursor, FALSE); | |
3494 | |
8021 | 3495 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3496 g_free(entered); |
11338 | 3497 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3498 } |
3499 | |
8021 | 3500 nick_partial = g_malloc(strlen(entered)+1); |
3501 | |
9605 | 3502 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3503 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3504 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3505 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3506 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3507 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3508 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3509 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3510 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3511 g_list_free(list); |
11338 | 3512 } 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
|
3513 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3514 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3515 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
|
3516 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3517 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3518 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3519 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3520 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3521 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3522 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3523 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3524 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3525 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3526 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3527 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3528 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3529 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3530 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3531 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3532 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3533 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3534 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3535 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3536 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3537 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3538 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3539 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3540 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3541 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3542 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3543 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3544 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3545 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3546 } |
9605 | 3547 } else { |
3548 g_free(nick_partial); | |
3549 g_free(entered); | |
3550 return FALSE; | |
3551 } | |
3552 | |
8021 | 3553 g_free(nick_partial); |
3554 | |
4359 | 3555 /* we're only here if we're doing new style */ |
3556 | |
3557 /* if there weren't any matches, return */ | |
3558 if (!matches) { | |
3559 /* if matches isn't set partials won't be either */ | |
3560 g_free(entered); | |
11338 | 3561 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3562 } |
3563 | |
3564 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3565 | |
3566 if (!matches->next) { | |
3567 /* there was only one match. fill it in. */ | |
3568 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3569 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3570 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3571 | |
3572 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3573 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3574 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3575 g_free(tmp); | |
3576 } | |
3577 else | |
3578 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3579 matches->data, -1); | |
3580 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3581 g_free(matches->data); |
4359 | 3582 matches = g_list_remove(matches, matches->data); |
3583 } | |
3584 else { | |
3585 /* | |
3586 * there were lots of matches, fill in as much as possible | |
3587 * and display all of them | |
3588 */ | |
3589 char *addthis = g_malloc0(1); | |
3590 | |
3591 while (matches) { | |
3592 char *tmp = addthis; | |
3593 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3594 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3595 g_free(matches->data); |
4359 | 3596 matches = g_list_remove(matches, matches->data); |
3597 } | |
3598 | |
6982 | 3599 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3600 time(NULL)); |
3601 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3602 g_free(addthis); | |
3603 } | |
3604 | |
3605 g_free(entered); | |
3606 g_free(partial); | |
9605 | 3607 |
3608 return TRUE; | |
4359 | 3609 } |
3610 | |
10810 | 3611 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3612 { |
3613 GaimPluginProtocolInfo *prpl_info = NULL; | |
3614 GaimConnection *gc; | |
10810 | 3615 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3616 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3617 char *new_topic; |
8858 | 3618 const char *current_topic; |
7971 | 3619 |
3620 gc = gaim_conversation_get_gc(conv); | |
3621 | |
3622 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3623 return; | |
3624 | |
3625 if(prpl_info->set_chat_topic == NULL) | |
3626 return; | |
3627 | |
3628 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3629 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3630 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3631 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3632 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3633 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3634 g_free(new_topic); |
7971 | 3635 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3636 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3637 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3638 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3639 |
8858 | 3640 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3641 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3642 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3643 g_free(new_topic); |
7971 | 3644 } |
3645 | |
9554 | 3646 static gint |
3647 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3648 { | |
3649 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3650 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3651 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3652 gint ret = 0; |
3653 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3654 gtk_tree_model_get(model, a, |
13965 | 3655 CHAT_USERS_ALIAS_KEY_COLUMN, &user1, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3656 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3657 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3658 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3659 gtk_tree_model_get(model, b, |
13965 | 3660 CHAT_USERS_ALIAS_KEY_COLUMN, &user2, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3661 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3662 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3663 -1); |
9554 | 3664 |
3665 if (user1 == NULL || user2 == NULL) { | |
3666 if (!(user1 == NULL && user2 == NULL)) | |
3667 ret = (user1 == NULL) ? -1: 1; | |
3668 } else if (f1 != f2) { | |
3669 /* sort more important users first */ | |
3670 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3671 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3672 ret = buddy1 ? -1 : 1; |
9554 | 3673 } else { |
13965 | 3674 ret = strcasecmp(user1, user2); |
9554 | 3675 } |
3676 | |
3677 g_free(user1); | |
3678 g_free(user2); | |
3679 | |
3680 return ret; | |
3681 } | |
3682 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3683 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3684 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
|
3685 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3686 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3687 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3688 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3689 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3690 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3691 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3692 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3693 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3694 g_return_if_fail(conv != NULL); |
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 /* 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
|
3697 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
|
3698 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3699 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
|
3700 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3701 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3702 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3703 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3704 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3705 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3706 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3707 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
|
3708 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3709 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3710 const char *alias = name; |
13969 | 3711 char *alias_key = NULL; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3712 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3713 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3714 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3715 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3716 |
13965 | 3717 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3718 alias = gaim_buddy_get_contact_alias(buddy2); |
13965 | 3719 } |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3720 |
13969 | 3721 alias_key = g_utf8_collate_key(alias, strlen(alias)); |
3722 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3723 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
13965 | 3724 CHAT_USERS_ALIAS_COLUMN, alias, |
3725 CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, | |
3726 -1); | |
13969 | 3727 g_free(alias_key); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3728 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3729 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3730 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3731 } |
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 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3734 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3735 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3736 } while (f != 0); |
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 g_free(normalized_name); |
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 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
|
3743 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3744 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3745 GaimPluginProtocolInfo *prpl_info; |
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 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3748 g_return_if_fail(conv != NULL); |
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 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3751 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3752 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3753 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3754 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3755 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3756 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3757 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3758 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3759 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3760 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3761 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3762 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3763 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3764 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3765 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3766 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3767 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3768 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3769 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3770 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3771 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3772 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3773 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3774 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3775 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3776 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3777 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3778 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3779 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3780 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3781 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3782 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3783 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3784 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3785 /* 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
|
3786 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3787 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3788 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3789 /* 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
|
3790 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
|
3791 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3792 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
|
3793 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3794 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3795 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3796 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3797 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3798 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3799 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3800 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
|
3801 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3802 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3803 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
|
3804 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3805 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3806 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3807 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3808 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3809 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3810 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3811 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3812 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3813 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3814 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3815 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3816 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3817 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3818 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3819 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3820 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3821 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3822 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3823 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3824 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3825 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3826 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3827 /* 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
|
3828 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3829 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3830 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3831 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3832 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3833 |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3834 static void send_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3835 { |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3836 g_signal_emit_by_name(gtkconv->entry, "message_send"); |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3837 } |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
3838 |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3839 static void |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3840 entry_popup_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3841 { |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3842 GtkWidget *menuitem; |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3843 GaimGtkConversation *gtkconv = data; |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3844 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3845 g_return_if_fail(menu != NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3846 g_return_if_fail(gtkconv != NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3847 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3848 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
|
3849 G_CALLBACK(send_menu_cb), gtkconv, |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3850 0, 0, NULL); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3851 if (gtk_text_buffer_get_char_count(imhtml->text_buffer) == 0) |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3852 gtk_widget_set_sensitive(menuitem, FALSE); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3853 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 0); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3854 |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3855 menuitem = gtk_separator_menu_item_new(); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3856 gtk_widget_show(menuitem); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3857 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 1); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3858 } |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
3859 |
4359 | 3860 static GtkWidget * |
10810 | 3861 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3862 { |
13419
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
3863 GaimPluginProtocolInfo *prpl_info; |
10810 | 3864 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3865 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3866 GaimConnection *gc; |
4359 | 3867 GtkWidget *vpaned, *hpaned; |
10175 | 3868 GtkWidget *vbox, *hbox, *frame; |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3869 GtkWidget *imhtml_sw; |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3870 GtkPolicyType imhtml_sw_hscroll; |
13994 | 3871 GtkWidget *lbox; |
4359 | 3872 GtkWidget *label; |
3873 GtkWidget *list; | |
7949 | 3874 GtkWidget *sw; |
4359 | 3875 GtkListStore *ls; |
3876 GtkCellRenderer *rend; | |
3877 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3878 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3879 GList *focus_chain = NULL; |
4359 | 3880 |
3881 gtkchat = gtkconv->u.chat; | |
3882 gc = gaim_conversation_get_gc(conv); | |
13424
d52b9874c0de
[gaim-migrate @ 15799]
Richard Laager <rlaager@wiktel.com>
parents:
13419
diff
changeset
|
3883 g_return_val_if_fail(gc != NULL, NULL); |
d52b9874c0de
[gaim-migrate @ 15799]
Richard Laager <rlaager@wiktel.com>
parents:
13419
diff
changeset
|
3884 g_return_val_if_fail(gc->prpl != NULL, NULL); |
13419
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
3885 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
4359 | 3886 |
3887 /* Setup the outer pane. */ | |
3888 vpaned = gtk_vpaned_new(); | |
3889 gtk_widget_show(vpaned); | |
3890 | |
3891 /* Setup the top part of the pane. */ | |
11243 | 3892 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3893 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3894 gtk_widget_show(vbox); |
3895 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3896 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3897 { |
11243 | 3898 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3899 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3900 gtk_widget_show(hbox); |
3901 | |
3902 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3903 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3904 gtk_widget_show(label); |
3905 | |
3906 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3907 |
7971 | 3908 if(prpl_info->set_chat_topic == NULL) { |
3909 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3910 } else { | |
3911 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3912 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3913 } |
3914 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3915 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3916 gtk_widget_show(gtkchat->topic_text); |
3917 } | |
3918 | |
3919 /* Setup the horizontal pane. */ | |
3920 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3921 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3922 gtk_widget_show(hpaned); |
3923 | |
10175 | 3924 /* Setup gtkihmtml. */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3925 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL, &imhtml_sw); |
10175 | 3926 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); |
10389 | 3927 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3928 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3929 gtk_widget_show(frame); | |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3930 gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3931 &imhtml_sw_hscroll, NULL); |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3932 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
3933 imhtml_sw_hscroll, GTK_POLICY_ALWAYS); |
10175 | 3934 |
3935 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3936 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3937 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3938 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3939 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3940 |
4359 | 3941 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3942 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3943 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3944 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3945 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3946 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3947 |
3948 /* Build the right pane. */ | |
11243 | 3949 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3950 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3951 gtk_widget_show(lbox); |
3952 | |
3953 /* Setup the label telling how many people are in the room. */ | |
3954 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3955 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3956 gtk_widget_show(gtkchat->count); | |
3957 | |
3958 /* Setup the list of users. */ | |
7949 | 3959 sw = gtk_scrolled_window_new(NULL, NULL); |
3960 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3961 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3962 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3963 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3964 gtk_widget_show(sw); | |
4359 | 3965 |
9554 | 3966 ls = gtk_list_store_new(CHAT_USERS_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, |
13965 | 3967 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, |
3968 GDK_TYPE_COLOR, G_TYPE_BOOLEAN); | |
3969 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN, | |
9554 | 3970 sort_chat_users, NULL, NULL); |
4359 | 3971 |
3972 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3973 | |
9498 | 3974 rend = gtk_cell_renderer_pixbuf_new(); |
3975 | |
4359 | 3976 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3977 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3978 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3979 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3980 |
3981 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3982 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3983 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3984 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3985 |
9498 | 3986 rend = gtk_cell_renderer_text_new(); |
3987 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3988 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3989 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3990 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3991 NULL); |
4359 | 3992 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3993 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3994 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3995 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3996 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3997 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3998 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3999 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4000 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4001 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4002 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4003 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4004 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4005 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4006 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4007 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4008 #endif |
4359 | 4009 |
4010 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
4011 | |
4012 gtk_widget_set_size_request(list, 150, -1); | |
4013 | |
4014 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
4015 gtk_widget_show(list); | |
4016 | |
4017 gtkchat->list = list; | |
4018 | |
7949 | 4019 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 4020 |
10175 | 4021 /* Setup the bottom half of the conversation window */ |
11243 | 4022 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 4023 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4024 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4025 |
11243 | 4026 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 4027 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
4028 gtk_widget_show(gtkconv->lower_hbox); | |
4029 | |
11243 | 4030 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 4031 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
4032 gtk_widget_show(vbox); | |
4033 | |
10175 | 4034 /* Setup the toolbar, entry widget and all signals */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4035 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar, NULL); |
10080 | 4036 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 4037 gtk_widget_show(frame); |
4038 | |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4039 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4040 G_CALLBACK(entry_popup_menu_cb), gtkconv); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4041 |
9005 | 4042 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 4043 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 4044 gaim_account_get_protocol_name(conv->account)); |
10175 | 4045 gtk_widget_set_size_request(gtkconv->entry, -1, |
4046 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4047 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4048 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 4049 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 4050 |
4051 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 4052 G_CALLBACK(entry_key_press_cb), gtkconv); |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4053 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4054 G_CALLBACK(send_cb), gtkconv); |
4359 | 4055 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 4056 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 4057 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 4058 G_CALLBACK(size_allocate_cb), gtkconv); |
4059 | |
4060 default_formatize(gtkconv); | |
4359 | 4061 |
9080 | 4062 /* |
4063 * Focus for chat windows should be as follows: | |
4064 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
4065 * user list buttons -> entry -> buttons at bottom | |
4066 */ | |
9332 | 4067 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4068 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
4069 | |
4359 | 4070 return vpaned; |
4071 } | |
4072 | |
4073 static GtkWidget * | |
10810 | 4074 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 4075 { |
10810 | 4076 GaimConversation *conv = gtkconv->active_conv; |
10175 | 4077 GtkWidget *frame; |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4078 GtkWidget *imhtml_sw; |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4079 GtkPolicyType imhtml_sw_hscroll; |
4359 | 4080 GtkWidget *paned; |
10175 | 4081 GtkWidget *vbox; |
4082 GtkWidget *vbox2; | |
9080 | 4083 GList *focus_chain = NULL; |
4359 | 4084 |
10175 | 4085 /* Setup the outer pane */ |
4359 | 4086 paned = gtk_vpaned_new(); |
4087 gtk_widget_show(paned); | |
4088 | |
10175 | 4089 /* Setup the top part of the pane */ |
11243 | 4090 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
4091 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 4092 gtk_widget_show(vbox); |
4093 | |
10175 | 4094 /* Setup the gtkimhtml widget */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4095 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL, &imhtml_sw); |
10175 | 4096 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); |
10389 | 4097 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 4098 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
4099 gtk_widget_show(frame); | |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4100 gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4101 &imhtml_sw_hscroll, NULL); |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4102 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(imhtml_sw), |
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4103 imhtml_sw_hscroll, GTK_POLICY_ALWAYS); |
10175 | 4104 |
4105 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4106 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4107 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 4108 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 4109 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 4110 |
4111 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 4112 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 4113 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 4114 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 4115 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 4116 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 4117 |
10175 | 4118 /* Setup the bottom half of the conversation window */ |
11243 | 4119 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 4120 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4121 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4122 |
11243 | 4123 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 4124 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
4125 gtk_widget_show(gtkconv->lower_hbox); | |
4126 | |
11243 | 4127 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 4128 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
4129 gtk_widget_show(vbox2); | |
8821 | 4130 |
10175 | 4131 /* Setup the toolbar, entry widget and all signals */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13233
diff
changeset
|
4132 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar, NULL); |
10080 | 4133 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 4134 gtk_widget_show(frame); |
4135 | |
12636
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4136 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4137 G_CALLBACK(entry_popup_menu_cb), gtkconv); |
886498a66961
[gaim-migrate @ 14972]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
4138 |
9005 | 4139 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 4140 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 4141 gaim_account_get_protocol_name(conv->account)); |
10175 | 4142 gtk_widget_set_size_request(gtkconv->entry, -1, |
4143 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4144 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4145 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 4146 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
|
4147 |
4359 | 4148 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 4149 G_CALLBACK(entry_key_press_cb), gtkconv); |
12710
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4150 g_signal_connect_after(G_OBJECT(gtkconv->entry), "message_send", |
2d326453b33d
[gaim-migrate @ 15054]
Richard Laager <rlaager@wiktel.com>
parents:
12682
diff
changeset
|
4151 G_CALLBACK(send_cb), gtkconv); |
4359 | 4152 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 4153 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 4154 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 4155 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 4156 |
4157 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 4158 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 4159 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 4160 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 4161 |
8481 | 4162 /* had to move this after the imtoolbar is attached so that the |
4163 * signals get fired to toggle the buttons on the toolbar as well. | |
4164 */ | |
10810 | 4165 default_formatize(gtkconv); |
4359 | 4166 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4167 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4168 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
4169 |
8758 | 4170 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 4171 gtkconv->u.im->show_icon = TRUE; |
4359 | 4172 |
9080 | 4173 /* |
4174 * Focus for IM windows should be as follows: | |
10356 | 4175 * Tab title -> conversation scrollback -> entry |
9080 | 4176 */ |
9332 | 4177 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4178 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 4179 |
4359 | 4180 return paned; |
4181 } | |
4182 | |
4183 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4184 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 4185 GtkSelectionData *sd, guint info, guint t, |
4186 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4187 { |
10810 | 4188 GaimConversation *conv = gtkconv->active_conv; |
11581 | 4189 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4190 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4191 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4192 { |
4781 | 4193 GaimBlistNode *n = NULL; |
6695 | 4194 GaimBuddy *b; |
11581 | 4195 GaimGtkConversation *gtkconv = NULL; |
9622 | 4196 |
11812 | 4197 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4198 |
6695 | 4199 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
4200 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
4201 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
4202 b = (GaimBuddy*)n; | |
4203 else | |
4781 | 4204 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4205 |
9622 | 4206 /* |
4207 * If we already have an open conversation with this buddy, then | |
4208 * just move the conv to this window. Otherwise, create a new | |
4209 * conv and add it to this window. | |
4210 */ | |
11338 | 4211 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 4212 if (c != NULL) { |
11581 | 4213 GaimGtkWindow *oldwin; |
4214 gtkconv = GAIM_GTK_CONVERSATION(c); | |
4215 oldwin = gtkconv->win; | |
9622 | 4216 if (oldwin != win) { |
11581 | 4217 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
4218 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 4219 } |
4220 } else { | |
11338 | 4221 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 4222 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 4223 if (gtkconv->win != win) |
4224 { | |
4225 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
4226 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
4227 } | |
9622 | 4228 } |
4229 | |
4230 /* Make this conversation the active conversation */ | |
11581 | 4231 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4232 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4233 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 4234 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4235 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
|
4236 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4237 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4238 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4239 GaimAccount *account; |
11581 | 4240 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4241 |
11137 | 4242 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 4243 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4244 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4245 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4246 { |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
4247 gaim_notify_error(win, NULL, |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4248 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4249 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4250 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4251 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4252 { |
11338 | 4253 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 4254 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 4255 if (gtkconv->win != win) |
4256 { | |
4257 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
4258 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
4259 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4260 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4261 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4262 |
14035 | 4263 g_free(username); |
4264 g_free(protocol); | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4265 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4266 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4267 } |
9525 | 4268 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 4269 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 4270 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 4271 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 4272 } |
10145 | 4273 else |
4274 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4275 } |
4359 | 4276 |
4277 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4278 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4279 { |
10145 | 4280 GTK_IMHTML_DND_TARGETS, |
4281 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
4282 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4283 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4284 |
10810 | 4285 static GaimGtkConversation * |
4286 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
4287 { | |
4288 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
4289 GaimContact *c; | |
4290 GaimBlistNode *cn; | |
10935 | 4291 |
10810 | 4292 if (!bud) |
4293 return NULL; | |
10935 | 4294 |
10810 | 4295 if (!(c = gaim_buddy_get_contact(bud))) |
4296 return NULL; | |
10935 | 4297 |
10810 | 4298 cn = (GaimBlistNode *)c; |
4299 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
4300 GaimConversation *conv; | |
11338 | 4301 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 4302 if (conv->ui_data) |
4303 return conv->ui_data; | |
4304 } | |
4305 } | |
10935 | 4306 |
10810 | 4307 return NULL; |
4308 } | |
4309 | |
11855 | 4310 static void |
4311 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
4312 { | |
4313 GList *list; | |
4314 | |
4315 g_return_if_fail(bnode); | |
4316 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
4317 | |
4318 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
4319 { | |
4320 GaimGtkWindow *win = list->data; | |
4321 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4322 | |
4323 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
4324 continue; | |
4325 | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
4326 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_MENU); |
11855 | 4327 } |
4328 } | |
4329 | |
11581 | 4330 /************************************************************************** |
4331 * Conversation UI operations | |
4332 **************************************************************************/ | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4333 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4334 private_gtkconv_new(GaimConversation *conv, gboolean hidden) |
11581 | 4335 { |
4336 GaimGtkConversation *gtkconv; | |
4337 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 4338 GtkWidget *pane = NULL; |
4339 GtkWidget *tab_cont; | |
11581 | 4340 |
4341 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 4342 conv->ui_data = gtkconv; |
4343 if (!g_list_find(gtkconv->convs, conv)) | |
4344 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 4345 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 4346 return; |
4359 | 4347 } |
4348 | |
11581 | 4349 gtkconv = g_new0(GaimGtkConversation, 1); |
4350 conv->ui_data = gtkconv; | |
4351 gtkconv->active_conv = conv; | |
4352 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
4353 gtkconv->send_history = g_list_append(NULL, NULL); |
11581 | 4354 |
4355 /* Setup some initial variables. */ | |
4356 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
4357 gtkconv->tooltips = gtk_tooltips_new(); | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4358 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4359 gtkconv->unseen_count = 0; |
11581 | 4360 |
4361 if (conv_type == GAIM_CONV_TYPE_IM) { | |
4362 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
4363 | |
4364 pane = setup_im_pane(gtkconv); | |
4365 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
4366 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
4367 pane = setup_chat_pane(gtkconv); | |
4368 } | |
4369 | |
12101 | 4370 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
4371 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
4372 | |
11581 | 4373 if (pane == NULL) { |
4374 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
4375 g_free(gtkconv->u.chat); | |
4376 else if (conv_type == GAIM_CONV_TYPE_IM) | |
4377 g_free(gtkconv->u.im); | |
4378 | |
4379 g_free(gtkconv); | |
4380 conv->ui_data = NULL; | |
4381 return; | |
10449 | 4382 } |
11581 | 4383 |
4384 /* Setup drag-and-drop */ | |
4385 gtk_drag_dest_set(pane, | |
4386 GTK_DEST_DEFAULT_MOTION | | |
4387 GTK_DEST_DEFAULT_DROP, | |
4388 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4389 GDK_ACTION_COPY); | |
4390 gtk_drag_dest_set(pane, | |
4391 GTK_DEST_DEFAULT_MOTION | | |
4392 GTK_DEST_DEFAULT_DROP, | |
4393 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4394 GDK_ACTION_COPY); | |
4395 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4396 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4397 GDK_ACTION_COPY); | |
4398 | |
4399 gtk_drag_dest_set(gtkconv->entry, 0, | |
4400 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4401 GDK_ACTION_COPY); | |
4402 | |
4403 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
4404 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4405 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
4406 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4407 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
4408 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4409 | |
4410 /* Setup the container for the tab. */ | |
4411 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
4412 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
4413 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
4414 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
4415 gtk_widget_show(pane); | |
4416 | |
4417 gtkconv->make_sound = TRUE; | |
4418 | |
4419 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
4420 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4421 else |
11581 | 4422 gtk_widget_hide(gtkconv->toolbar); |
4423 | |
12188 | 4424 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), |
4425 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4426 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4427 gaim_account_get_protocol_name(conv->account)); |
11581 | 4428 |
4429 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
4430 G_CALLBACK(gtk_widget_grab_focus), | |
4431 gtkconv->entry); | |
4432 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4433 if (hidden) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4434 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4435 else |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4436 gaim_gtkconv_placement_place(gtkconv); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
4437 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4438 if (nick_colors == NULL) { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4439 nbr_nick_colors = NUM_NICK_COLORS; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
4440 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
|
4441 } |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4442 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4443 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4444 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4445 gaim_gtkconv_new_hidden(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4446 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4447 private_gtkconv_new(conv, TRUE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4448 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4449 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4450 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4451 gaim_gtkconv_new(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4452 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4453 private_gtkconv_new(conv, FALSE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4454 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4455 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4456 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4457 received_im_msg_cb(GaimAccount *account, char *sender, char *message, |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4458 GaimConversation *conv, int flags) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4459 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4460 GaimConversationUiOps *ui_ops = gaim_gtk_conversations_get_conv_ui_ops(); |
12719
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4461 if (conv != NULL) |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4462 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4463 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4464 /* create hidden conv if hide_new pref is always */ |
12719
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4465 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
|
4466 { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4467 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4468 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4469 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4470 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4471 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4472 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4473 /* 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
|
4474 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
|
4475 !gaim_status_is_available(gaim_account_get_active_status(account))) |
ba053e8d71b6
[gaim-migrate @ 15063]
Richard Laager <rlaager@wiktel.com>
parents:
12710
diff
changeset
|
4476 { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4477 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4478 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4479 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4480 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4481 } |
11581 | 4482 } |
4483 | |
4359 | 4484 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4485 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4486 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4487 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4488 |
10810 | 4489 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4490 /* Don't destroy ourselves until all our convos are gone */ | |
4491 if (gtkconv->convs) | |
4492 return; | |
11508 | 4493 |
11581 | 4494 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4495 | |
9504 | 4496 /* 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
|
4497 gaim_request_close_with_handle(gtkconv); |
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
4498 gaim_notify_close_with_handle(gtkconv); |
4359 | 4499 |
13721
6a02f71a305a
[gaim-migrate @ 16130]
Richard Laager <rlaager@wiktel.com>
parents:
13714
diff
changeset
|
4500 /* Close the "Find" dialog if it's open */ |
6a02f71a305a
[gaim-migrate @ 16130]
Richard Laager <rlaager@wiktel.com>
parents:
13714
diff
changeset
|
4501 if (gtkconv->dialogs.search) |
6a02f71a305a
[gaim-migrate @ 16130]
Richard Laager <rlaager@wiktel.com>
parents:
13714
diff
changeset
|
4502 gtk_widget_destroy(gtkconv->dialogs.search); |
6a02f71a305a
[gaim-migrate @ 16130]
Richard Laager <rlaager@wiktel.com>
parents:
13714
diff
changeset
|
4503 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4504 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4505 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4506 |
11338 | 4507 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4508 if (gtkconv->u.im->icon_timer != 0) |
4509 g_source_remove(gtkconv->u.im->icon_timer); | |
4510 | |
4359 | 4511 if (gtkconv->u.im->anim != NULL) |
4793 | 4512 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4513 |
4514 g_free(gtkconv->u.im); | |
11581 | 4515 } 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
|
4516 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4517 g_free(gtkconv->u.chat); |
4518 } | |
4519 | |
4633 | 4520 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4521 | |
13838
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
4522 gtkconv->send_history = g_list_first(gtkconv->send_history); |
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
4523 g_list_foreach(gtkconv->send_history, (GFunc)g_free, NULL); |
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
4524 g_list_free(gtkconv->send_history); |
dd00149f6f9b
[gaim-migrate @ 16287]
Richard Laager <rlaager@wiktel.com>
parents:
13788
diff
changeset
|
4525 |
4359 | 4526 g_free(gtkconv); |
4527 } | |
4528 | |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4529 |
4359 | 4530 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4531 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4532 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4533 time_t mtime) |
4359 | 4534 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4535 GaimGtkConversation *gtkconv; |
4359 | 4536 |
4537 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4538 |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4539 if (conv != gtkconv->active_conv && |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4540 flags & GAIM_MESSAGE_ACTIVE_ONLY) |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4541 { |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4542 /* Plugins that want these messages suppressed should be |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4543 * calling gaim_conv_im_write(), so they get suppressed here, |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4544 * before being written to the log. */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4545 gaim_debug_info("gtkconv", |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4546 "Suppressing message for an inactive conversation in gaim_gtkconv_write_im()\n"); |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4547 return; |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4548 } |
4359 | 4549 |
6982 | 4550 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4551 } |
4552 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4553 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4554 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4555 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4556 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4557 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4558 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4559 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4560 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4561 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4562 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4563 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4564 && (strlen(tag->name) > 6), FALSE); |
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 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4567 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4568 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4569 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4570 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4571 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4572 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4573 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4574 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4575 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4576 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4577 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4578 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4579 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4580 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4581 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4582 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4583 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4584 gaim_conversation_get_gc(conv); |
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 |
13505
7a6763bbf82b
[gaim-migrate @ 15881]
Richard Laager <rlaager@wiktel.com>
parents:
13504
diff
changeset
|
4587 menu = create_chat_menu(conv, buddyname, gc); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4588 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4589 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4590 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4591 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4592 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4593 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4594 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4595 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4596 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4597 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4598 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4599 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4600 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4601 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4602 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4603 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4604 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4605 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4606 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4607 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4608 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4609 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4610 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4611 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4612 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4613 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4614 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4615 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4616 buddytag = gtk_text_buffer_create_tag( |
11096 | 4617 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4618 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4619 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4620 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4621 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4622 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4623 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4624 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4625 |
4359 | 4626 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4627 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4628 const char *message, GaimMessageFlags flags, |
4359 | 4629 time_t mtime) |
4630 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4631 GaimGtkConversation *gtkconv; |
11581 | 4632 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4633 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4634 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4635 GaimPluginProtocolInfo *prpl_info; |
4359 | 4636 int gtk_font_options = 0; |
12553 | 4637 int gtk_font_options_all = 0; |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4638 int max_scrollback_lines; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4639 int line_count; |
4359 | 4640 char buf2[BUF_LONG]; |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4641 char *mdate; |
4359 | 4642 char color[10]; |
4643 char *str; | |
4644 char *with_font_tag; | |
4896 | 4645 char *sml_attrib = NULL; |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4646 size_t length; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4647 GaimConversationType type; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4648 char *displaying; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4649 gboolean plugin_return; |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4650 |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4651 g_return_if_fail(conv != NULL); |
4359 | 4652 gtkconv = GAIM_GTK_CONVERSATION(conv); |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4653 g_return_if_fail(gtkconv != NULL); |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4654 |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4655 if (conv != gtkconv->active_conv) |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4656 { |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4657 if (flags & GAIM_MESSAGE_ACTIVE_ONLY) |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4658 { |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4659 /* Unless this had GAIM_MESSAGE_NO_LOG, this message |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4660 * was logged. Plugin writers: if this isn't what |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4661 * you wanted, call gaim_conv_im_write() instead of |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4662 * gaim_conversation_write(). */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4663 gaim_debug_info("gtkconv", |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4664 "Suppressing message for an inactive conversation in gaim_gtkconv_write_conv()\n"); |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4665 return; |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4666 } |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4667 |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4668 /* Set the active conversation to the one that just messaged us. */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4669 /* TODO: consider not doing this if the account is offline or something */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4670 if (flags & (GAIM_MESSAGE_SEND | GAIM_MESSAGE_RECV)) |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4671 gaim_gtkconv_switch_active_conversation(conv); |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4672 } |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4673 |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4674 type = gaim_conversation_get_type(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4675 account = gaim_conversation_get_account(conv); |
13419
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
4676 g_return_if_fail(account != NULL); |
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
4677 gc = gaim_account_get_connection(account); |
3e9c865abd3f
[gaim-migrate @ 15794]
Richard Laager <rlaager@wiktel.com>
parents:
13416
diff
changeset
|
4678 g_return_if_fail(gc != NULL); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4679 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4680 displaying = g_strdup(message); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4681 plugin_return = GPOINTER_TO_INT(gaim_signal_emit_return_1( |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4682 gaim_gtk_conversations_get_handle(), (type == GAIM_CONV_TYPE_IM ? |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4683 "displaying-im-msg" : "displaying-chat-msg"), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
4684 account, name, &displaying, conv, flags)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4685 if (plugin_return) |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4686 { |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4687 g_free(displaying); |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4688 return; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4689 } |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4690 message = displaying; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4691 length = strlen(message) + 1; |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
4692 |
11581 | 4693 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4694 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4695 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4696 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4697 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4698 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4699 |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4700 max_scrollback_lines = gaim_prefs_get_int( |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4701 "/gaim/gtk/conversations/scrollback_lines"); |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4702 /* 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
|
4703 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4704 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4705 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4706 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4707 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4708 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4709 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4710 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4711 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4712 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4713 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4714 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4715 |
12939
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4716 if (type == GAIM_CONV_TYPE_CHAT) |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4717 { |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4718 /* Create anchor for user */ |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4719 GtkTextIter iter; |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4720 char *tmp = g_strconcat("user:", name, NULL); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4721 |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4722 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
|
4723 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
|
4724 tmp, &iter, TRUE); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4725 g_free(tmp); |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4726 } |
7f633dd625a9
[gaim-migrate @ 15292]
Richard Laager <rlaager@wiktel.com>
parents:
12902
diff
changeset
|
4727 |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4728 if (gaim_prefs_get_bool("/gaim/gtk/conversations/use_smooth_scrolling")) |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4729 gtk_font_options_all |= GTK_IMHTML_USE_SMOOTHSCROLLING; |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4730 |
8677 | 4731 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
12553 | 4732 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", gtk_font_options_all); |
8677 | 4733 |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4734 mdate = gaim_signal_emit_return_1(gaim_gtk_conversations_get_handle(), |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4735 "conversation-timestamp", |
13987
f94309c7c480
[gaim-migrate @ 16559]
Richard Laager <rlaager@wiktel.com>
parents:
13972
diff
changeset
|
4736 conv, mtime); |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4737 if (mdate == NULL) |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4738 { |
13987
f94309c7c480
[gaim-migrate @ 16559]
Richard Laager <rlaager@wiktel.com>
parents:
13972
diff
changeset
|
4739 struct tm *tm = localtime(&mtime); |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4740 if (time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
13987
f94309c7c480
[gaim-migrate @ 16559]
Richard Laager <rlaager@wiktel.com>
parents:
13972
diff
changeset
|
4741 mdate = g_strdup(gaim_date_format_long(tm)); |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4742 else |
13987
f94309c7c480
[gaim-migrate @ 16559]
Richard Laager <rlaager@wiktel.com>
parents:
13972
diff
changeset
|
4743 mdate = g_strdup(gaim_time_format(tm)); |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4744 } |
4359 | 4745 |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4746 sml_attrib = g_strdup_printf("sml=\"%s\"", gaim_account_get_protocol_name(account)); |
7440 | 4747 |
10503 | 4748 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4749 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4750 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4751 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4752 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4753 |
7956 | 4754 /* this is gonna crash one day, I can feel it. */ |
4755 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4756 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4757 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4758 } |
4359 | 4759 |
12553 | 4760 |
10737 | 4761 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4762 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4763 g_snprintf(buf2, sizeof(buf2), |
8690 | 4764 "<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
|
4765 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4766 |
12553 | 4767 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
7440 | 4768 |
8722 | 4769 } else if (flags & GAIM_MESSAGE_ERROR) { |
4770 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4771 "<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
|
4772 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4773 |
12553 | 4774 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
8962 | 4775 |
7431 | 4776 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4777 g_snprintf(buf2, BUF_LONG, |
8690 | 4778 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4779 sml_attrib ? sml_attrib : "", message); |
7440 | 4780 |
12553 | 4781 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
10346 | 4782 } else if (flags & GAIM_MESSAGE_RAW) { |
12553 | 4783 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, gtk_font_options_all); |
10346 | 4784 } else { |
4895 | 4785 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4786 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
|
4787 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4788 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4789 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
|
4790 int tag_end_offset = 0; |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4791 GtkSmileyTree *tree = NULL; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4792 GHashTable *smiley_data = NULL; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4793 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4794 if (flags & GAIM_MESSAGE_SEND) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4795 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4796 /* Temporarily revert to the original smiley-data to avoid showing up |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4797 * custom smileys of the buddy when sending message |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4798 */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4799 tree = GTK_IMHTML(gtkconv->imhtml)->default_smilies; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4800 GTK_IMHTML(gtkconv->imhtml)->default_smilies = |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4801 GTK_IMHTML(gtkconv->entry)->default_smilies; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4802 smiley_data = GTK_IMHTML(gtkconv->imhtml)->smiley_data; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4803 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
|
4804 } |
7440 | 4805 |
6621 | 4806 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4807 str = g_malloc(1024); |
7440 | 4808 |
4359 | 4809 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4810 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4811 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4812 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4813 tag_start_offset += 3; |
4359 | 4814 } |
4815 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4816 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4817 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4818 tag_end_offset = 2; |
4359 | 4819 strcpy(color, "#00FF00"); |
4820 } | |
7440 | 4821 } |
4359 | 4822 else { |
10504 | 4823 if (gaim_message_meify(new_message, -1)) { |
4359 | 4824 str = g_malloc(1024); |
7440 | 4825 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4826 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4827 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
|
4828 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4829 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4830 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4831 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4832 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4833 } |
7440 | 4834 |
6621 | 4835 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4836 strcpy(color, HIGHLIGHT_COLOR); |
4359 | 4837 else |
4838 strcpy(color, "#062585"); | |
4839 } | |
4840 else { | |
4841 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4842 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4843 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
|
4844 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4845 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4846 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4847 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4848 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4849 } |
6621 | 4850 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4851 strcpy(color, HIGHLIGHT_COLOR); |
6621 | 4852 else if (flags & GAIM_MESSAGE_RECV) { |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
4853 if (type == GAIM_CONV_TYPE_CHAT) { |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
4854 GdkColor *col = get_nick_color(gtkconv, name); |
10346 | 4855 |
10108 | 4856 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4857 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4858 } else |
7854 | 4859 strcpy(color, RECV_COLOR); |
4359 | 4860 } |
6621 | 4861 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4862 strcpy(color, SEND_COLOR); |
10892 | 4863 else { |
4864 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4865 strcpy(color, "#000000"); | |
4866 } | |
4359 | 4867 } |
4868 } | |
10892 | 4869 |
14035 | 4870 g_free(alias_escaped); |
11508 | 4871 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4872 /* 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
|
4873 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4874 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4875 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4876 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4877 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4878 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4879 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4880 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4881 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4882 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4883 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4884 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4885 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4886 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4887 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4888 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4889 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4890 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4891 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4892 /* 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
|
4893 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4894 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4895 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4896 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4897 } |
7440 | 4898 |
12553 | 4899 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
|
4900 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4901 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4902 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4903 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4904 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4905 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4906 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4907 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4908 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4909 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4910 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4911 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4912 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4913 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4914 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4915 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4916 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4917 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4918 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4919 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4920 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4921 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4922 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4923 |
4359 | 4924 g_free(str); |
4925 | |
4895 | 4926 if(gc){ |
4896 | 4927 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4928 char *post = "</font>"; |
4929 int pre_len = strlen(pre); | |
4930 int post_len = strlen(post); | |
7440 | 4931 |
4895 | 4932 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4933 |
4895 | 4934 strcpy(with_font_tag, pre); |
4935 memcpy(with_font_tag + pre_len, new_message, length); | |
4936 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4937 |
4895 | 4938 length += pre_len + post_len; |
4939 g_free(pre); | |
4940 } | |
4608 | 4941 else |
4895 | 4942 with_font_tag = g_memdup(new_message, length); |
7440 | 4943 |
8962 | 4944 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
12553 | 4945 with_font_tag, gtk_font_options | gtk_font_options_all); |
7440 | 4946 |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4947 if (flags & GAIM_MESSAGE_SEND) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4948 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4949 /* Restore the smiley-data */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4950 GTK_IMHTML(gtkconv->imhtml)->default_smilies = tree; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4951 GTK_IMHTML(gtkconv->imhtml)->smiley_data = smiley_data; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4952 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
4953 |
7440 | 4954 g_free(with_font_tag); |
7447 | 4955 g_free(new_message); |
7440 | 4956 } |
4957 | |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4958 g_free(mdate); |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
4959 g_free(sml_attrib); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4960 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4961 /* Tab highlighting stuff */ |
13138
277c7a62650b
[gaim-migrate @ 15500]
Richard Laager <rlaager@wiktel.com>
parents:
13131
diff
changeset
|
4962 if (!(flags & GAIM_MESSAGE_SEND) && !gaim_gtkconv_has_focus(conv)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4963 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4964 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4965 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4966 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4967 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4968 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4969 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4970 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4971 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
|
4972 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4973 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4974 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4975 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4976 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4977 } |
12902
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4978 |
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4979 gaim_signal_emit(gaim_gtk_conversations_get_handle(), |
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4980 (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
|
4981 account, name, message, conv, flags); |
12902
3bf3f489b64b
[gaim-migrate @ 15255]
Richard Laager <rlaager@wiktel.com>
parents:
12899
diff
changeset
|
4982 g_free(displaying); |
4359 | 4983 } |
13965 | 4984 static void |
4985 gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *cbuddies, gboolean new_arrivals) | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4986 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4987 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4988 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4989 GaimGtkChatPane *gtkchat; |
13965 | 4990 GtkListStore *ls; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4991 GList *l; |
13965 | 4992 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4993 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4994 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4995 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4996 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4997 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4998 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4999 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5000 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
|
5001 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5002 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5003 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5004 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5005 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5006 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5007 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5008 |
13965 | 5009 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); |
5010 | |
5011 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, | |
5012 GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID); | |
5013 | |
5014 l = cbuddies; | |
5015 while (l != NULL) { | |
5016 add_chat_buddy_common(conv, (GaimConvChatBuddy *)l->data, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5017 l = l->next; |
13965 | 5018 } |
5019 | |
5020 /* Currently GTK+ maintains our sorted list after it's in the tree. | |
5021 * This may change if it turns out we can manage it faster ourselves. | |
5022 */ | |
5023 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN, | |
5024 GTK_SORT_ASCENDING); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5025 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5026 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5027 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5028 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
|
5029 const char *new_name, const char *new_alias) |
4359 | 5030 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5031 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5032 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5033 GaimGtkChatPane *gtkchat; |
11869 | 5034 GaimConvChatBuddyFlags flags; |
13965 | 5035 GaimConvChatBuddy *cbuddy; |
4359 | 5036 GtkTreeIter iter; |
5037 GtkTreeModel *model; | |
5038 int f = 1; | |
5039 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5040 chat = GAIM_CONV_CHAT(conv); |
4359 | 5041 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5042 gtkchat = gtkconv->u.chat; | |
5043 | |
9554 | 5044 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5045 | |
5046 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5047 return; | |
5048 | |
5049 while (f != 0) { | |
5050 char *val; | |
5051 | |
11869 | 5052 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 5053 |
5054 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
5055 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5056 g_free(val); | |
4359 | 5057 break; |
5058 } | |
9554 | 5059 |
5060 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5061 | |
5062 g_free(val); | |
4359 | 5063 } |
5064 | |
9554 | 5065 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 5066 return; |
5067 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
5068 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
5069 |
13965 | 5070 cbuddy = gaim_conv_chat_cb_new(new_name, new_alias, flags); |
14035 | 5071 |
13965 | 5072 add_chat_buddy_common(conv, cbuddy, old_name); |
4359 | 5073 } |
5074 | |
5075 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5076 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5077 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5078 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5079 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5080 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5081 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5082 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5083 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5084 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5085 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5086 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5087 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5088 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5089 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5090 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5091 |
12982 | 5092 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
|
5093 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5094 for (l = users; l != NULL; l = l->next) { |
9554 | 5095 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5096 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
5097 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 5098 continue; |
5099 | |
5100 do { | |
5101 char *val; | |
5102 | |
5103 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
5104 CHAT_USERS_NAME_COLUMN, &val, -1); | |
5105 | |
9696 | 5106 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
5107 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 5108 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 5109 #else |
5110 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5111 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5112 #endif | |
5113 } | |
9554 | 5114 else |
5115 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5116 | |
5117 g_free(val); | |
5118 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5119 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5120 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5121 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5122 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5123 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5124 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5125 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5126 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5127 |
9554 | 5128 static void |
5129 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
5130 { | |
5131 GaimConvChat *chat; | |
11869 | 5132 GaimConvChatBuddyFlags flags; |
13965 | 5133 GaimConvChatBuddy *cbuddy; |
9554 | 5134 GaimGtkConversation *gtkconv; |
5135 GaimGtkChatPane *gtkchat; | |
5136 GtkTreeIter iter; | |
5137 GtkTreeModel *model; | |
5138 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5139 char *alias = NULL; |
9554 | 5140 |
5141 chat = GAIM_CONV_CHAT(conv); | |
5142 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5143 gtkchat = gtkconv->u.chat; | |
5144 | |
5145 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
5146 | |
5147 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5148 return; | |
5149 | |
5150 while (f != 0) { | |
5151 char *val; | |
5152 | |
5153 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5154 | |
5155 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
5156 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 5157 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
5158 g_free(val); | |
5159 break; | |
5160 } | |
5161 | |
5162 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5163 | |
5164 g_free(val); | |
5165 } | |
5166 | |
5167 if (!gaim_conv_chat_find_user(chat, user)) | |
12982 | 5168 { |
5169 g_free(alias); | |
9554 | 5170 return; |
12982 | 5171 } |
9554 | 5172 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5173 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5174 |
11869 | 5175 flags = gaim_conv_chat_user_get_flags(chat, user); |
5176 | |
13965 | 5177 cbuddy = gaim_conv_chat_cb_new(user, alias, flags); |
14035 | 5178 |
13965 | 5179 add_chat_buddy_common(conv, cbuddy, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
5180 g_free(alias); |
9554 | 5181 } |
5182 | |
11581 | 5183 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5184 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5185 { |
11581 | 5186 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
5187 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5188 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5189 |
11581 | 5190 win = gtkconv->win; |
5191 | |
5192 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
|
5193 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5194 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5195 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5196 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
5197 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5198 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5199 |
12335 | 5200 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data) |
5201 { | |
5202 GtkIMHtmlSmiley *smiley; | |
12682 | 5203 |
12335 | 5204 smiley = (GtkIMHtmlSmiley *)user_data; |
5205 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
12682 | 5206 |
12335 | 5207 if (smiley->icon) |
5208 g_object_ref(G_OBJECT(smiley->icon)); | |
12682 | 5209 #ifdef DEBUG_CUSTOM_SMILEY |
5210 gaim_debug_info("custom-smiley", "gaim_gtkconv_custom_smiley_allocated(): got GdkPixbufAnimation %p for smiley '%s'\n", smiley->icon, smiley->smile); | |
12335 | 5211 #endif |
5212 } | |
5213 | |
5214 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data) | |
5215 { | |
5216 GtkIMHtmlSmiley *smiley; | |
5217 GtkWidget *icon = NULL; | |
5218 GtkTextChildAnchor *anchor = NULL; | |
5219 GSList *current = NULL; | |
12682 | 5220 |
12335 | 5221 smiley = (GtkIMHtmlSmiley *)user_data; |
5222 if (!smiley->imhtml) { | |
5223 #ifdef DEBUG_CUSTOM_SMILEY | |
12682 | 5224 gaim_debug_error("custom-smiley", "gaim_gtkconv_custom_smiley_closed(): orphan smiley found: %p\n", smiley); |
12335 | 5225 #endif |
5226 g_object_unref(G_OBJECT(loader)); | |
5227 smiley->loader = NULL; | |
5228 return; | |
5229 } | |
5230 | |
5231 for (current = smiley->anchors; current; current = g_slist_next(current)) { | |
5232 | |
5233 icon = gtk_image_new_from_animation(smiley->icon); | |
5234 | |
12682 | 5235 #ifdef DEBUG_CUSTOM_SMILEY |
5236 gaim_debug_info("custom-smiley", "gaim_gtkconv_custom_smiley_closed(): got GtkImage %p from GtkPixbufAnimation %p for smiley '%s'\n", | |
5237 icon, smiley->icon, smiley->smile); | |
12335 | 5238 #endif |
5239 if (icon) { | |
5240 gtk_widget_show(icon); | |
12682 | 5241 |
12335 | 5242 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
5243 | |
13518
cd21f1738063
[gaim-migrate @ 15894]
Richard Laager <rlaager@wiktel.com>
parents:
13505
diff
changeset
|
5244 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", gaim_unescape_html(smiley->smile), g_free); |
12335 | 5245 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley->smile), g_free); |
12682 | 5246 |
12335 | 5247 if (smiley->imhtml) |
5248 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(smiley->imhtml), icon, anchor); | |
5249 } | |
5250 | |
5251 } | |
5252 | |
5253 g_slist_free(smiley->anchors); | |
5254 smiley->anchors = NULL; | |
12682 | 5255 |
12335 | 5256 g_object_unref(G_OBJECT(loader)); |
5257 smiley->loader = NULL; | |
5258 } | |
5259 | |
10526 | 5260 static gboolean |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5261 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
|
5262 { |
10526 | 5263 GtkIMHtmlSmiley *smiley; |
5264 GdkPixbufLoader *loader; | |
12618
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 smiley = gtk_imhtml_smiley_get(imhtml, sml, smile); |
10526 | 5267 |
5268 if (smiley) { | |
11525 | 5269 |
5270 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
5271 return FALSE; | |
5272 } | |
5273 | |
5274 /* Close the old GdkPixbufAnimation, then create a new one for | |
5275 * the smiley we are about to receive */ | |
5276 g_object_unref(G_OBJECT(smiley->icon)); | |
5277 | |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5278 /* XXX: Is it necessary to _unref the loader first? */ |
11525 | 5279 smiley->loader = gdk_pixbuf_loader_new(); |
12335 | 5280 smiley->icon = NULL; |
5281 | |
5282 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); | |
5283 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
5284 | |
11525 | 5285 return TRUE; |
10526 | 5286 } |
5287 | |
5288 loader = gdk_pixbuf_loader_new(); | |
5289 | |
5290 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
5291 /* 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
|
5292 GtkIMHtmlSmiley by opaque */ |
10526 | 5293 smiley = g_new0(GtkIMHtmlSmiley, 1); |
5294 smiley->file = NULL; | |
5295 smiley->smile = g_strdup(smile); | |
5296 smiley->loader = loader; | |
11525 | 5297 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 5298 |
12335 | 5299 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); |
5300 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
11525 | 5301 |
12618
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5302 gtk_imhtml_associate_smiley(imhtml, sml, smiley); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5303 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5304 return TRUE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5305 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5306 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5307 static gboolean |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5308 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
|
5309 { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5310 GaimGtkConversation *gtkconv; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5311 struct smiley_list *list; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5312 const char *sml = NULL, *conv_sml; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5313 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5314 if (!conv || !smile || !*smile) { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5315 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5316 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5317 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5318 /* If smileys are off, return false */ |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5319 if (gaim_gtkthemes_smileys_disabled()) |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5320 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5321 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5322 /* If possible add this smiley to the current theme. |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5323 * 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
|
5324 conv_sml = gaim_account_get_protocol_name(conv->account); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5325 gtkconv = GAIM_GTK_CONVERSATION(conv); |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5326 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5327 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
|
5328 if (!strcmp(list->sml, conv_sml)) { |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5329 sml = list->sml; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5330 break; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5331 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5332 } |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5333 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5334 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
|
5335 return FALSE; |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5336 |
204bd8fac61f
[gaim-migrate @ 14954]
Richard Laager <rlaager@wiktel.com>
parents:
12616
diff
changeset
|
5337 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
|
5338 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
|
5339 return FALSE; |
10537 | 5340 |
10526 | 5341 return TRUE; |
5342 } | |
5343 | |
10537 | 5344 static void |
10526 | 5345 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 5346 const guchar *data, gsize size) |
10526 | 5347 { |
5348 GaimGtkConversation *gtkconv; | |
5349 GtkIMHtmlSmiley *smiley; | |
10537 | 5350 GdkPixbufLoader *loader; |
10526 | 5351 const char *sml; |
5352 | |
5353 sml = gaim_account_get_protocol_name(conv->account); | |
5354 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5355 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5356 | |
10537 | 5357 if (!smiley) |
10526 | 5358 return; |
10537 | 5359 |
10526 | 5360 loader = smiley->loader; |
10537 | 5361 if (!loader) |
10526 | 5362 return; |
5363 | |
5364 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
5365 } | |
5366 | |
5367 static void | |
5368 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
5369 { | |
5370 GaimGtkConversation *gtkconv; | |
5371 GtkIMHtmlSmiley *smiley; | |
5372 GdkPixbufLoader *loader; | |
5373 const char *sml; | |
5374 | |
5375 g_return_if_fail(conv != NULL); | |
5376 g_return_if_fail(smile != NULL); | |
5377 | |
5378 sml = gaim_account_get_protocol_name(conv->account); | |
5379 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5380 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5381 | |
10537 | 5382 if (!smiley) |
10526 | 5383 return; |
5384 | |
5385 loader = smiley->loader; | |
5386 | |
10537 | 5387 if (!loader) |
10526 | 5388 return; |
10537 | 5389 |
12335 | 5390 |
11525 | 5391 |
10526 | 5392 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
5393 | |
5394 gdk_pixbuf_loader_close(loader, NULL); | |
12335 | 5395 |
10526 | 5396 } |
5397 | |
11581 | 5398 /* |
5399 * Makes sure all the menu items and all the buttons are hidden/shown and | |
5400 * sensitive/insensitive. This is called after changing tabs and when an | |
5401 * account signs on or off. | |
5402 */ | |
5403 static void | |
5404 gray_stuff_out(GaimGtkConversation *gtkconv) | |
5405 { | |
5406 GaimGtkWindow *win; | |
5407 GaimConversation *conv = gtkconv->active_conv; | |
5408 GaimConnection *gc; | |
5409 GaimPluginProtocolInfo *prpl_info = NULL; | |
5410 GdkPixbuf *window_icon = NULL; | |
5411 GtkIMHtmlButtons buttons; | |
5412 GaimAccount *account; | |
5413 | |
5414 win = gaim_gtkconv_get_window(gtkconv); | |
5415 gc = gaim_conversation_get_gc(conv); | |
5416 account = gaim_conversation_get_account(conv); | |
5417 | |
5418 if (gc != NULL) | |
5419 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
5420 | |
11594 | 5421 if (win->menu.send_to != NULL) |
11734 | 5422 update_send_to_selection(win); |
11581 | 5423 |
5424 /* | |
5425 * Handle hiding and showing stuff based on what type of conv this is. | |
5426 * Stuff that Gaim IMs support in general should be shown for IM | |
5427 * conversations. Stuff that Gaim chats support in general should be | |
5428 * shown for chat conversations. It doesn't matter whether the PRPL | |
5429 * supports it or not--that only affects if the button or menu item | |
5430 * is sensitive or not. | |
5431 */ | |
5432 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
5433 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
5434 | |
5435 /* Deal with menu items */ | |
5436 gtk_widget_show(win->menu.view_log); | |
5437 gtk_widget_show(win->menu.send_file); | |
5438 gtk_widget_show(win->menu.add_pounce); | |
5439 gtk_widget_show(win->menu.get_info); | |
5440 gtk_widget_hide(win->menu.invite); | |
5441 gtk_widget_show(win->menu.alias); | |
5442 gtk_widget_show(win->menu.block); | |
5443 | |
13131 | 5444 if ((account == NULL) || gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { |
11581 | 5445 gtk_widget_show(win->menu.add); |
5446 gtk_widget_hide(win->menu.remove); | |
5447 } else { | |
5448 gtk_widget_show(win->menu.remove); | |
5449 gtk_widget_hide(win->menu.add); | |
5450 } | |
5451 | |
5452 gtk_widget_show(win->menu.insert_link); | |
5453 gtk_widget_show(win->menu.insert_image); | |
5454 gtk_widget_show(win->menu.show_icon); | |
5455 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
5456 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
5457 | |
5458 /* Deal with menu items */ | |
5459 gtk_widget_show(win->menu.view_log); | |
5460 gtk_widget_hide(win->menu.send_file); | |
5461 gtk_widget_hide(win->menu.add_pounce); | |
5462 gtk_widget_hide(win->menu.get_info); | |
5463 gtk_widget_show(win->menu.invite); | |
5464 gtk_widget_show(win->menu.alias); | |
5465 gtk_widget_hide(win->menu.block); | |
5466 gtk_widget_hide(win->menu.show_icon); | |
5467 | |
13131 | 5468 if ((account == NULL) || gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { |
11581 | 5469 /* If the chat is NOT in the buddy list */ |
5470 gtk_widget_show(win->menu.add); | |
5471 gtk_widget_hide(win->menu.remove); | |
5472 } else { | |
5473 /* If the chat IS in the buddy list */ | |
5474 gtk_widget_hide(win->menu.add); | |
5475 gtk_widget_show(win->menu.remove); | |
5476 } | |
5477 | |
5478 gtk_widget_show(win->menu.insert_link); | |
5479 gtk_widget_hide(win->menu.insert_image); | |
5480 } | |
5481 | |
5482 /* | |
5483 * Handle graying stuff out based on whether an account is connected | |
5484 * and what features that account supports. | |
5485 */ | |
5486 if ((gc != NULL) && | |
12012 | 5487 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
5488 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
5489 { | |
11581 | 5490 /* Account is online */ |
5491 /* Deal with the toolbar */ | |
12012 | 5492 if (conv->features & GAIM_CONNECTION_HTML) |
5493 { | |
5494 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
5495 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
5496 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
5497 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
5498 { | |
5499 buttons &= ~GTK_IMHTML_GROW; | |
5500 buttons &= ~GTK_IMHTML_SHRINK; | |
5501 } | |
5502 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
5503 buttons &= ~GTK_IMHTML_LINKDESC; | |
5504 } else { | |
12216 | 5505 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
12012 | 5506 } |
12216 | 5507 |
5508 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
5509 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
5510 buttons &= ~GTK_IMHTML_IMAGE; | |
5511 | |
12012 | 5512 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); |
13131 | 5513 if (account != NULL) |
5514 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 5515 |
5516 /* Deal with menu items */ | |
12012 | 5517 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5518 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5519 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
5520 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
5521 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 5522 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 5523 |
5524 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
5525 { | |
5526 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
5527 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
5528 gtk_widget_set_sensitive(win->menu.send_file, | |
5529 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
5530 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
5531 gtk_widget_set_sensitive(win->menu.alias, | |
13131 | 5532 (account != NULL) && |
12012 | 5533 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); |
5534 } | |
5535 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5536 { | |
5537 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
5538 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
5539 gtk_widget_set_sensitive(win->menu.alias, | |
13131 | 5540 (account != NULL) && |
12012 | 5541 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); |
5542 } | |
11581 | 5543 |
13994 | 5544 |
12012 | 5545 } else { |
11581 | 5546 /* Account is offline */ |
5547 /* Or it's a chat that we've left. */ | |
5548 | |
5549 /* Then deal with menu items */ | |
12012 | 5550 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5551 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
5552 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5553 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
5554 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
5555 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
5556 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
5557 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
5558 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
5559 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
5560 } | |
11581 | 5561 |
5562 /* | |
5563 * Update the window's icon | |
5564 */ | |
12171 | 5565 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5566 { |
12171 | 5567 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
5568 (gtkconv->u.im->anim)) | |
5569 { | |
5570 window_icon = | |
5571 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5572 g_object_ref(window_icon); | |
5573 } else { | |
5574 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5575 } | |
5576 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5577 if (window_icon != NULL) | |
5578 g_object_unref(G_OBJECT(window_icon)); | |
5579 } | |
11581 | 5580 } |
5581 | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5582 static void |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5583 gaim_gtkconv_update_fields(GaimConversation *conv, GaimGtkConvFields fields) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5584 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5585 GaimGtkConversation *gtkconv; |
11581 | 5586 GaimGtkWindow *win; |
10116 | 5587 |
4359 | 5588 gtkconv = GAIM_GTK_CONVERSATION(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5589 if (!gtkconv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5590 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5591 win = gaim_gtkconv_get_window(gtkconv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5592 if (!win) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5593 return; |
13090 | 5594 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5595 if (fields & GAIM_GTKCONV_SET_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5596 { |
4359 | 5597 gaim_conversation_autoset_title(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5598 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5599 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5600 if (fields & GAIM_GTKCONV_BUDDY_ICON) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5601 { |
11338 | 5602 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5603 gaim_gtkconv_update_buddy_icon(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5604 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5605 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5606 if (fields & GAIM_GTKCONV_MENU) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5607 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5608 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5609 generate_send_to_items(win); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5610 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5611 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5612 if (fields & GAIM_GTKCONV_TAB_ICON) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5613 { |
6395 | 5614 update_tab_icon(conv); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5615 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
|
5616 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5617 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5618 if ((fields & GAIM_GTKCONV_TOPIC) && |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5619 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5620 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5621 const char *topic; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5622 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5623 GaimGtkChatPane *gtkchat = gtkconv->u.chat; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5624 |
13350
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5625 if (gtkchat->topic_text != NULL) |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5626 { |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5627 topic = gaim_conv_chat_get_topic(chat); |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5628 |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5629 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5630 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5631 topic ? topic : "", NULL); |
7c8f03ad0e8e
[gaim-migrate @ 15722]
Richard Laager <rlaager@wiktel.com>
parents:
13326
diff
changeset
|
5632 } |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5633 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5634 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5635 if (fields & GAIM_GTKCONV_SMILEY_THEME) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5636 gaim_gtkthemes_smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5637 |
13131 | 5638 if ((fields & GAIM_GTKCONV_COLORIZE_TITLE) || |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5639 (fields & GAIM_GTKCONV_SET_TITLE)) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5640 { |
9472 | 5641 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5642 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5643 GaimAccount *account = gaim_conversation_get_account(conv); |
13521
d593b7d4f29c
[gaim-migrate @ 15897]
Richard Laager <rlaager@wiktel.com>
parents:
13519
diff
changeset
|
5644 AtkObject *accessibility_obj; |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5645 /* 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
|
5646 char style[51]; |
4736 | 5647 |
11338 | 5648 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5649 im = GAIM_CONV_IM(conv); |
4359 | 5650 |
13131 | 5651 if ((account == NULL) || |
5652 !gaim_account_is_connected(account) || | |
5653 ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5654 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) | |
9472 | 5655 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); |
5656 else | |
5657 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5658 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5659 *style = '\0'; |
4359 | 5660 |
5661 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5662 gtk_widget_realize(gtkconv->tab_label); | |
5663 | |
13521
d593b7d4f29c
[gaim-migrate @ 15897]
Richard Laager <rlaager@wiktel.com>
parents:
13519
diff
changeset
|
5664 accessibility_obj = gtk_widget_get_accessible(gtkconv->tab_cont); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5665 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5666 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5667 { |
13521
d593b7d4f29c
[gaim-migrate @ 15897]
Richard Laager <rlaager@wiktel.com>
parents:
13519
diff
changeset
|
5668 atk_object_set_description(accessibility_obj, _("Typing")); |
11759 | 5669 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5670 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5671 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5672 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5673 { |
13536
977714c5e8a6
[gaim-migrate @ 15913]
Richard Laager <rlaager@wiktel.com>
parents:
13525
diff
changeset
|
5674 atk_object_set_description(accessibility_obj, _("Stopped Typing")); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5675 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5676 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5677 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5678 { |
13536
977714c5e8a6
[gaim-migrate @ 15913]
Richard Laager <rlaager@wiktel.com>
parents:
13525
diff
changeset
|
5679 atk_object_set_description(accessibility_obj, _("Nick Said")); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5680 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5681 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5682 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5683 { |
13521
d593b7d4f29c
[gaim-migrate @ 15897]
Richard Laager <rlaager@wiktel.com>
parents:
13519
diff
changeset
|
5684 atk_object_set_description(accessibility_obj, _("Unread Messages")); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5685 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5686 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5687 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5688 { |
13536
977714c5e8a6
[gaim-migrate @ 15913]
Richard Laager <rlaager@wiktel.com>
parents:
13525
diff
changeset
|
5689 atk_object_set_description(accessibility_obj, _("New Event")); |
11758 | 5690 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5691 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5692 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5693 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5694 { |
8536 | 5695 char *html_title,*label; |
5696 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5697 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5698 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5699 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5700 style, html_title); |
8536 | 5701 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5702 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5703 g_free(label); |
4359 | 5704 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5705 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5706 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5707 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5708 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5709 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5710 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5711 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5712 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5713 gtk_window_set_title(GTK_WINDOW(win->window), title); |
9472 | 5714 |
5715 g_free(title); | |
4359 | 5716 } |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5717 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5718 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5719 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5720 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5721 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5722 GaimGtkConvFields flags = 0; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5723 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5724 g_return_if_fail(conv != NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5725 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5726 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5727 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5728 flags = GAIM_GTKCONV_ALL; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5729 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5730 else if (type == GAIM_CONV_UPDATE_TYPING || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5731 type == GAIM_CONV_UPDATE_UNSEEN || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5732 type == GAIM_CONV_UPDATE_TITLE) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5733 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5734 flags = GAIM_GTKCONV_COLORIZE_TITLE; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5735 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5736 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5737 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5738 flags = GAIM_GTKCONV_TOPIC; |
4359 | 5739 } |
5740 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5741 type == GAIM_CONV_ACCOUNT_OFFLINE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5742 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5743 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
|
5744 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5745 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5746 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5747 flags = GAIM_GTKCONV_TAB_ICON; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5748 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5749 else if (type == GAIM_CONV_UPDATE_ADD || |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5750 type == GAIM_CONV_UPDATE_REMOVE || |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5751 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5752 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5753 flags = GAIM_GTKCONV_SET_TITLE | GAIM_GTKCONV_MENU; |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5754 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5755 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5756 { |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5757 flags = GAIM_GTKCONV_BUDDY_ICON; |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5758 } |
10665 | 5759 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5760 { | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5761 flags = GAIM_GTKCONV_MENU; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5762 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5763 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5764 gaim_gtkconv_update_fields(conv, flags); |
4359 | 5765 } |
5766 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5767 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5768 { |
11581 | 5769 gaim_gtkconv_new, |
13476
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5770 gaim_gtkconv_destroy, /* destroy_conversation */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5771 NULL, /* write_chat */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5772 gaim_gtkconv_write_im, /* write_im */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5773 gaim_gtkconv_write_conv, /* write_conv */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5774 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5775 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5776 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5777 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5778 gaim_gtkconv_present_conversation, /* present */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5779 gaim_gtkconv_has_focus, /* has_focus */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5780 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5781 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ |
465c368366f8
[gaim-migrate @ 15852]
Richard Laager <rlaager@wiktel.com>
parents:
13457
diff
changeset
|
5782 gaim_gtkconv_custom_smiley_close /* custom_smiley_close */ |
4359 | 5783 }; |
5784 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5785 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5786 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5787 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5788 return &conversation_ui_ops; |
4359 | 5789 } |
5790 | |
5791 /************************************************************************** | |
5792 * Public conversation utility functions | |
5793 **************************************************************************/ | |
5794 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5795 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5796 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5797 GaimGtkConversation *gtkconv; |
11581 | 5798 GaimGtkWindow *win; |
4359 | 5799 |
10381 | 5800 GdkPixbufLoader *loader; |
5801 GdkPixbufAnimation *anim; | |
4359 | 5802 GError *err = NULL; |
5803 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5804 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5805 size_t len; |
4359 | 5806 |
5807 GdkPixbuf *buf; | |
5808 | |
5809 GtkWidget *event; | |
5810 GtkWidget *frame; | |
5811 GdkPixbuf *scale; | |
9318 | 5812 int scale_width, scale_height; |
5813 | |
5814 GaimAccount *account; | |
5815 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5816 |
9324 | 5817 GaimBuddyIcon *icon; |
5818 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5819 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5820 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5821 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5822 |
5823 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5824 win = gtkconv->win; |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5825 if (conv != gtkconv->active_conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
5826 return; |
10175 | 5827 |
9687 | 5828 if (!gtkconv->u.im->show_icon) |
5829 return; | |
5830 | |
9318 | 5831 account = gaim_conversation_get_account(conv); |
5832 if(account && account->gc) | |
5833 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5834 |
9845 | 5835 /* Remove the current icon stuff */ |
9885 | 5836 if (gtkconv->u.im->icon_container != NULL) |
5837 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5838 gtkconv->u.im->icon_container = NULL; | |
9845 | 5839 |
5840 if (gtkconv->u.im->anim != NULL) | |
5841 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5842 | |
9887 | 5843 gtkconv->u.im->anim = NULL; |
5844 | |
9845 | 5845 if (gtkconv->u.im->icon_timer != 0) |
5846 g_source_remove(gtkconv->u.im->icon_timer); | |
5847 | |
5848 gtkconv->u.im->icon_timer = 0; | |
5849 | |
5850 if (gtkconv->u.im->iter != NULL) | |
5851 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5852 |
10116 | 5853 gtkconv->u.im->iter = NULL; |
5854 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5855 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5856 return; |
5857 | |
5858 if (gaim_conversation_get_gc(conv) == NULL) | |
5859 return; | |
5860 | |
9324 | 5861 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5862 | |
5863 if (icon == NULL) | |
5864 return; | |
5865 | |
5866 data = gaim_buddy_icon_get_data(icon, &len); | |
5867 | |
10381 | 5868 loader = gdk_pixbuf_loader_new(); |
5869 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
12601
e63fb8e9f4ac
[gaim-migrate @ 14935]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
5870 gdk_pixbuf_loader_close(loader, &err); |
10381 | 5871 anim = gdk_pixbuf_loader_get_animation(loader); |
5872 if (anim) | |
5873 g_object_ref(G_OBJECT(anim)); | |
5874 g_object_unref(loader); | |
5875 | |
5876 if (!anim) | |
9324 | 5877 return; |
10381 | 5878 gtkconv->u.im->anim = anim; |
9324 | 5879 |
4359 | 5880 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5881 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5882 "Buddy icon error: %s\n", err->message); |
4359 | 5883 g_error_free(err); |
5884 } | |
5885 | |
5886 if (!gtkconv->u.im->anim) | |
5887 return; | |
5888 | |
5889 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5890 gtkconv->u.im->iter = NULL; | |
5891 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5892 } else { | |
5893 gtkconv->u.im->iter = | |
8496 | 5894 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5895 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5896 if (gtkconv->u.im->animate) |
10810 | 5897 start_anim(NULL, gtkconv); |
4359 | 5898 } |
5899 | |
10483 | 5900 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5901 NULL, &scale_width, &scale_height); |
4359 | 5902 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5903 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5904 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5905 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5906 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5907 GDK_INTERP_BILINEAR); |
4359 | 5908 |
9885 | 5909 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5910 |
4359 | 5911 frame = gtk_frame_new(NULL); |
13690
6a86f4ec744e
[gaim-migrate @ 16093]
Richard Laager <rlaager@wiktel.com>
parents:
13663
diff
changeset
|
5912 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); |
9885 | 5913 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5914 FALSE, FALSE, 0); | |
8821 | 5915 |
4359 | 5916 event = gtk_event_box_new(); |
5917 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5918 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5919 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5920 gtk_widget_show(event); |
5921 | |
13690
6a86f4ec744e
[gaim-migrate @ 16093]
Richard Laager <rlaager@wiktel.com>
parents:
13663
diff
changeset
|
5922 gtkconv->u.im->icon = gtk_image_new_from_pixbuf(scale); |
9318 | 5923 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5924 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5925 gtk_widget_show(gtkconv->u.im->icon); | |
5926 | |
13690
6a86f4ec744e
[gaim-migrate @ 16093]
Richard Laager <rlaager@wiktel.com>
parents:
13663
diff
changeset
|
5927 g_object_unref(G_OBJECT(scale)); |
7143 | 5928 |
10356 | 5929 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5930 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5931 |
9885 | 5932 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5933 gtk_widget_show(frame); |
5934 | |
7143 | 5935 /* The buddy icon code needs badly to be fixed. */ |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5936 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
5937 { |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
5938 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); |
11581 | 5939 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
5940 } |
4359 | 5941 } |
5942 | |
5943 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5944 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5945 { |
11581 | 5946 GaimGtkWindow *win; |
4359 | 5947 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5948 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5949 return; |
5950 | |
11581 | 5951 win = GAIM_GTK_CONVERSATION(conv)->win; |
5952 | |
5953 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5954 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5955 } |
5956 | |
5957 int | |
11614 | 5958 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5959 { |
4359 | 5960 gint nb_x, nb_y, x_rel, y_rel; |
5961 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5962 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5963 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5964 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5965 gboolean horiz; |
4359 | 5966 |
11614 | 5967 if (to_right) |
5968 *to_right = FALSE; | |
5969 | |
11581 | 5970 notebook = GTK_NOTEBOOK(win->notebook); |
5971 | |
5972 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5973 x_rel = x - nb_x; |
5974 y_rel = y - nb_y; | |
5975 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5976 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5977 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5978 |
11780 | 5979 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5980 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5981 #else |
5982 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5983 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5984 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5985 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5986 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5987 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5988 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5989 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5990 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5991 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5992 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5993 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
|
5994 page_num = i; |
11614 | 5995 |
5996 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5997 *to_right = TRUE; | |
5998 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5999 break; |
4359 | 6000 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
6001 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
6002 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
6003 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
|
6004 page_num = i; |
11614 | 6005 |
6006 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
6007 *to_right = TRUE; | |
6008 | |
4359 | 6009 break; |
6010 } | |
6011 } | |
6012 } | |
6013 | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6014 if (page_num == -1) { |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6015 /* Add after the last tab */ |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6016 page_num = count - 1; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6017 } |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6018 |
4359 | 6019 return page_num; |
6020 } | |
6021 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6022 static void |
12816 | 6023 close_on_tabs_pref_cb(const char *name, GaimPrefType type, |
6024 gconstpointer value, gpointer data) | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6025 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6026 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6027 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6028 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6029 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6030 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6031 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6032 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6033 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6034 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6035 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6036 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6037 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6038 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6039 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6040 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6041 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6042 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6043 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6044 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6045 static void |
12816 | 6046 spellcheck_pref_cb(const char *name, GaimPrefType type, |
6047 gconstpointer value, gpointer data) | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6048 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6049 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6050 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6051 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6052 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6053 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6054 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6055 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
6056 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6057 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6058 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6059 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6060 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6061 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6062 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6063 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6064 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6065 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6066 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6067 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6068 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
6069 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6070 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6071 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6072 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6073 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6074 static void |
12816 | 6075 tab_side_pref_cb(const char *name, GaimPrefType type, |
6076 gconstpointer value, gpointer data) | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6077 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6078 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6079 GtkPositionType pos; |
11581 | 6080 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6081 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6082 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6083 |
11581 | 6084 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
6085 win = l->data; | |
6086 | |
11619 | 6087 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
|
6088 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6089 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6090 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6091 static void |
12188 | 6092 show_timestamps_pref_cb(const char *name, GaimPrefType type, |
12816 | 6093 gconstpointer value, gpointer data) |
12188 | 6094 { |
6095 GList *l; | |
6096 GaimConversation *conv; | |
6097 GaimGtkConversation *gtkconv; | |
6098 GaimGtkWindow *win; | |
6099 | |
6100 for (l = gaim_get_conversations(); l != NULL; l = l->next) | |
6101 { | |
6102 conv = (GaimConversation *)l->data; | |
6103 | |
6104 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
6105 continue; | |
6106 | |
6107 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6108 win = gtkconv->win; | |
6109 | |
6110 gtk_check_menu_item_set_active( | |
6111 GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
6112 (gboolean)GPOINTER_TO_INT(value)); | |
6113 | |
6114 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
6115 (gboolean)GPOINTER_TO_INT(value)); | |
6116 } | |
6117 } | |
6118 | |
6119 static void | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6120 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
12816 | 6121 gconstpointer value, gpointer data) |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6122 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6123 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6124 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6125 GaimGtkConversation *gtkconv; |
11581 | 6126 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6127 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6128 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6129 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6130 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6131 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6132 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6133 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6134 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6135 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 6136 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6137 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6138 gtk_check_menu_item_set_active( |
11581 | 6139 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
6140 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 6141 |
6142 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 6143 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6144 else |
8317 | 6145 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6146 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6147 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6148 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6149 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6150 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
12816 | 6151 gconstpointer value, gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6152 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6153 GList *l; |
8189 | 6154 GaimConversation *conv; |
6155 GaimGtkConversation *gtkconv; | |
11581 | 6156 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6157 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6158 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
|
6159 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6160 |
8189 | 6161 /* Set the "animate" flag for each icon based on the new preference */ |
6162 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
6163 conv = (GaimConversation *)l->data; | |
6164 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 6165 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6166 } |
8189 | 6167 |
6168 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 6169 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
6170 win = l->data; | |
6171 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 6172 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6173 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6174 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6175 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6176 static void |
12816 | 6177 show_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
6178 gconstpointer value, gpointer data) | |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6179 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6180 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6181 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6182 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6183 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6184 |
11338 | 6185 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 6186 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6187 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6188 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6189 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
6190 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6191 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
12816 | 6192 gconstpointer value, gpointer data) |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6193 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6194 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6195 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6196 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6197 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6198 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6199 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6200 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6201 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6202 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6203 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6204 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6205 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
|
6206 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6207 |
12310 | 6208 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
|
6209 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6210 |
13139
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6211 while ((l = hidden_convwin->gtkconvs) != NULL) |
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6212 { |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6213 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6214 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6215 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6216 |
13525 | 6217 while(l && !gaim_status_is_available( |
12310 | 6218 gaim_account_get_active_status( |
6219 gaim_conversation_get_account(conv)))) | |
13525 | 6220 l = l->next; |
6221 if (!l) | |
6222 break; | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6223 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6224 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6225 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6226 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6227 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6228 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6229 static void |
12816 | 6230 hide_new_pref_cb(const char *name, GaimPrefType type, |
6231 gconstpointer value, gpointer data) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6232 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6233 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6234 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6235 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6236 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6237 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6238 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6239 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6240 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6241 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
|
6242 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6243 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6244 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
|
6245 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6246 |
13139
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6247 while ((l = hidden_convwin->gtkconvs) != NULL) |
05ef36447131
[gaim-migrate @ 15501]
Richard Laager <rlaager@wiktel.com>
parents:
13138
diff
changeset
|
6248 { |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6249 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6250 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6251 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6252 |
12310 | 6253 if(when_away && !gaim_status_is_available( |
6254 gaim_account_get_active_status( | |
6255 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6256 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6257 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6258 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6259 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6260 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6261 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6262 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6263 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6264 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6265 conv_placement_pref_cb(const char *name, GaimPrefType type, |
12816 | 6266 gconstpointer value, gpointer data) |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6267 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6268 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6269 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6270 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6271 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6272 |
11581 | 6273 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6274 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6275 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6276 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6277 |
11581 | 6278 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6279 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6280 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6281 static GaimGtkConversation * |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6282 get_gtkconv_with_contact(GaimContact *contact) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6283 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6284 GaimBlistNode *node; |
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 node = ((GaimBlistNode*)contact)->child; |
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 for (; node; node = node->next) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6289 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6290 GaimBuddy *buddy = (GaimBuddy*)node; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6291 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6292 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
|
6293 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6294 return GAIM_GTK_CONVERSATION(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6295 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6296 return NULL; |
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 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6299 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6300 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6301 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6302 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6303 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6304 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6305 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6306 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6307 |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6308 /* 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
|
6309 * case of this account matching one of the other buddies in |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6310 * one of the contacts containing the buddy corresponding to |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6311 * a conversation. It's easier to just update them all. */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6312 /* if (gaim_conversation_get_account(conv) == account) */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6313 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON | |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6314 GAIM_GTKCONV_MENU | GAIM_GTKCONV_COLORIZE_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6315 } |
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 gboolean |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6319 update_buddy_status_timeout(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 /* To remove the signing-on/off door icon */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6322 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6323 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6324 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
|
6325 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6326 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); |
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 return FALSE; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6329 } |
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 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6332 update_buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *newstatus) |
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 GaimGtkConversation *gtkconv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6335 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6336 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6337 gtkconv = get_gtkconv_with_contact(gaim_buddy_get_contact(buddy)); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6338 if (gtkconv) |
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 conv = gtkconv->active_conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6341 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
|
6342 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
|
6343 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_MENU); |
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 /* 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
|
6347 g_timeout_add(11000, (GSourceFunc)update_buddy_status_timeout, buddy); |
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 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6350 static void |
14138 | 6351 update_buddy_privacy_changed(GaimBuddy *buddy) |
6352 { | |
6353 GaimGtkConversation *gtkconv; | |
6354 GaimConversation *conv; | |
6355 | |
6356 gtkconv = get_gtkconv_with_contact(gaim_buddy_get_contact(buddy)); | |
6357 if (gtkconv) | |
6358 { | |
6359 conv = gtkconv->active_conv; | |
6360 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); | |
6361 } | |
6362 } | |
6363 | |
6364 static void | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6365 update_buddy_idle_changed(GaimBuddy *buddy, gboolean old, gboolean newidle) |
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 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6368 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6369 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
|
6370 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6371 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6372 } |
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 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6375 update_buddy_icon(GaimBuddy *buddy) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6376 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6377 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6378 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6379 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
|
6380 if (conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6381 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_BUDDY_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6382 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6383 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6384 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6385 update_buddy_sign(GaimBuddy *buddy, const char *which) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6386 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6387 GaimPresence *presence; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6388 GaimStatus *on, *off; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6389 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6390 presence = gaim_buddy_get_presence(buddy); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6391 if (!presence) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6392 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6393 off = gaim_presence_get_status(presence, "offline"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6394 on = gaim_presence_get_status(presence, "available"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6395 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6396 if (*(which+1) == 'f') |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6397 update_buddy_status_changed(buddy, on, off); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6398 else |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6399 update_buddy_status_changed(buddy, off, on); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6400 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6401 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6402 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6403 update_conversation_switched(GaimConversation *conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6404 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6405 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
|
6406 GAIM_GTKCONV_MENU | GAIM_GTKCONV_BUDDY_ICON); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6407 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6408 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6409 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6410 update_buddy_typing(GaimAccount *account, const char *who) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6411 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6412 GaimConversation *conv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6413 GaimGtkConversation *gtkconv; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6414 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6415 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
|
6416 if (!conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6417 return; |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6418 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6419 gtkconv = GAIM_GTK_CONVERSATION(conv); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6420 if (gtkconv && gtkconv->active_conv == conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6421 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_COLORIZE_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6422 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6423 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6424 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6425 update_chat(GaimConversation *conv) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6426 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6427 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TOPIC | |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6428 GAIM_GTKCONV_MENU | GAIM_GTKCONV_SET_TITLE); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6429 } |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6430 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6431 static void |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6432 update_chat_topic(GaimConversation *conv, const char *old, const char *new) |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6433 { |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6434 gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TOPIC); |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6435 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6436 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6437 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6438 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6439 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6440 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6441 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6442 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6443 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6444 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6445 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
6446 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6447 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6448 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6449 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6450 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6451 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6452 gaim_prefs_add_none("/gaim/gtk/conversations"); |
12553 | 6453 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
|
6454 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6455 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6456 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6457 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6458 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
6459 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
6460 |
12264 | 6461 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6462 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 6463 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 6464 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6465 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 6466 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 6467 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
6468 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6469 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6470 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6471 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6472 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
|
6473 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6474 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6475 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6476 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6477 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6478 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6479 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6480 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6481 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6482 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 6483 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6484 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 6485 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6486 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6487 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6488 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 6489 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
|
6490 |
12616
eee2042ad4f4
[gaim-migrate @ 14952]
Richard Laager <rlaager@wiktel.com>
parents:
12604
diff
changeset
|
6491 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
|
6492 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6493 /* Connect callbacks. */ |
10087 | 6494 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
|
6495 close_on_tabs_pref_cb, NULL); |
12188 | 6496 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
6497 show_timestamps_pref_cb, NULL); | |
10087 | 6498 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
|
6499 show_formatting_toolbar_pref_cb, NULL); |
10087 | 6500 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6501 spellcheck_pref_cb, NULL); |
10087 | 6502 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6503 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6504 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6505 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6506 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6507 |
10087 | 6508 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6509 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6510 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6511 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6512 /* IM callbacks */ |
10087 | 6513 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
|
6514 animate_buddy_icons_pref_cb, NULL); |
10087 | 6515 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
|
6516 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6517 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6518 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6519 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6520 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6521 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6522 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6523 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6524 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
6525 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6526 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
12837
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6527 gaim_value_new(GAIM_TYPE_BOXED, |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6528 "GaimGtkWindow *"), |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6529 gaim_value_new(GAIM_TYPE_BOXED, |
1096bdfef887
[gaim-migrate @ 15185]
Richard Laager <rlaager@wiktel.com>
parents:
12831
diff
changeset
|
6530 "GaimGtkWindow *")); |
9167 | 6531 |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6532 gaim_signal_register(handle, "conversation-timestamp", |
13995 | 6533 #if SIZEOF_TIME_T == 4 |
13987
f94309c7c480
[gaim-migrate @ 16559]
Richard Laager <rlaager@wiktel.com>
parents:
13972
diff
changeset
|
6534 gaim_marshal_POINTER__POINTER_INT, |
13995 | 6535 #elif SIZEOF_TIME_T == 8 |
6536 gaim_marshal_POINTER__POINTER_INT64, | |
6537 #else | |
6538 #error Unkown size of time_t | |
6539 #endif | |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6540 gaim_value_new(GAIM_TYPE_POINTER), 2, |
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6541 gaim_value_new(GAIM_TYPE_SUBTYPE, |
13987
f94309c7c480
[gaim-migrate @ 16559]
Richard Laager <rlaager@wiktel.com>
parents:
13972
diff
changeset
|
6542 GAIM_SUBTYPE_LOG), |
13992
0567de116699
[gaim-migrate @ 16566]
Richard Laager <rlaager@wiktel.com>
parents:
13987
diff
changeset
|
6543 #if SIZEOF_TIME_T == 4 |
0567de116699
[gaim-migrate @ 16566]
Richard Laager <rlaager@wiktel.com>
parents:
13987
diff
changeset
|
6544 gaim_value_new(GAIM_TYPE_INT)); |
14005
d856c2ec93ca
[gaim-migrate @ 16590]
Richard Laager <rlaager@wiktel.com>
parents:
13995
diff
changeset
|
6545 #elif SIZEOF_TIME_T == 8 |
13992
0567de116699
[gaim-migrate @ 16566]
Richard Laager <rlaager@wiktel.com>
parents:
13987
diff
changeset
|
6546 gaim_value_new(GAIM_TYPE_INT64)); |
0567de116699
[gaim-migrate @ 16566]
Richard Laager <rlaager@wiktel.com>
parents:
13987
diff
changeset
|
6547 #else |
0567de116699
[gaim-migrate @ 16566]
Richard Laager <rlaager@wiktel.com>
parents:
13987
diff
changeset
|
6548 # error Unknown size of time_t |
0567de116699
[gaim-migrate @ 16566]
Richard Laager <rlaager@wiktel.com>
parents:
13987
diff
changeset
|
6549 #endif |
12737
a1e241dd50b6
[gaim-migrate @ 15082]
Richard Laager <rlaager@wiktel.com>
parents:
12722
diff
changeset
|
6550 |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6551 gaim_signal_register(handle, "displaying-im-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6552 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6553 gaim_value_new(GAIM_TYPE_BOOLEAN), 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6554 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6555 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6556 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6557 gaim_value_new_outgoing(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6558 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6559 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6560 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6561 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6562 gaim_signal_register(handle, "displayed-im-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6563 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6564 NULL, 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6565 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6566 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6567 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6568 gaim_value_new(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6569 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6570 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6571 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6572 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6573 gaim_signal_register(handle, "displaying-chat-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6574 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6575 gaim_value_new(GAIM_TYPE_BOOLEAN), 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6576 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6577 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6578 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6579 gaim_value_new_outgoing(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6580 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6581 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6582 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6583 |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6584 gaim_signal_register(handle, "displayed-chat-msg", |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6585 gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT, |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6586 NULL, 5, |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6587 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6588 GAIM_SUBTYPE_ACCOUNT), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6589 gaim_value_new(GAIM_TYPE_STRING), |
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6590 gaim_value_new(GAIM_TYPE_STRING), |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6591 gaim_value_new(GAIM_TYPE_SUBTYPE, |
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6592 GAIM_SUBTYPE_CONVERSATION), |
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
13147
diff
changeset
|
6593 gaim_value_new(GAIM_TYPE_INT)); |
12604
71299d63801d
[gaim-migrate @ 14939]
Richard Laager <rlaager@wiktel.com>
parents:
12601
diff
changeset
|
6594 |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6595 gaim_signal_register(handle, "conversation-switched", |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6596 gaim_marshal_VOID__POINTER_POINTER, NULL, 1, |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6597 gaim_value_new(GAIM_TYPE_SUBTYPE, |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6598 GAIM_SUBTYPE_CONVERSATION)); |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
6599 |
9167 | 6600 /********************************************************************** |
6601 * Register commands | |
6602 **********************************************************************/ | |
9829 | 6603 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
6604 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
6605 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 6606 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
6607 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6608 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 6609 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
6610 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6611 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
|
6612 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6613 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6614 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 6615 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 6616 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
6617 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 6618 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6619 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6620 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6621 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6622 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6623 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6624 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6625 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6626 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6627 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6628 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6629 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6630 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6631 handle, G_CALLBACK(received_im_msg_cb), NULL); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6632 |
11581 | 6633 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6634 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6635 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6636 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6637 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6638 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6639 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6640 |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6641 /* Callbacks to update a conversation */ |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6642 gaim_signal_connect(blist_handle, "buddy-added", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6643 G_CALLBACK(buddy_update_cb), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6644 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6645 G_CALLBACK(buddy_update_cb), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6646 gaim_signal_connect(blist_handle, "buddy-signed-on", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6647 handle, GAIM_CALLBACK(update_buddy_sign), "on"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6648 gaim_signal_connect(blist_handle, "buddy-signed-off", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6649 handle, GAIM_CALLBACK(update_buddy_sign), "off"); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6650 gaim_signal_connect(blist_handle, "buddy-status-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6651 handle, GAIM_CALLBACK(update_buddy_status_changed), NULL); |
14138 | 6652 gaim_signal_connect(blist_handle, "buddy-privacy-changed", |
6653 handle, GAIM_CALLBACK(update_buddy_privacy_changed), NULL); | |
12797
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6654 gaim_signal_connect(blist_handle, "buddy-idle-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6655 handle, GAIM_CALLBACK(update_buddy_idle_changed), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6656 gaim_signal_connect(blist_handle, "buddy-icon-changed", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6657 handle, GAIM_CALLBACK(update_buddy_icon), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6658 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6659 handle, GAIM_CALLBACK(update_buddy_typing), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6660 gaim_signal_connect(gaim_conversations_get_handle(), "buddy-typing-stopped", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6661 handle, GAIM_CALLBACK(update_buddy_typing), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6662 gaim_signal_connect(gaim_gtk_conversations_get_handle(), "conversation-switched", |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6663 handle, GAIM_CALLBACK(update_conversation_switched), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6664 gaim_signal_connect(gaim_conversations_get_handle(), "chat-left", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6665 GAIM_CALLBACK(update_chat), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6666 gaim_signal_connect(gaim_conversations_get_handle(), "chat-joined", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6667 GAIM_CALLBACK(update_chat), NULL); |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6668 gaim_signal_connect(gaim_conversations_get_handle(), "chat-topic-changed", handle, |
eda1572c788b
[gaim-migrate @ 15144]
Richard Laager <rlaager@wiktel.com>
parents:
12795
diff
changeset
|
6669 GAIM_CALLBACK(update_chat_topic), NULL); |
12806
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6670 gaim_signal_connect_priority(gaim_conversations_get_handle(), "conversation-updated", handle, |
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6671 GAIM_CALLBACK(gaim_gtkconv_updated), NULL, |
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6672 GAIM_SIGNAL_PRIORITY_LOWEST); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6673 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6674 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6675 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6676 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6677 { |
10443 | 6678 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 6679 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6680 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6681 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6682 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6683 } |
11581 | 6684 |
6685 | |
6686 | |
6687 | |
6688 | |
6689 | |
6690 | |
6691 | |
6692 | |
6693 | |
6694 | |
6695 | |
6696 | |
6697 | |
6698 | |
6699 | |
6700 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
6701 * and touch each others' private members all day long */ | |
6702 | |
6703 /** | |
6704 * @file gtkconvwin.c GTK+ Conversation Window API | |
6705 * @ingroup gtkui | |
6706 * | |
6707 * gaim | |
6708 * | |
6709 * Gaim is the legal property of its developers, whose names are too numerous | |
6710 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6711 * source distribution. | |
6712 * | |
6713 * This program is free software; you can redistribute it and/or modify | |
6714 * it under the terms of the GNU General Public License as published by | |
6715 * the Free Software Foundation; either version 2 of the License, or | |
6716 * (at your option) any later version. | |
6717 * | |
6718 * This program is distributed in the hope that it will be useful, | |
6719 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
6720 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
6721 * GNU General Public License for more details. | |
6722 * | |
6723 * You should have received a copy of the GNU General Public License | |
6724 * along with this program; if not, write to the Free Software | |
6725 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
6726 * | |
6727 */ | |
6728 #include "internal.h" | |
6729 #include "gtkgaim.h" | |
6730 | |
6731 | |
6732 #include <gdk/gdkkeysyms.h> | |
6733 | |
6734 #include "account.h" | |
6735 #include "cmds.h" | |
6736 #include "debug.h" | |
6737 #include "imgstore.h" | |
6738 #include "log.h" | |
6739 #include "notify.h" | |
6740 #include "prpl.h" | |
6741 #include "request.h" | |
6742 #include "util.h" | |
6743 | |
6744 #include "gtkdnd-hints.h" | |
6745 #include "gtkblist.h" | |
6746 #include "gtkconv.h" | |
6747 #include "gtkdialogs.h" | |
6748 #include "gtkmenutray.h" | |
6749 #include "gtkpounce.h" | |
6750 #include "gtkprefs.h" | |
6751 #include "gtkprivacy.h" | |
6752 #include "gtkutils.h" | |
6753 #include "gtkstock.h" | |
6754 #include "gtkimhtml.h" | |
6755 #include "gtkimhtmltoolbar.h" | |
6756 | |
6757 static void | |
6758 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
6759 { | |
6760 gtk_widget_destroy(warn_close_dialog); | |
6761 warn_close_dialog = NULL; | |
6762 | |
6763 if (resp == GTK_RESPONSE_OK) | |
6764 gaim_gtk_conv_window_destroy(win); | |
6765 } | |
6766 | |
6767 static void | |
6768 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
6769 { | |
6770 GtkWidget *label; | |
6771 GtkWidget *vbox, *hbox; | |
6772 GtkWidget *img; | |
6773 | |
6774 g_return_if_fail(warn_close_dialog == NULL); | |
6775 | |
6776 | |
6777 warn_close_dialog = gtk_dialog_new_with_buttons( | |
12660 | 6778 _("Confirm close"), |
6779 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
6780 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
6781 GAIM_STOCK_CLOSE_TABS, GTK_RESPONSE_OK, NULL); | |
11581 | 6782 |
6783 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
6784 GTK_RESPONSE_OK); | |
6785 | |
6786 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
6787 6); | |
6788 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
6789 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
6790 FALSE); | |
6791 | |
6792 /* Setup the outside spacing. */ | |
6793 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
6794 | |
6795 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
6796 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
6797 | |
6798 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
6799 GTK_ICON_SIZE_DIALOG); | |
6800 /* Setup the inner hbox and put the dialog's icon in it. */ | |
6801 hbox = gtk_hbox_new(FALSE, 12); | |
6802 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
6803 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
6804 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
6805 | |
6806 /* Setup the right vbox. */ | |
6807 vbox = gtk_vbox_new(FALSE, 12); | |
6808 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
6809 | |
6810 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
6811 gtk_widget_set_size_request(label, 350, -1); | |
6812 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
6813 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
6814 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
6815 | |
6816 /* Connect the signals. */ | |
6817 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
6818 G_CALLBACK(do_close), gtkwin); | |
6819 | |
6820 } | |
6821 | |
6822 /************************************************************************** | |
6823 * Callbacks | |
6824 **************************************************************************/ | |
6825 | |
6826 static gboolean | |
6827 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
6828 { | |
6829 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6830 GList *l; |
11581 | 6831 |
6832 /* If there are unread messages then show a warning dialog */ | |
6833 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
6834 l != NULL; l = l->next) | |
6835 { | |
6836 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6837 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
|
6838 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6839 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6840 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6841 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6842 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6843 return TRUE; |
11581 | 6844 } |
6845 } | |
6846 | |
6847 gaim_gtk_conv_window_destroy(win); | |
6848 | |
6849 return TRUE; | |
6850 } | |
6851 | |
11604 | 6852 static void |
6853 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
6854 { | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6855 if (state == GAIM_UNSEEN_NONE) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6856 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6857 gtkconv->unseen_count = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6858 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6859 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6860 else |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6861 { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6862 if (state >= GAIM_UNSEEN_TEXT) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6863 gtkconv->unseen_count++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6864 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6865 if (state > gtkconv->unseen_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6866 gtkconv->unseen_state = state; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6867 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6868 |
12806
ebef62bc831a
[gaim-migrate @ 15153]
Richard Laager <rlaager@wiktel.com>
parents:
12801
diff
changeset
|
6869 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
|
6870 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6871 |
11581 | 6872 /* |
6873 * When a conversation window is focused, we know the user | |
6874 * has looked at it so we know there are no longer unseen | |
6875 * messages. | |
6876 */ | |
6877 static gint | |
6878 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6879 { | |
6880 GaimGtkWindow *win = d; | |
11604 | 6881 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6882 | |
6883 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6884 |
6885 return FALSE; | |
6886 } | |
6887 | |
11851 | 6888 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6889 /* Courtesy of Galeon! */ |
6890 static void | |
6891 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6892 { | |
6893 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6894 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6895 } | |
11851 | 6896 #endif |
11581 | 6897 |
6898 static void | |
6899 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6900 { | |
6901 static GdkCursor *cursor = NULL; | |
6902 | |
6903 gtkwin->in_drag = TRUE; | |
6904 | |
6905 if (gtkwin->drag_leave_signal) { | |
6906 g_signal_handler_disconnect(G_OBJECT(widget), | |
6907 gtkwin->drag_leave_signal); | |
6908 gtkwin->drag_leave_signal = 0; | |
6909 } | |
6910 | |
6911 if (cursor == NULL) | |
6912 cursor = gdk_cursor_new(GDK_FLEUR); | |
6913 | |
6914 /* Grab the pointer */ | |
6915 gtk_grab_add(gtkwin->notebook); | |
6916 #ifndef _WIN32 | |
6917 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6918 always be true after a button press. */ | |
6919 if (!gdk_pointer_is_grabbed()) | |
6920 #endif | |
6921 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6922 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6923 NULL, cursor, GDK_CURRENT_TIME); | |
6924 } | |
6925 | |
6926 static gboolean | |
6927 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6928 { | |
6929 | |
6930 /* | |
6931 * Make sure the user moved the mouse far enough for the | |
6932 * drag to be initiated. | |
6933 */ | |
6934 if (win->in_predrag) { | |
6935 if (e->x_root < win->drag_min_x || | |
6936 e->x_root >= win->drag_max_x || | |
6937 e->y_root < win->drag_min_y || | |
6938 e->y_root >= win->drag_max_y) { | |
6939 | |
6940 win->in_predrag = FALSE; | |
6941 notebook_init_grab(win, widget); | |
6942 } | |
6943 } | |
6944 else { /* Otherwise, draw the arrows. */ | |
6945 GaimGtkWindow *dest_win; | |
6946 GtkNotebook *dest_notebook; | |
6947 GtkWidget *tab; | |
6948 gint nb_x, nb_y, page_num; | |
6949 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6950 gboolean horiz_tabs = FALSE; | |
11614 | 6951 GaimGtkConversation *gtkconv; |
6952 gboolean to_right = FALSE; | |
11581 | 6953 |
6954 /* Get the window that the cursor is over. */ | |
6955 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6956 | |
6957 if (dest_win == NULL) { | |
6958 dnd_hints_hide_all(); | |
6959 | |
6960 return TRUE; | |
6961 } | |
6962 | |
6963 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6964 | |
6965 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6966 | |
6967 arrow1_x = arrow2_x = nb_x; | |
6968 arrow1_y = arrow2_y = nb_y; | |
6969 | |
6970 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6971 e->x_root, e->y_root, &to_right); |
6972 to_right = to_right && (win != dest_win); | |
11581 | 6973 |
6974 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6975 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6976 | |
6977 horiz_tabs = TRUE; | |
6978 } | |
6979 | |
11614 | 6980 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6981 tab = gtkconv->tabby; | |
11581 | 6982 |
6983 if (horiz_tabs) { | |
6984 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6985 | |
11614 | 6986 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6987 arrow1_x += tab->allocation.width; |
6988 arrow2_x += tab->allocation.width; | |
6989 } | |
6990 | |
6991 arrow1_y = nb_y + tab->allocation.y; | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6992 arrow2_y = nb_y + tab->allocation.y + tab->allocation.height; |
11581 | 6993 } else { |
6994 arrow1_x = nb_x + tab->allocation.x; | |
12795
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6995 arrow2_x = nb_x + tab->allocation.x + tab->allocation.width; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6996 arrow1_y = arrow2_y = nb_y + tab->allocation.y; |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6997 |
ca1144227826
[gaim-migrate @ 15142]
Richard Laager <rlaager@wiktel.com>
parents:
12737
diff
changeset
|
6998 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6999 arrow1_y += tab->allocation.height; |
7000 arrow2_y += tab->allocation.height; | |
7001 } | |
7002 } | |
7003 | |
7004 if (horiz_tabs) { | |
7005 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
7006 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
7007 } else { | |
7008 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
7009 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
7010 } | |
7011 } | |
7012 | |
7013 return TRUE; | |
7014 } | |
7015 | |
7016 static gboolean | |
7017 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
7018 { | |
7019 if (win->in_drag) | |
7020 return FALSE; | |
7021 | |
7022 if (e->x_root < win->drag_min_x || | |
7023 e->x_root >= win->drag_max_x || | |
7024 e->y_root < win->drag_min_y || | |
7025 e->y_root >= win->drag_max_y) { | |
7026 | |
7027 win->in_predrag = FALSE; | |
7028 notebook_init_grab(win, widget); | |
7029 } | |
7030 | |
7031 return TRUE; | |
7032 } | |
7033 | |
7034 /* | |
7035 * THANK YOU GALEON! | |
7036 */ | |
7037 static gboolean | |
7038 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
7039 { | |
7040 gint nb_x, nb_y, x_rel, y_rel; | |
7041 int tab_clicked; | |
7042 GtkWidget *page; | |
7043 GtkWidget *tab; | |
7044 | |
7045 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
7046 return FALSE; | |
7047 | |
7048 | |
7049 if (win->in_drag) { | |
7050 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
7051 "Already in the middle of a window drag at tab_press_cb\n"); | |
7052 return TRUE; | |
7053 } | |
7054 | |
7055 /* | |
7056 * Make sure a tab was actually clicked. The arrow buttons | |
7057 * mess things up. | |
7058 */ | |
11614 | 7059 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 7060 |
7061 if (tab_clicked == -1) | |
7062 return FALSE; | |
7063 | |
7064 /* | |
7065 * Get the relative position of the press event, with regards to | |
7066 * the position of the notebook. | |
7067 */ | |
7068 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
7069 | |
7070 x_rel = e->x_root - nb_x; | |
7071 y_rel = e->y_root - nb_y; | |
7072 | |
7073 /* Reset the min/max x/y */ | |
7074 win->drag_min_x = 0; | |
7075 win->drag_min_y = 0; | |
7076 win->drag_max_x = 0; | |
7077 win->drag_max_y = 0; | |
7078 | |
7079 /* Find out which tab was dragged. */ | |
7080 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
7081 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
7082 | |
7083 win->drag_min_x = tab->allocation.x + nb_x; | |
7084 win->drag_min_y = tab->allocation.y + nb_y; | |
7085 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
7086 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
7087 | |
7088 /* Make sure the click occurred in the tab. */ | |
7089 if (e->x_root < win->drag_min_x || | |
7090 e->x_root >= win->drag_max_x || | |
7091 e->y_root < win->drag_min_y || | |
7092 e->y_root >= win->drag_max_y) { | |
7093 | |
7094 return FALSE; | |
7095 } | |
7096 | |
7097 win->in_predrag = TRUE; | |
7098 win->drag_tab = tab_clicked; | |
7099 | |
7100 /* Connect the new motion signals. */ | |
7101 win->drag_motion_signal = | |
7102 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
7103 G_CALLBACK(notebook_motion_cb), win); | |
7104 | |
7105 win->drag_leave_signal = | |
7106 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
7107 G_CALLBACK(notebook_leave_cb), win); | |
7108 | |
7109 return FALSE; | |
7110 } | |
7111 | |
7112 static gboolean | |
7113 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
7114 { | |
7115 GaimGtkWindow *dest_win; | |
7116 GaimConversation *conv; | |
7117 GaimGtkConversation *gtkconv; | |
7118 gint dest_page_num = 0; | |
7119 gboolean new_window = FALSE; | |
11614 | 7120 gboolean to_right = FALSE; |
11581 | 7121 |
7122 /* | |
7123 * Don't check to make sure that the event's window matches the | |
7124 * widget's, because we may be getting an event passed on from the | |
7125 * close button. | |
7126 */ | |
7127 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
7128 return FALSE; | |
7129 | |
7130 if (gdk_pointer_is_grabbed()) { | |
7131 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
7132 gtk_grab_remove(widget); | |
7133 } | |
7134 | |
7135 if (!win->in_predrag && !win->in_drag) | |
7136 return FALSE; | |
7137 | |
7138 /* Disconnect the motion signal. */ | |
7139 if (win->drag_motion_signal) { | |
7140 g_signal_handler_disconnect(G_OBJECT(widget), | |
7141 win->drag_motion_signal); | |
7142 | |
7143 win->drag_motion_signal = 0; | |
7144 } | |
7145 | |
7146 /* | |
7147 * If we're in a pre-drag, we'll also need to disconnect the leave | |
7148 * signal. | |
7149 */ | |
7150 if (win->in_predrag) { | |
7151 win->in_predrag = FALSE; | |
7152 | |
7153 if (win->drag_leave_signal) { | |
7154 g_signal_handler_disconnect(G_OBJECT(widget), | |
7155 win->drag_leave_signal); | |
7156 | |
7157 win->drag_leave_signal = 0; | |
7158 } | |
7159 } | |
7160 | |
7161 /* If we're not in drag... */ | |
7162 /* We're perfectly normal people! */ | |
7163 if (!win->in_drag) | |
7164 return FALSE; | |
7165 | |
7166 win->in_drag = FALSE; | |
7167 | |
7168 dnd_hints_hide_all(); | |
7169 | |
7170 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
7171 | |
7172 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
7173 | |
7174 if (dest_win == NULL) { | |
7175 /* If the current window doesn't have any other conversations, | |
7176 * there isn't much point transferring the conv to a new window. */ | |
7177 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
7178 /* Make a new window to stick this to. */ | |
7179 dest_win = gaim_gtk_conv_window_new(); | |
7180 new_window = TRUE; | |
7181 } | |
7182 } | |
7183 | |
7184 if (dest_win == NULL) | |
7185 return FALSE; | |
7186 | |
7187 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
7188 "conversation-dragging", win, dest_win); | |
7189 | |
7190 /* Get the destination page number. */ | |
7191 if (!new_window) | |
7192 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 7193 e->x_root, e->y_root, &to_right); |
11581 | 7194 |
7195 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7196 | |
7197 if (win == dest_win) { | |
7198 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
7199 } else { | |
7200 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
7201 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 7202 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 7203 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
7204 if (new_window) { | |
7205 gint win_width, win_height; | |
7206 | |
7207 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
7208 &win_width, &win_height); | |
7209 | |
7210 gtk_window_move(GTK_WINDOW(dest_win->window), | |
7211 e->x_root - (win_width / 2), | |
7212 e->y_root - (win_height / 2)); | |
7213 | |
7214 gaim_gtk_conv_window_show(dest_win); | |
7215 } | |
7216 } | |
7217 | |
7218 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
7219 | |
7220 return TRUE; | |
7221 } | |
7222 | |
7223 | |
7224 static void | |
7225 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
7226 gpointer user_data) | |
7227 { | |
7228 GaimGtkWindow *win; | |
7229 GaimConversation *conv; | |
7230 GaimGtkConversation *gtkconv; | |
7231 | |
7232 win = user_data; | |
7233 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
7234 | |
7235 g_return_if_fail(conv != NULL); | |
7236 | |
7237 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
7238 return; | |
7239 | |
7240 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7241 | |
7242 stop_anim(NULL, gtkconv); | |
7243 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7244 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7245 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7246 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7247 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7248 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7249 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7250 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7251 detach_tab_cb(GtkWidget *w, GObject *menu) |
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 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7254 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7255 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7256 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7257 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7258 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7259 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7260 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7261 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7262 /* 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
|
7263 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7264 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7265 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7266 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7267 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7268 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7269 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7270 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7271 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7272 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7273 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7274 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7275 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7276 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7277 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7278 GaimGtkWindow *win; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7279 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7280 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7281 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7282 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7283 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7284 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7285 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7286 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7287 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7288 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7289 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7290 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7291 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7292 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7293 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7294 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7295 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7296 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7297 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7298 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7299 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7300 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7301 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7302 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7303 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7304 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7305 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7306 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7307 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7308 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7309 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7310 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7311 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7312 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7313 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7314 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7315 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7316 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7317 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7318 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
7319 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
|
7320 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7321 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7322 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7323 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7324 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7325 } |
12188 | 7326 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7327 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7328 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7329 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7330 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7331 |
13326 | 7332 item = gtk_menu_item_new_with_label(_("Close other tabs")); |
12824
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7333 gtk_widget_show(item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7334 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7335 g_signal_connect(G_OBJECT(item), "activate", |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7336 G_CALLBACK(close_others_cb), menu); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7337 |
13326 | 7338 item = gtk_menu_item_new_with_label(_("Close all tabs")); |
12824
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7339 gtk_widget_show(item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7340 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7341 g_signal_connect(G_OBJECT(item), "activate", |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7342 G_CALLBACK(close_window), win); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7343 |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7344 gaim_separator(menu); |
7b8e885c1be3
[gaim-migrate @ 15172]
Richard Laager <rlaager@wiktel.com>
parents:
12816
diff
changeset
|
7345 |
13326 | 7346 item = gtk_menu_item_new_with_label(_("Detach this tab")); |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7347 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7348 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7349 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7350 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7351 |
13326 | 7352 item = gtk_menu_item_new_with_label(_("Close this tab")); |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7353 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7354 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7355 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7356 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7357 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7358 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7359 } |
11581 | 7360 |
7361 static void | |
7362 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
7363 gpointer user_data) | |
7364 { | |
7365 GaimGtkWindow *win; | |
7366 GaimConversation *conv; | |
7367 GaimGtkConversation *gtkconv; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7368 const char *sound_method; |
11581 | 7369 |
7370 win = user_data; | |
7371 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
7372 conv = gtkconv->active_conv; | |
7373 | |
7374 g_return_if_fail(conv != NULL); | |
7375 | |
7376 /* | |
7377 * Only set "unseen" to "none" if the window has focus | |
7378 */ | |
7379 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 7380 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 7381 |
7382 /* Update the menubar */ | |
7383 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
7384 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
|
7385 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
7386 |
11594 | 7387 generate_send_to_items(win); |
7388 | |
11604 | 7389 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 7390 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7391 sound_method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7392 if (strcmp(sound_method, "none") != 0) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7393 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
|
7394 gtkconv->make_sound); |
11581 | 7395 |
7396 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
7397 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
7398 | |
7399 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
12188 | 7400 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
11581 | 7401 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7402 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM && |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7403 gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7404 { |
11581 | 7405 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
7406 gtkconv->u.im->show_icon); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7407 } |
11604 | 7408 |
11581 | 7409 /* |
7410 * We pause icons when they are not visible. If this icon should | |
7411 * be animated then start it back up again. | |
7412 */ | |
7413 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
7414 (gtkconv->u.im->animate)) | |
7415 start_anim(NULL, gtkconv); | |
12639
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
7416 |
366326fa9cb4
[gaim-migrate @ 14975]
Richard Laager <rlaager@wiktel.com>
parents:
12638
diff
changeset
|
7417 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-switched", conv); |
11581 | 7418 } |
7419 | |
7420 /************************************************************************** | |
7421 * GTK+ window ops | |
7422 **************************************************************************/ | |
7423 | |
7424 GList * | |
7425 gaim_gtk_conv_windows_get_list() | |
7426 { | |
7427 return window_list; | |
7428 } | |
7429 | |
7430 GaimGtkWindow * | |
7431 gaim_gtk_conv_window_new() | |
7432 { | |
7433 GaimGtkWindow *win; | |
7434 GtkPositionType pos; | |
7435 GtkWidget *testidea; | |
7436 GtkWidget *menubar; | |
7437 | |
7438 win = g_malloc0(sizeof(GaimGtkWindow)); | |
7439 | |
7440 window_list = g_list_append(window_list, win); | |
7441 | |
7442 /* Create the window. */ | |
7443 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
7444 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
7445 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
7446 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
7447 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
7448 | |
7449 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
7450 G_CALLBACK(close_win_cb), win); | |
7451 | |
7452 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
7453 G_CALLBACK(focus_win_cb), win); | |
7454 | |
7455 /* Create the notebook. */ | |
7456 win->notebook = gtk_notebook_new(); | |
7457 | |
7458 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
7459 | |
7460 #if 0 | |
7461 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
7462 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
7463 #endif | |
7464 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
7465 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
7466 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
7467 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
7468 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
7469 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7470 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7471 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
7472 |
11581 | 7473 gtk_widget_show(win->notebook); |
7474 | |
7475 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
7476 G_CALLBACK(before_switch_conv_cb), win); | |
7477 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
7478 G_CALLBACK(switch_conv_cb), win); | |
7479 | |
7480 /* Setup the tab drag and drop signals. */ | |
7481 gtk_widget_add_events(win->notebook, | |
7482 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
7483 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
7484 G_CALLBACK(notebook_press_cb), win); | |
7485 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
7486 G_CALLBACK(notebook_release_cb), win); | |
7487 | |
7488 testidea = gtk_vbox_new(FALSE, 0); | |
7489 | |
7490 /* Setup the menubar. */ | |
7491 menubar = setup_menubar(win); | |
7492 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
7493 | |
7494 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
7495 | |
7496 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
7497 | |
7498 gtk_widget_show(testidea); | |
7499 | |
7500 return win; | |
7501 } | |
7502 | |
7503 void | |
7504 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
7505 { | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
7506 gaim_prefs_disconnect_by_handle(win); |
11581 | 7507 window_list = g_list_remove(window_list, win); |
7508 | |
11611 | 7509 if (win->gtkconvs) { |
7510 while (win->gtkconvs) { | |
7511 GList *nextgtk = win->gtkconvs->next; | |
7512 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
7513 GList *nextcore = gtkconv->convs->next; | |
7514 GaimConversation *conv = gtkconv->convs->data; | |
7515 gaim_conversation_destroy(conv); | |
7516 if (!nextgtk && !nextcore) | |
7517 /* we'll end up invoking ourselves when we destroy our last child */ | |
7518 /* so don't destroy ourselves right now */ | |
7519 return; | |
7520 } | |
7521 return; | |
7522 } | |
11581 | 7523 gtk_widget_destroy(win->window); |
7524 | |
7525 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
7526 | |
13147
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
7527 gaim_notify_close_with_handle(win); |
21ee457d479c
[gaim-migrate @ 15510]
Richard Laager <rlaager@wiktel.com>
parents:
13139
diff
changeset
|
7528 |
11581 | 7529 g_free(win); |
7530 } | |
7531 | |
7532 void | |
7533 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
7534 { | |
7535 gtk_widget_show(win->window); | |
7536 } | |
7537 | |
7538 void | |
7539 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
7540 { | |
7541 gtk_widget_hide(win->window); | |
7542 } | |
7543 | |
7544 void | |
7545 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
7546 { | |
13750 | 7547 gdk_window_raise(GDK_WINDOW(win->window->window)); |
11581 | 7548 } |
7549 | |
7550 void | |
7551 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
7552 { | |
7553 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
7554 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
7555 gtkconv->tab_cont)); | |
7556 } | |
7557 | |
7558 void | |
7559 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
7560 { | |
7561 GaimConversation *conv = gtkconv->active_conv; | |
7562 GaimGtkConversation *focus_gtkconv; | |
7563 GtkWidget *tabby, *menu_tabby; | |
7564 GtkWidget *tab_cont = gtkconv->tab_cont; | |
7565 GtkWidget *close_image; | |
7566 GaimConversationType conv_type; | |
7567 const gchar *tmp_lab; | |
13788
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7568 gint close_button_width, close_button_height, focus_width, focus_pad; |
11619 | 7569 gboolean tabs_side = FALSE; |
7570 gint angle = 0; | |
11581 | 7571 |
7572 conv_type = gaim_conversation_get_type(conv); | |
7573 | |
7574 | |
7575 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
7576 gtkconv->win = win; | |
7577 | |
11619 | 7578 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
7579 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
7580 tabs_side = TRUE; | |
7581 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
7582 angle = 90; | |
7583 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
7584 angle = 270; | |
7585 | |
7586 if (angle) | |
7587 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
7588 else | |
7589 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 7590 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
7591 | |
7592 /* Close button. */ | |
7593 gtkconv->close = gtk_button_new(); | |
13788
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7594 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); |
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7595 if (gtk_check_version(2, 4, 2) == NULL) { |
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7596 /* Need to account for extra padding around the gtkbutton */ |
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7597 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), |
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7598 "focus-line-width", &focus_width, |
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7599 "focus-padding", &focus_pad, |
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7600 NULL); |
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7601 close_button_width += (focus_width + focus_pad) * 2; |
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7602 close_button_height += (focus_width + focus_pad) * 2; |
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7603 } |
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7604 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), |
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7605 close_button_width, close_button_height); |
ef95bcc62330
[gaim-migrate @ 16200]
Richard Laager <rlaager@wiktel.com>
parents:
13787
diff
changeset
|
7606 |
11581 | 7607 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); |
7608 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
7609 gtk_widget_show(close_image); | |
7610 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
7611 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
7612 _("Close conversation"), NULL); | |
7613 | |
7614 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
7615 G_CALLBACK(close_conv_cb), gtkconv); | |
7616 | |
11851 | 7617 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 7618 /* |
7619 * I love Galeon. They have a fix for that stupid annoying visible | |
7620 * border bug. I love you guys! -- ChipX86 | |
7621 */ | |
11851 | 7622 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 7623 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
7624 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 7625 #endif |
11581 | 7626 |
7627 /* Status icon. */ | |
7628 gtkconv->icon = gtk_image_new(); | |
7629 gtkconv->menu_icon = gtk_image_new(); | |
7630 update_tab_icon(conv); | |
7631 | |
7632 /* Tab label. */ | |
7633 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 7634 |
11581 | 7635 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 7636 if (!angle) |
7637 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 7638 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 7639 if (tabs_side) { |
13769
1afc1b0c4fb3
[gaim-migrate @ 16181]
Richard Laager <rlaager@wiktel.com>
parents:
13750
diff
changeset
|
7640 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 12)); |
11619 | 7641 } |
7642 if (angle) | |
7643 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 7644 #endif |
7645 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
7646 #if 0 | |
7647 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
7648 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
7649 #endif | |
7650 | |
7651 /* Pack it all together. */ | |
11619 | 7652 if (angle == 90) |
7653 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
7654 else | |
7655 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 7656 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
7657 FALSE, FALSE, 0); | |
7658 | |
7659 gtk_widget_show_all(gtkconv->icon); | |
7660 gtk_widget_show_all(gtkconv->menu_icon); | |
7661 | |
7662 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
7663 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
7664 gtk_widget_show(gtkconv->tab_label); | |
7665 gtk_widget_show(gtkconv->menu_label); | |
7666 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
7667 | |
11619 | 7668 if (angle == 90) |
7669 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
7670 else | |
7671 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 7672 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
7673 gtk_widget_show(gtkconv->close); | |
7674 | |
7675 gtk_widget_show(tabby); | |
7676 gtk_widget_show(menu_tabby); | |
7677 | |
7678 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
7679 gaim_gtkconv_update_buddy_icon(conv); | |
7680 | |
7681 /* Add this pane to the conversation's notebook. */ | |
7682 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 7683 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 7684 |
7685 | |
7686 gtk_widget_show(tab_cont); | |
7687 | |
7688 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
7689 /* Er, bug in notebooks? Switch to the page manually. */ | |
7690 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
7691 | |
7692 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7693 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7694 } else | |
7695 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
7696 | |
7697 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
7698 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
7699 gtk_widget_grab_focus(focus_gtkconv->entry); | |
7700 | |
7701 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 7702 update_send_to_selection(win); |
11581 | 7703 } |
7704 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7705 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7706 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
11581 | 7707 { |
7708 unsigned int index; | |
7709 GaimConversationType conv_type; | |
7710 | |
7711 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
7712 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
7713 | |
7714 g_object_ref(gtkconv->tab_cont); | |
7715 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
7716 | |
7717 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
7718 | |
7719 /* go back to tabless if need be */ | |
7720 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
7721 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7722 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7723 } | |
7724 | |
7725 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 7726 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7727 if (!win->gtkconvs && win != hidden_convwin) |
11582 | 7728 gaim_gtk_conv_window_destroy(win); |
11581 | 7729 } |
7730 | |
7731 GaimGtkConversation * | |
7732 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
7733 { | |
7734 GtkWidget *tab_cont; | |
7735 | |
7736 if (index == -1) | |
7737 index = 0; | |
7738 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 7739 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 7740 } |
7741 | |
7742 GaimGtkConversation * | |
7743 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
7744 { | |
7745 int index; | |
7746 GtkWidget *tab_cont; | |
7747 | |
7748 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
7749 if (index == -1) | |
7750 index = 0; | |
7751 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
7752 if (!tab_cont) | |
7753 return NULL; | |
7754 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
7755 } | |
7756 | |
7757 | |
7758 GaimConversation * | |
7759 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
7760 { | |
7761 GaimGtkConversation *gtkconv; | |
7762 | |
7763 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
7764 return gtkconv ? gtkconv->active_conv : NULL; | |
7765 } | |
7766 | |
7767 gboolean | |
7768 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
7769 { | |
7770 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
7771 } | |
7772 | |
7773 gboolean | |
7774 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
7775 { | |
7776 gboolean has_focus = FALSE; | |
7777 | |
7778 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
7779 | |
7780 return has_focus; | |
7781 } | |
7782 | |
7783 GaimGtkWindow * | |
7784 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
7785 { | |
7786 GaimGtkWindow *win; | |
7787 GdkWindow *gdkwin; | |
7788 GList *l; | |
7789 | |
7790 gdkwin = gdk_window_at_pointer(&x, &y); | |
7791 | |
7792 if (gdkwin) | |
7793 gdkwin = gdk_window_get_toplevel(gdkwin); | |
7794 | |
7795 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
7796 win = l->data; | |
7797 | |
7798 if (gdkwin == win->window->window) | |
7799 return win; | |
7800 } | |
7801 | |
7802 return NULL; | |
7803 } | |
7804 | |
7805 GList * | |
7806 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
7807 { | |
7808 return win->gtkconvs; | |
7809 } | |
7810 | |
7811 guint | |
7812 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
7813 { | |
7814 return g_list_length(win->gtkconvs); | |
7815 } | |
7816 | |
7817 GaimGtkWindow * | |
7818 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
7819 { | |
7820 GList *wins, *convs; | |
7821 GaimGtkWindow *win; | |
7822 GaimGtkConversation *conv; | |
7823 | |
7824 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7825 return NULL; | |
7826 | |
7827 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7828 win = wins->data; | |
7829 | |
7830 for (convs = win->gtkconvs; | |
7831 convs != NULL; | |
7832 convs = convs->next) { | |
7833 | |
7834 conv = convs->data; | |
7835 | |
7836 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7837 return win; | |
7838 } | |
7839 } | |
7840 | |
7841 return NULL; | |
7842 } | |
7843 | |
7844 GaimGtkWindow * | |
7845 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
7846 { | |
7847 GList *wins, *convs; | |
7848 GaimGtkWindow *win; | |
7849 GaimGtkConversation *conv; | |
7850 | |
7851 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7852 return NULL; | |
7853 | |
7854 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7855 wins != NULL; | |
7856 wins = wins->prev) { | |
7857 | |
7858 win = wins->data; | |
7859 | |
7860 for (convs = win->gtkconvs; | |
7861 convs != NULL; | |
7862 convs = convs->next) { | |
7863 | |
7864 conv = convs->data; | |
7865 | |
7866 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7867 return win; | |
7868 } | |
7869 } | |
7870 | |
7871 return NULL; | |
7872 } | |
7873 | |
7874 | |
7875 /************************************************************************** | |
7876 * Conversation placement functions | |
7877 **************************************************************************/ | |
7878 typedef struct | |
7879 { | |
7880 char *id; | |
7881 char *name; | |
7882 GaimConvPlacementFunc fnc; | |
7883 | |
7884 } ConvPlacementData; | |
7885 | |
7886 static GList *conv_placement_fncs = NULL; | |
7887 static GaimConvPlacementFunc place_conv = NULL; | |
7888 | |
7889 /* This one places conversations in the last made window. */ | |
7890 static void | |
7891 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7892 { | |
7893 GaimGtkWindow *win; | |
7894 | |
7895 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7896 win = l ? l->data : NULL;; | |
7897 | |
7898 if (win == NULL) { | |
7899 win = gaim_gtk_conv_window_new(); | |
7900 | |
7901 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7902 gaim_gtk_conv_window_show(win); | |
7903 } else { | |
7904 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7905 } | |
7906 } | |
7907 | |
7908 /* This one places conversations in the last made window of the same type. */ | |
7909 static void | |
7910 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7911 { | |
7912 GaimGtkWindow *win; | |
7913 | |
7914 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7915 | |
7916 if (win == NULL) { | |
7917 win = gaim_gtk_conv_window_new(); | |
7918 | |
7919 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7920 gaim_gtk_conv_window_show(win); | |
7921 } else | |
7922 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7923 } | |
7924 | |
7925 /* This one places each conversation in its own window. */ | |
7926 static void | |
7927 conv_placement_new_window(GaimGtkConversation *conv) | |
7928 { | |
7929 GaimGtkWindow *win; | |
7930 | |
7931 win = gaim_gtk_conv_window_new(); | |
7932 | |
7933 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7934 | |
7935 gaim_gtk_conv_window_show(win); | |
7936 } | |
7937 | |
7938 static GaimGroup * | |
7939 conv_get_group(GaimGtkConversation *conv) | |
7940 { | |
7941 GaimGroup *group = NULL; | |
7942 | |
7943 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7944 GaimBuddy *buddy; | |
7945 | |
7946 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7947 gaim_conversation_get_name(conv->active_conv)); | |
7948 | |
7949 if (buddy != NULL) | |
12088 | 7950 group = gaim_buddy_get_group(buddy); |
11581 | 7951 |
7952 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7953 GaimChat *chat; | |
7954 | |
7955 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7956 gaim_conversation_get_name(conv->active_conv)); | |
7957 | |
7958 if (chat != NULL) | |
7959 group = gaim_chat_get_group(chat); | |
7960 } | |
7961 | |
7962 return group; | |
7963 } | |
7964 | |
7965 /* | |
7966 * This groups things by, well, group. Buddies from groups will always be | |
7967 * grouped together, and a buddy from a group not belonging to any currently | |
7968 * open windows will get a new window. | |
7969 */ | |
7970 static void | |
7971 conv_placement_by_group(GaimGtkConversation *conv) | |
7972 { | |
7973 GaimConversationType type; | |
7974 GaimGroup *group = NULL; | |
7975 GList *wl, *cl; | |
7976 | |
7977 type = gaim_conversation_get_type(conv->active_conv); | |
7978 | |
7979 group = conv_get_group(conv); | |
7980 | |
7981 /* Go through the list of IMs and find one with this group. */ | |
7982 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7983 GaimGtkWindow *win2; | |
7984 GaimGtkConversation *conv2; | |
7985 GaimGroup *group2 = NULL; | |
7986 | |
7987 win2 = wl->data; | |
7988 | |
7989 for (cl = win2->gtkconvs; | |
7990 cl != NULL; | |
7991 cl = cl->next) { | |
7992 conv2 = cl->data; | |
7993 | |
7994 group2 = conv_get_group(conv2); | |
7995 | |
7996 if (group == group2) { | |
7997 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7998 | |
7999 return; | |
8000 } | |
8001 } | |
8002 } | |
8003 | |
8004 /* Make a new window. */ | |
8005 conv_placement_new_window(conv); | |
8006 } | |
8007 | |
8008 /* This groups things by account. Otherwise, the same semantics as above */ | |
8009 static void | |
8010 conv_placement_by_account(GaimGtkConversation *conv) | |
8011 { | |
8012 GaimConversationType type; | |
8013 GList *wins, *convs; | |
8014 GaimAccount *account; | |
8015 | |
8016 account = gaim_conversation_get_account(conv->active_conv); | |
8017 type = gaim_conversation_get_type(conv->active_conv); | |
8018 | |
8019 /* Go through the list of IMs and find one with this group. */ | |
8020 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
8021 GaimGtkWindow *win2; | |
8022 GaimGtkConversation *conv2; | |
8023 | |
8024 win2 = wins->data; | |
8025 | |
8026 for (convs = win2->gtkconvs; | |
8027 convs != NULL; | |
8028 convs = convs->next) { | |
8029 conv2 = convs->data; | |
8030 | |
8031 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
8032 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
8033 return; | |
8034 } | |
8035 } | |
8036 } | |
8037 | |
8038 /* Make a new window. */ | |
8039 conv_placement_new_window(conv); | |
8040 } | |
8041 | |
8042 static ConvPlacementData * | |
8043 get_conv_placement_data(const char *id) | |
8044 { | |
8045 ConvPlacementData *data = NULL; | |
8046 GList *n; | |
8047 | |
8048 for (n = conv_placement_fncs; n; n = n->next) { | |
8049 data = n->data; | |
8050 if (!strcmp(data->id, id)) | |
8051 return data; | |
8052 } | |
8053 | |
8054 return NULL; | |
8055 } | |
8056 | |
8057 static void | |
8058 add_conv_placement_fnc(const char *id, const char *name, | |
8059 GaimConvPlacementFunc fnc) | |
8060 { | |
8061 ConvPlacementData *data; | |
8062 | |
8063 data = g_new(ConvPlacementData, 1); | |
8064 | |
8065 data->id = g_strdup(id); | |
8066 data->name = g_strdup(name); | |
8067 data->fnc = fnc; | |
8068 | |
8069 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
8070 } | |
8071 | |
8072 static void | |
8073 ensure_default_funcs(void) | |
8074 { | |
8075 if (conv_placement_fncs == NULL) { | |
8076 add_conv_placement_fnc("last", _("Last created window"), | |
8077 conv_placement_last_created_win); | |
8078 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
8079 conv_placement_last_created_win_type); | |
8080 add_conv_placement_fnc("new", _("New window"), | |
8081 conv_placement_new_window); | |
8082 add_conv_placement_fnc("group", _("By group"), | |
8083 conv_placement_by_group); | |
8084 add_conv_placement_fnc("account", _("By account"), | |
8085 conv_placement_by_account); | |
8086 } | |
8087 } | |
8088 | |
8089 GList * | |
8090 gaim_gtkconv_placement_get_options(void) | |
8091 { | |
8092 GList *n, *list = NULL; | |
8093 ConvPlacementData *data; | |
8094 | |
8095 ensure_default_funcs(); | |
8096 | |
8097 for (n = conv_placement_fncs; n; n = n->next) { | |
8098 data = n->data; | |
8099 list = g_list_append(list, data->name); | |
8100 list = g_list_append(list, data->id); | |
8101 } | |
8102 | |
8103 return list; | |
8104 } | |
8105 | |
8106 | |
8107 void | |
8108 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
8109 GaimConvPlacementFunc fnc) | |
8110 { | |
8111 g_return_if_fail(id != NULL); | |
8112 g_return_if_fail(name != NULL); | |
8113 g_return_if_fail(fnc != NULL); | |
8114 | |
8115 ensure_default_funcs(); | |
8116 | |
8117 add_conv_placement_fnc(id, name, fnc); | |
8118 } | |
8119 | |
8120 void | |
8121 gaim_gtkconv_placement_remove_fnc(const char *id) | |
8122 { | |
8123 ConvPlacementData *data = get_conv_placement_data(id); | |
8124 | |
8125 if (data == NULL) | |
8126 return; | |
8127 | |
8128 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
8129 | |
8130 g_free(data->id); | |
8131 g_free(data->name); | |
8132 g_free(data); | |
8133 } | |
8134 | |
8135 const char * | |
8136 gaim_gtkconv_placement_get_name(const char *id) | |
8137 { | |
8138 ConvPlacementData *data; | |
8139 | |
8140 ensure_default_funcs(); | |
8141 | |
8142 data = get_conv_placement_data(id); | |
8143 | |
8144 if (data == NULL) | |
8145 return NULL; | |
8146 | |
8147 return data->name; | |
8148 } | |
8149 | |
8150 GaimConvPlacementFunc | |
8151 gaim_gtkconv_placement_get_fnc(const char *id) | |
8152 { | |
8153 ConvPlacementData *data; | |
8154 | |
8155 ensure_default_funcs(); | |
8156 | |
8157 data = get_conv_placement_data(id); | |
8158 | |
8159 if (data == NULL) | |
8160 return NULL; | |
8161 | |
8162 return data->fnc; | |
8163 } | |
8164 | |
8165 void | |
8166 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
8167 { | |
8168 g_return_if_fail(func != NULL); | |
8169 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8170 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8171 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8172 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8173 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8174 place_conv = NULL; |
11581 | 8175 } |
8176 | |
8177 GaimConvPlacementFunc | |
8178 gaim_gtkconv_placement_get_current_func(void) | |
8179 { | |
8180 return place_conv; | |
8181 } | |
8182 | |
8183 void | |
8184 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
8185 { | |
8186 if (place_conv) | |
8187 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8188 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8189 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
8190 } |
12239 | 8191 |
8192 gboolean | |
8193 gaim_gtkconv_is_hidden(GaimGtkConversation *gtkconv) | |
8194 { | |
8195 g_return_val_if_fail(gtkconv != NULL, FALSE); | |
8196 | |
8197 return (gtkconv->win == hidden_convwin); | |
8198 } | |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8199 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8200 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8201 /* Algorithm from http://www.w3.org/TR/AERT#color-contrast */ |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
8202 static gboolean |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8203 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
|
8204 { |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8205 gulong fg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8206 gulong bg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8207 gulong br_diff; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8208 gulong col_diff; |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8209 int fred, fgreen, fblue, bred, bgreen, bblue; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8210 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8211 /* 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
|
8212 * GTK on the other hand has values between 0 and 65535 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8213 * Err suggested I >> 8, which grabbed the high bits. |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8214 */ |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8215 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8216 fred = foreground.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8217 fgreen = foreground.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8218 fblue = foreground.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8219 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8220 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8221 bred = background.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8222 bgreen = background.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8223 bblue = background.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8224 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8225 fg_brightness = (fred * 299 + fgreen * 587 + fblue * 114) / 1000; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8226 bg_brightness = (bred * 299 + bgreen * 587 + bblue * 114) / 1000; |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8227 br_diff = abs(fg_brightness - bg_brightness); |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8228 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8229 col_diff = abs(fred - bred) + abs(fgreen - bgreen) + abs(fblue - bblue); |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
8230 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8231 return ((col_diff > color_contrast) && (br_diff > brightness_contrast)); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8232 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8233 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8234 |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
8235 static GdkColor* |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8236 generate_nick_colors(guint *color_count, GdkColor background) |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8237 { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8238 guint numcolors = *color_count; |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8239 guint i = 0, j = 0; |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8240 GdkColor *colors = g_new(GdkColor, numcolors); |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8241 GdkColor nick_highlight; |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8242 GdkColor send_color; |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8243 time_t breakout_time; |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8244 |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8245 gdk_color_parse(HIGHLIGHT_COLOR, &nick_highlight); |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8246 gdk_color_parse(SEND_COLOR, &send_color); |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8247 |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8248 srand(background.red + background.green + background.blue + 1); |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8249 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8250 breakout_time = time(NULL) + 3; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8251 |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8252 /* 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
|
8253 * 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
|
8254 * numcolors of them that do |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8255 */ |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8256 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
|
8257 { |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8258 GdkColor color = nick_seed_colors[j]; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8259 |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8260 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
|
8261 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8262 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8263 { |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8264 colors[i] = color; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8265 i++; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8266 } |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8267 j++; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8268 } |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8269 |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8270 /* 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
|
8271 * 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
|
8272 * 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
|
8273 * conflict with each other. |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
8274 */ |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8275 while(i < numcolors && time(NULL) < breakout_time) |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8276 { |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
8277 GdkColor color = { 0, rand() % 65536, rand() % 65536, rand() % 65536 }; |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
8278 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8279 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
|
8280 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8281 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
8282 { |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8283 colors[i] = color; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8284 i++; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8285 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8286 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8287 |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8288 if (i < numcolors) { |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8289 GdkColor *c = colors; |
13519 | 8290 gaim_debug_warning("gtkconv", "Unable to generate enough random colors before timeout. %u colors found.\n", i); |
12801
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8291 colors = g_memdup(c, i * sizeof(GdkColor)); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8292 g_free(c); |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8293 *color_count = i; |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8294 } |
d24bc9737de8
[gaim-migrate @ 15148]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12797
diff
changeset
|
8295 |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8296 return colors; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
8297 } |