Mercurial > pidgin
annotate src/gtkconv.c @ 12116:e75ef7aa913e
[gaim-migrate @ 14416]
" This patch implements a replacement for the queuing
system from 1.x. It also obsoletes a previous patch
[#1338873] I submitted to prioritize the unseen states
in gtk conversations.
The attached envelope.png is ripped from the
msgunread.png already included in gaim. It should be
dropped in the pixmaps directory (Makefile.am is
updated accordingly in this patch).
The two separate queuing preferences from 1.x, queuing
messages while away and queuing all new messages (from
docklet), are replaced with a single 3-way preference
for conversations. The new preference is "Hide new IM
conversations". This preference can be set to never,
away and always.
When a gtk conversation is created, it may be placed in
a hidden conversation window instead of being placed
normally. This decision is based upon the preference
and possibly the away state of the account the
conversation is being created for. This *will* effect
conversations the user explicitly requests to be
created, so in these cases the caller must be sure to
present the conversation to the user, using
gaim_gtkconv_present_conversation(). This is done
already in gtkdialogs.c which handles creating
conversations requested by the user from gaim proper
(menus, double-clicking on budy in blist, etc.).
The main advantage to not queuing messages is that the
conversations exist, the message is written to the
conversation (and logged if appropriate) and the unseen
state is set on the conversation. This means no
additional features are needed to track whether there
are queued messages or not, just use the unseen state
on conversations.
Since conversations may not be visible (messages
"queued"), gaim proper needs some notification that
there are messages waiting. I opted for a menutray icon
that shows up when an im conversation has an unseen
message. Clicking this icon will focus (and show if
hidden) the first conversation with an unseen message.
This is essentially the same behavior of the docklet in
cvs right now, except that the icon is only visible
when there is a conversation with an unread message.
The api that is added is flexible enough to allow
either the docklet or the new blist menutray icon to be
visible for conversations of any/all types and for
unseen messages >= any state. Currently they are set to
only IM conversations and only unseen states >= TEXT
(system messages and no log messages will not trigger
blinking the docklet or showing the blist tray icon),
but these could be made preferences relatively easily
in the future. Other plugins could probably benefit as
well: gaim_gtk_conversations_get_first_unseen().
There is probably some limit to comment size, so I'll
stop rambling now. If anyone has more
questions/comments, catch me in #gaim, here or on
gaim-devel."
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Wed, 16 Nov 2005 18:17:01 +0000 |
parents | 8c6ea55c84a4 |
children | cb7ccb5048cf |
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" |
6982 | 45 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
46 #include "log.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5402
diff
changeset
|
47 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
48 #include "prpl.h" |
6038 | 49 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
50 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
51 |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
52 #include "gtkdnd-hints.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
53 #include "gtkblist.h" |
5717 | 54 #include "gtkconv.h" |
11583 | 55 #include "gtkconvwin.h" |
9709 | 56 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
57 #include "gtkimhtml.h" |
8317 | 58 #include "gtkimhtmltoolbar.h" |
7431 | 59 #include "gtklog.h" |
11554
f8443218b7fe
[gaim-migrate @ 13814]
Gary Kramlich <grim@reaperworld.com>
parents:
11552
diff
changeset
|
60 #include "gtkmenutray.h" |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
61 #include "gtkpounce.h" |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
62 #include "gtkprefs.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
63 #include "gtkprivacy.h" |
11525 | 64 #include "gtkthemes.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
65 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
66 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
67 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
68 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
69 |
11731 | 70 #define SEND_COLOR "#001f41" |
71 #define RECV_COLOR "#a63802" | |
7854 | 72 |
10108 | 73 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
74 | |
75 /* These colors come from the default GNOME palette */ | |
76 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
77 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
78 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
79 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
80 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
81 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
82 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
83 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
84 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
85 {0, 34816, 17920, 12544}, /* Red Dark */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
86 {0, 49408, 14336, 8704}, /* Red Shadow */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
87 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
88 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
89 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
90 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
91 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
92 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
93 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
94 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
95 {0, 57088, 16896, 7680}, /* Accent Red */ |
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
96 {0, 39168, 0, 0}, /* Accent Red Dark */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
97 {0, 17920, 40960, 17920}, /* Accent Green */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
98 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 99 }; |
6291 | 100 |
4359 | 101 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
102 | |
11581 | 103 typedef struct { |
4359 | 104 GtkWidget *window; |
105 | |
106 GtkWidget *entry; | |
107 GtkWidget *message; | |
108 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
109 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
110 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
111 } InviteBuddyInfo; |
4359 | 112 |
113 static GtkWidget *invite_dialog = NULL; | |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
114 static GtkWidget *warn_close_dialog = NULL; |
4359 | 115 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
116 static GaimGtkWindow *hidden_convwin = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
117 static GList *window_list = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
118 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
119 |
11594 | 120 static gboolean update_send_to_selection(GaimGtkWindow *win); |
121 static void generate_send_to_items(GaimGtkWindow *win); | |
11581 | 122 |
4359 | 123 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
10810 | 124 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
11604 | 125 static void gray_stuff_out(GaimGtkConversation *gtkconv); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
126 static GList *generate_invite_user_names(GaimConnection *gc); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
127 static void add_chat_buddy_common(GaimConversation *conv, const char *name, |
11869 | 128 GaimConvChatBuddyFlags flags, const char *alias, const char *old_name); |
9605 | 129 static gboolean tab_complete(GaimConversation *conv); |
11604 | 130 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); |
11613 | 131 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); |
10810 | 132 static void update_typing_icon(GaimGtkConversation *gtkconv); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
133 static char *item_factory_translate_func (const char *path, gpointer func_data); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
134 gboolean gaim_gtkconv_has_focus(GaimConversation *conv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
135 static void private_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
136 gboolean destroy_empty); |
4359 | 137 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
138 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
139 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
140 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
141 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
142 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
143 col = nick_colors[g_str_hash(name) % NUM_NICK_COLORS]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
144 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
145 (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
|
146 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
147 /* 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
|
148 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
149 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
150 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
151 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
152 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
153 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
154 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
155 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
156 |
4359 | 157 /************************************************************************** |
158 * Callbacks | |
159 **************************************************************************/ | |
10971 | 160 |
4359 | 161 static gint |
10810 | 162 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 163 { |
10810 | 164 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 165 |
10810 | 166 l = list; |
167 while (l) { | |
168 GaimConversation *conv = l->data; | |
169 gaim_conversation_destroy(conv); | |
170 l = l->next; | |
171 } | |
11508 | 172 |
10810 | 173 g_list_free(list); |
11508 | 174 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
175 return TRUE; |
4359 | 176 } |
177 | |
8914 | 178 static gboolean |
10810 | 179 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 180 { |
10810 | 181 GaimConversation *conv = gtkconv->active_conv; |
11508 | 182 |
8914 | 183 if (!GTK_WIDGET_VISIBLE(w)) |
184 return FALSE; | |
185 | |
186 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
187 return FALSE; | |
188 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
189 /* 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
|
190 * 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
|
191 * 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
|
192 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
193 /* 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
|
194 * negate it anyway. --luke */ |
11338 | 195 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 196 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
197 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
198 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
|
199 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
|
200 } |
8914 | 201 if (w == gtkconv->entry) |
202 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
203 } | |
11338 | 204 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 205 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
206 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
207 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
|
208 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
|
209 } |
8914 | 210 if (w == gtkconv->entry) |
211 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
212 } | |
213 | |
214 return FALSE; | |
215 } | |
216 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
217 static void |
10810 | 218 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
219 { |
10810 | 220 GaimConversation *conv = c->active_conv; |
11508 | 221 |
10665 | 222 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
223 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
224 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
225 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
226 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
227 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
|
228 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
229 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
230 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
|
231 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
232 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
233 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
|
234 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
235 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
236 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
237 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
238 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
239 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
240 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
241 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
242 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
243 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
|
244 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
245 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
246 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
247 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
248 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
249 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
250 fg_color.blue / 256); |
8061 | 251 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
252 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
253 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
254 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
255 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
256 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
259 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
261 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
262 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
264 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
266 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
267 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
268 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
269 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
270 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
271 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
272 g_free(color); |
8677 | 273 |
9025 | 274 |
10665 | 275 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 276 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
277 else | |
278 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 279 } |
280 } | |
9130 | 281 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
282 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
283 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
284 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
285 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
286 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
287 |
9130 | 288 static const char * |
289 gaim_gtk_get_cmd_prefix(void) | |
290 { | |
291 return "/"; | |
292 } | |
293 | |
9167 | 294 static GaimCmdRet |
9829 | 295 say_command_cb(GaimConversation *conv, |
296 const char *cmd, char **args, char **error, void *data) | |
297 { | |
11338 | 298 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 299 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 300 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 301 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
302 | |
303 return GAIM_CMD_RET_OK; | |
304 } | |
305 | |
306 static GaimCmdRet | |
9167 | 307 me_command_cb(GaimConversation *conv, |
9597 | 308 const char *cmd, char **args, char **error, void *data) |
9167 | 309 { |
310 char *tmp; | |
311 | |
312 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 313 |
11338 | 314 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 315 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 316 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 317 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
318 | |
319 g_free(tmp); | |
320 return GAIM_CMD_RET_OK; | |
321 } | |
322 | |
9212 | 323 static GaimCmdRet |
324 debug_command_cb(GaimConversation *conv, | |
9597 | 325 const char *cmd, char **args, char **error, void *data) |
9212 | 326 { |
327 char *tmp, *markup; | |
328 GaimCmdStatus status; | |
329 | |
330 if (!g_ascii_strcasecmp(args[0], "version")) { | |
331 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
|
332 markup = g_markup_escape_text(tmp, -1); |
9212 | 333 |
334 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
335 | |
336 g_free(tmp); | |
337 g_free(markup); | |
338 return status; | |
339 } else { | |
340 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
341 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
342 return GAIM_CMD_STATUS_OK; | |
343 } | |
344 } | |
345 | |
9213 | 346 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
347 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
348 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
349 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
350 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
351 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
352 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
353 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
354 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
355 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
356 } |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
357 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
358 static GaimCmdRet |
9213 | 359 help_command_cb(GaimConversation *conv, |
9597 | 360 const char *cmd, char **args, char **error, void *data) |
9213 | 361 { |
9597 | 362 GList *l, *text; |
9213 | 363 GString *s; |
9597 | 364 |
365 if (args[0] != NULL) { | |
366 s = g_string_new(""); | |
367 text = gaim_cmd_help(conv, args[0]); | |
368 | |
369 if (text) { | |
370 for (l = text; l; l = l->next) | |
371 if (l->next) | |
9816 | 372 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 373 else |
9816 | 374 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 375 } else { |
376 g_string_append(s, _("No such command (in this context).")); | |
377 } | |
378 } else { | |
379 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
380 "The following commands are available in this context:\n")); | |
381 | |
382 text = gaim_cmd_list(conv); | |
383 for (l = text; l; l = l->next) | |
9213 | 384 if (l->next) |
9597 | 385 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 386 else |
9597 | 387 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 388 } |
389 | |
390 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
391 g_string_free(s, TRUE); | |
392 | |
393 return GAIM_CMD_STATUS_OK; | |
394 } | |
395 | |
4359 | 396 static void |
9374 | 397 send_history_add(GaimConversation *conv, const char *message) |
398 { | |
399 GList *first; | |
400 | |
401 first = g_list_first(conv->send_history); | |
402 | |
403 if (first->data) | |
404 g_free(first->data); | |
405 | |
406 first->data = g_strdup(message); | |
407 | |
408 conv->send_history = g_list_prepend(first, NULL); | |
409 } | |
410 | |
9832 | 411 static gboolean |
412 check_for_and_do_command(GaimConversation *conv) | |
413 { | |
414 GaimGtkConversation *gtkconv; | |
415 char *cmd; | |
416 const char *prefix; | |
417 GaimAccount *account; | |
418 GtkTextIter start; | |
419 | |
420 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
421 account = gaim_conversation_get_account(conv); | |
422 prefix = gaim_gtk_get_cmd_prefix(); | |
423 | |
424 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
425 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
426 | |
427 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
428 && !gtk_text_iter_get_child_anchor(&start)) { | |
429 GaimCmdStatus status; | |
430 char *error, *cmdline, *markup, *send_history; | |
431 GtkTextIter end; | |
432 | |
433 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
434 send_history_add(conv, send_history); | |
435 g_free(send_history); | |
436 | |
437 cmdline = cmd + strlen(prefix); | |
438 | |
439 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
440 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
441 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
442 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
443 g_free(cmd); | |
444 g_free(markup); | |
445 | |
446 switch (status) { | |
447 case GAIM_CMD_STATUS_OK: | |
448 return TRUE; | |
449 case GAIM_CMD_STATUS_NOT_FOUND: | |
450 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
451 gaim_conversation_write(conv, "", _("No such command."), | |
452 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
453 | |
454 return TRUE; | |
455 } | |
456 return FALSE; | |
457 case GAIM_CMD_STATUS_WRONG_ARGS: | |
458 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
459 "to that command."), | |
460 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
461 return TRUE; | |
462 case GAIM_CMD_STATUS_FAILED: | |
463 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
464 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
465 if(error) | |
466 g_free(error); | |
467 return TRUE; | |
468 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 469 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 470 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 471 GAIM_MESSAGE_NO_LOG, time(NULL)); |
472 else | |
10843 | 473 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 474 GAIM_MESSAGE_NO_LOG, time(NULL)); |
475 return TRUE; | |
476 case GAIM_CMD_STATUS_WRONG_PRPL: | |
477 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
478 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
479 return TRUE; | |
480 } | |
481 } | |
482 | |
483 g_free(cmd); | |
484 return FALSE; | |
485 } | |
486 | |
9374 | 487 static void |
10810 | 488 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 489 { |
10810 | 490 GaimConversation *conv = gtkconv->active_conv; |
8655 | 491 GaimAccount *account; |
8677 | 492 GaimConnection *gc; |
8448 | 493 char *buf, *clean; |
4359 | 494 |
8655 | 495 account = gaim_conversation_get_account(conv); |
9130 | 496 |
9471 | 497 if (!gaim_account_is_connected(account)) |
498 return; | |
499 | |
11338 | 500 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 501 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 502 return; |
503 | |
9832 | 504 if (check_for_and_do_command(conv)) { |
505 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
506 return; | |
9130 | 507 } |
508 | |
8442 | 509 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 510 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 511 |
4359 | 512 gtk_widget_grab_focus(gtkconv->entry); |
513 | |
8448 | 514 if (strlen(clean) == 0) { |
515 g_free(clean); | |
4359 | 516 return; |
517 } | |
518 | |
8677 | 519 gc = gaim_account_get_connection(account); |
10665 | 520 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 521 char **bufs; |
522 int i; | |
523 | |
524 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
525 for (i = 0; bufs[i]; i++) { | |
9374 | 526 send_history_add(conv, bufs[i]); |
11338 | 527 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8677 | 528 gaim_conv_im_send(GAIM_CONV_IM(conv), bufs[i]); |
11338 | 529 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8677 | 530 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), bufs[i]); |
531 } | |
532 | |
533 g_strfreev(bufs); | |
534 | |
535 } else { | |
9374 | 536 send_history_add(conv, buf); |
11338 | 537 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8677 | 538 gaim_conv_im_send(GAIM_CONV_IM(conv), buf); |
11338 | 539 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8677 | 540 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), buf); |
541 } | |
4359 | 542 |
8677 | 543 g_free(clean); |
4359 | 544 g_free(buf); |
545 | |
8061 | 546 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 547 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 548 } |
549 | |
550 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
551 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 552 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
553 GaimAccount *account; |
4359 | 554 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
555 GaimConversation *conv = gtkconv->active_conv; |
4359 | 556 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
557 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
558 name = gaim_conversation_get_name(conv); |
7879 | 559 |
11338 | 560 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 561 GaimBuddy *b; |
562 | |
563 b = gaim_find_buddy(account, name); | |
564 if (b != NULL) | |
9730 | 565 gaim_gtkdialogs_remove_buddy(b); |
7859 | 566 else if (account != NULL && gaim_account_is_connected(account)) |
567 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 568 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 569 GaimChat *c; |
570 | |
571 c = gaim_blist_find_chat(account, name); | |
572 if (c != NULL) | |
9730 | 573 gaim_gtkdialogs_remove_chat(c); |
7859 | 574 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 575 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 576 } |
4359 | 577 |
578 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
579 } | |
580 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
581 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 582 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
583 GaimConversation *conv = gtkconv->active_conv; |
7975 | 584 GaimPluginProtocolInfo *prpl_info = NULL; |
585 GaimConnection *gc; | |
586 | |
587 if ((gc = gaim_conversation_get_gc(conv))) { | |
588 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
589 | |
590 /* | |
591 * If there are special needs for getting info on users in | |
592 * buddy chat "rooms"... | |
593 */ | |
594 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
595 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
596 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
597 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
598 } |
7975 | 599 else |
600 prpl_info->get_info(gc, who); | |
601 } | |
602 } | |
603 | |
604 | |
4359 | 605 static void |
10810 | 606 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 607 { |
10810 | 608 GaimConversation *conv = gtkconv->active_conv; |
4359 | 609 |
11338 | 610 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 611 serv_get_info(gaim_conversation_get_gc(conv), |
612 gaim_conversation_get_name(conv)); | |
613 | |
614 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 615 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 616 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
617 GaimGtkChatPane *gtkchat; |
4359 | 618 GtkTreeIter iter; |
619 GtkTreeModel *model; | |
620 GtkTreeSelection *sel; | |
9554 | 621 char *name; |
4359 | 622 |
623 gtkchat = gtkconv->u.chat; | |
624 | |
625 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
626 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
627 | |
628 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 629 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 630 else |
631 return; | |
632 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
633 chat_do_info(gtkconv, name); |
9554 | 634 g_free(name); |
4359 | 635 } |
636 } | |
637 | |
638 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
639 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 640 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
641 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
642 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
643 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
644 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
645 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
646 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
647 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 648 |
649 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
650 } | |
651 | |
652 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
653 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 654 { |
655 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
656 GaimGtkConversation *gtkconv; |
4359 | 657 |
658 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
659 | |
660 if (resp == GTK_RESPONSE_OK) { | |
661 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
662 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
663 | |
10113 | 664 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 665 return; |
666 | |
667 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
668 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 669 message, buddy); |
670 } | |
671 | |
672 gtk_widget_destroy(invite_dialog); | |
673 invite_dialog = NULL; | |
674 | |
675 g_free(info); | |
676 } | |
677 | |
678 static void | |
9909 | 679 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
680 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
681 { | |
682 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
683 const char *convprotocol; | |
684 | |
685 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
686 | |
687 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
688 { | |
689 GaimBlistNode *node = NULL; | |
690 GaimBuddy *buddy; | |
691 | |
692 memcpy(&node, sd->data, sizeof(node)); | |
693 | |
694 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
695 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
696 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
697 buddy = (GaimBuddy *)node; | |
698 else | |
699 return; | |
700 | |
701 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
702 { | |
703 gaim_notify_error(NULL, NULL, | |
704 _("That buddy is not on the same protocol as this " | |
10843 | 705 "chat."), NULL); |
9909 | 706 } |
707 else | |
708 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
709 | |
710 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
711 } | |
712 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
713 { | |
714 char *protocol = NULL; | |
715 char *username = NULL; | |
716 GaimAccount *account; | |
717 | |
11137 | 718 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 719 &protocol, &username, NULL)) |
720 { | |
721 if (account == NULL) | |
722 { | |
723 gaim_notify_error(NULL, NULL, | |
724 _("You are not currently signed on with an account that " | |
725 "can invite that buddy."), NULL); | |
726 } | |
727 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
728 { | |
729 gaim_notify_error(NULL, NULL, | |
730 _("That buddy is not on the same protocol as this " | |
10843 | 731 "chat."), NULL); |
9909 | 732 } |
733 else | |
734 { | |
735 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
736 } | |
737 } | |
738 | |
739 if (username != NULL) g_free(username); | |
740 if (protocol != NULL) g_free(protocol); | |
741 | |
742 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
743 } | |
744 } | |
745 | |
746 static const GtkTargetEntry dnd_targets[] = | |
747 { | |
748 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
749 {"application/x-im-contact", 0, 1} | |
750 }; | |
751 | |
752 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
753 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 754 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
755 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
756 InviteBuddyInfo *info = NULL; |
4359 | 757 |
758 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
759 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
760 GaimGtkWindow *gtkwin; |
4359 | 761 GtkWidget *label; |
762 GtkWidget *vbox, *hbox; | |
763 GtkWidget *table; | |
764 GtkWidget *img; | |
765 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
766 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 767 GTK_ICON_SIZE_DIALOG); |
4359 | 768 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
769 info = g_new0(InviteBuddyInfo, 1); |
4359 | 770 info->conv = conv; |
771 | |
11581 | 772 gc = gaim_conversation_get_gc(conv); |
773 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 774 |
775 /* Create the new dialog. */ | |
776 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 777 _("Invite Buddy Into Chat Room"), |
7879 | 778 GTK_WINDOW(gtkwin->window), 0, |
779 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
780 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 781 |
782 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 783 GTK_RESPONSE_OK); |
11243 | 784 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 785 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
786 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
787 | |
9909 | 788 info->window = GTK_WIDGET(invite_dialog); |
789 | |
4359 | 790 /* Setup the outside spacing. */ |
791 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
792 | |
11243 | 793 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
794 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 795 |
796 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 797 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 798 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
799 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
800 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
801 | |
802 /* Setup the right vbox. */ | |
803 vbox = gtk_vbox_new(FALSE, 0); | |
804 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
805 | |
806 /* Put our happy label in it. */ | |
807 label = gtk_label_new(_("Please enter the name of the user you wish " | |
808 "to invite, along with an optional invite " | |
809 "message.")); | |
810 gtk_widget_set_size_request(label, 350, -1); | |
811 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
812 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
813 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
814 | |
815 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 816 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 817 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
818 | |
819 /* Setup the table we're going to use to lay stuff out. */ | |
820 table = gtk_table_new(2, 2, FALSE); | |
11243 | 821 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
822 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
823 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 824 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
825 | |
826 /* Now the Buddy label */ | |
827 label = gtk_label_new(NULL); | |
828 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
829 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
830 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
831 | |
832 /* Now the Buddy drop-down entry field. */ | |
833 info->entry = gtk_combo_new(); | |
834 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
835 gtk_entry_set_activates_default( | |
836 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
837 | |
838 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
839 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
840 | |
841 /* Fill in the names. */ | |
842 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
843 generate_invite_user_names(gc)); | |
844 | |
845 | |
846 /* Now the label for "Message" */ | |
847 label = gtk_label_new(NULL); | |
848 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
849 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
850 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
851 | |
852 | |
853 /* And finally, the Message entry field. */ | |
854 info->message = gtk_entry_new(); | |
855 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
856 | |
857 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
858 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
859 | |
860 /* Connect the signals. */ | |
861 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
862 G_CALLBACK(do_invite), info); | |
9909 | 863 /* Setup drag-and-drop */ |
864 gtk_drag_dest_set(info->window, | |
865 GTK_DEST_DEFAULT_MOTION | | |
866 GTK_DEST_DEFAULT_DROP, | |
867 dnd_targets, | |
868 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
869 GDK_ACTION_COPY); | |
870 gtk_drag_dest_set(info->entry, | |
871 GTK_DEST_DEFAULT_MOTION | | |
872 GTK_DEST_DEFAULT_DROP, | |
873 dnd_targets, | |
874 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
875 GDK_ACTION_COPY); | |
876 | |
877 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
878 G_CALLBACK(invite_dnd_recv), info); | |
879 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
880 G_CALLBACK(invite_dnd_recv), info); | |
881 | |
4359 | 882 } |
883 | |
884 gtk_widget_show_all(invite_dialog); | |
885 | |
886 if (info != NULL) | |
887 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
888 } | |
889 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
890 static void |
7748 | 891 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
892 { | |
9714 | 893 gaim_gtkdialogs_im(); |
7748 | 894 } |
895 | |
896 static void | |
9504 | 897 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 898 { |
9504 | 899 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 900 FILE *fp; |
901 const char *name; | |
10849 | 902 gchar *text; |
9489 | 903 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
904 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9504 | 905 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 906 return; |
907 } | |
908 | |
909 name = gaim_conversation_get_name(conv); | |
10849 | 910 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 911 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 912 |
913 text = gtk_imhtml_get_markup( | |
914 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
915 fprintf(fp, "%s", text); | |
916 g_free(text); | |
917 | |
918 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 919 fclose(fp); |
920 } | |
921 | |
10849 | 922 /* |
923 * It would be kinda cool if this gave the option of saving a | |
924 * plaintext v. HTML file. | |
925 */ | |
9489 | 926 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
927 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
928 { |
11581 | 929 GaimGtkWindow *win = data; |
930 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 931 gchar *buf; |
932 | |
933 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 934 |
10849 | 935 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
936 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 937 |
938 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
939 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
940 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
941 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
942 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
943 { |
11581 | 944 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
945 GaimConversation *conv; |
9917 | 946 GaimLogType type; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
947 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
948 GaimAccount *account; |
10845 | 949 GSList *buddies, *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
950 |
11581 | 951 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
952 |
11338 | 953 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 954 type = GAIM_LOG_IM; |
11338 | 955 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 956 type = GAIM_LOG_CHAT; |
957 else | |
958 return; | |
959 | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
960 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
961 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
962 |
10845 | 963 buddies = gaim_find_buddies(account, name); |
964 for (cur = buddies; cur != NULL; cur = cur->next) | |
965 { | |
966 GaimBlistNode *node = cur->data; | |
10846 | 967 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 968 { |
969 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
970 g_slist_free(buddies); | |
971 return; | |
972 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
973 } |
10845 | 974 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
975 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
976 gaim_gtk_log_show(type, name, account); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
977 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
978 |
8974 | 979 static void |
980 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
981 { | |
11581 | 982 GaimGtkWindow *win = data; |
8974 | 983 GaimConversation *conv; |
984 GaimGtkConversation *gtkconv; | |
985 | |
11581 | 986 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 987 gtkconv = GAIM_GTK_CONVERSATION(conv); |
988 | |
989 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
990 } | |
991 | |
7295 | 992 struct _search { |
993 GaimGtkConversation *gtkconv; | |
994 GtkWidget *entry; | |
995 }; | |
996 | |
7929 | 997 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 998 { |
7929 | 999 switch (resp) { |
1000 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1001 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1002 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1003 break; |
1004 | |
1005 case GTK_RESPONSE_DELETE_EVENT: | |
1006 case GTK_RESPONSE_CLOSE: | |
1007 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1008 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1009 s->gtkconv->dialogs.search = NULL; | |
1010 g_free(s); | |
1011 break; | |
1012 } | |
7295 | 1013 } |
1014 | |
1015 static void | |
7751 | 1016 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1017 { |
11581 | 1018 GaimGtkWindow *gtkwin = data; |
1019 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1020 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1021 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1022 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1023 GTK_ICON_SIZE_DIALOG); |
7929 | 1024 GtkWidget *label; |
7295 | 1025 struct _search *s; |
1026 | |
7798 | 1027 if (gtkconv->dialogs.search) { |
1028 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1029 return; |
7798 | 1030 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1031 |
7295 | 1032 s = g_malloc(sizeof(struct _search)); |
1033 s->gtkconv = gtkconv; | |
7929 | 1034 |
1035 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1036 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1037 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1038 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1039 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1040 GTK_RESPONSE_OK); |
7929 | 1041 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1042 G_CALLBACK(do_search_cb), s); | |
1043 | |
11243 | 1044 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1045 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1046 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1047 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
|
1048 gtk_container_set_border_width( |
11243 | 1049 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1050 | |
1051 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1052 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1053 hbox); |
7929 | 1054 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1055 | |
1056 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1057 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1058 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1059 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1060 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1061 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1062 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1063 | |
1064 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1065 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1066 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1067 g_signal_connect(G_OBJECT(s->entry), "changed", |
1068 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1069 gtkconv->dialogs.search); | |
1070 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
|
1071 |
7295 | 1072 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1073 gtk_widget_grab_focus(s->entry); |
7295 | 1074 } |
1075 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1076 static void |
9468 | 1077 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1078 { | |
11581 | 1079 GaimGtkWindow *win = data; |
1080 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1081 |
11338 | 1082 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1083 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1084 } | |
1085 | |
1086 } | |
1087 | |
1088 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1089 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1090 { |
11581 | 1091 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1092 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1093 |
11581 | 1094 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
|
1095 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1096 gaim_gtkpounce_dialog_show(gaim_conversation_get_account(conv), |
11581 | 1097 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1098 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1099 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1100 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1101 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1102 { |
11581 | 1103 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1104 GaimGtkConversation *gtkconv; |
8756 | 1105 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1106 |
11581 | 1107 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1108 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1109 | |
1110 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1111 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1112 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1113 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1114 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1115 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1116 { |
11581 | 1117 GaimGtkWindow *win = data; |
8756 | 1118 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1119 GaimGtkConversation *gtkconv; |
8756 | 1120 GtkIMHtmlToolbar *toolbar; |
1121 | |
11581 | 1122 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1123 conv = gtkconv->active_conv; | |
8756 | 1124 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1125 | |
1126 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1127 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1128 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1129 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1130 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1131 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1132 { |
11581 | 1133 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1134 GaimConversation *conv; |
7879 | 1135 GaimAccount *account; |
1136 const char *name; | |
1137 | |
11581 | 1138 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1139 account = gaim_conversation_get_account(conv); |
1140 name = gaim_conversation_get_name(conv); | |
1141 | |
11338 | 1142 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1143 GaimBuddy *b; |
1144 | |
1145 b = gaim_find_buddy(account, name); | |
1146 if (b != NULL) | |
9730 | 1147 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1148 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1149 GaimChat *c; |
1150 | |
1151 c = gaim_blist_find_chat(account, name); | |
1152 if (c != NULL) | |
9730 | 1153 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1154 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1155 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1156 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1157 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1159 { |
11581 | 1160 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1161 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1162 |
11581 | 1163 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1164 |
10810 | 1165 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1166 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1167 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1168 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1169 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1170 { |
11581 | 1171 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1172 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1173 |
11581 | 1174 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1175 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1176 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1177 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1178 |
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_block_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; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1184 |
11581 | 1185 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1186 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1187 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1188 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1189 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1190 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1191 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1192 { |
11581 | 1193 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1194 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1195 |
11581 | 1196 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1197 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1198 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1199 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1200 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1201 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1202 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1203 { |
11581 | 1204 GaimGtkWindow *win = data; |
1205 | |
1206 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
|
1207 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1208 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1209 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1210 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 { |
11581 | 1212 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1213 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1214 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 |
11581 | 1216 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1218 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1219 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1220 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1221 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
|
1222 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1223 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1224 return; |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1225 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1226 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1227 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1228 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1229 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1230 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1231 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1232 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1233 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1234 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1235 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1236 } |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1237 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1238 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1239 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1240 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1241 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1242 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1243 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1244 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1245 /* 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
|
1246 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1247 } |
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 |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1251 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1252 { |
11581 | 1253 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1254 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1255 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1256 |
11581 | 1257 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1258 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1259 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1260 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1261 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1262 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1263 |
10377 | 1264 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1265 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
|
1266 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1267 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1268 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1269 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1270 { |
11581 | 1271 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1272 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1273 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1274 |
11581 | 1275 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1276 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1277 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1278 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1279 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1280 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1281 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1282 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1283 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1284 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1285 |
7961 | 1286 static void |
9188 | 1287 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1288 { | |
11581 | 1289 GaimGtkWindow *win = data; |
9188 | 1290 GaimConversation *conv; |
1291 GaimGtkConversation *gtkconv; | |
1292 | |
11581 | 1293 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1294 |
1295 if (!conv) | |
1296 return; | |
1297 | |
1298 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1299 | |
1300 gtkconv->show_timestamps = | |
1301 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
1302 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
1303 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); | |
1304 } | |
1305 | |
1306 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1307 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1309 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1310 GaimAccount *account; |
1311 GaimConnection *gc; | |
7961 | 1312 GaimPluginProtocolInfo *prpl_info = NULL; |
1313 char *real_who; | |
1314 | |
1315 account = gaim_conversation_get_account(conv); | |
10431 | 1316 g_return_if_fail(account != NULL); |
1317 | |
1318 gc = gaim_account_get_connection(account); | |
1319 g_return_if_fail(gc != NULL); | |
1320 | |
1321 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1322 | |
1323 if (prpl_info && prpl_info->get_cb_real_name) | |
1324 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1325 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1326 else | |
1327 real_who = g_strdup(who); | |
1328 | |
1329 if(!real_who) | |
1330 return; | |
1331 | |
10431 | 1332 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1333 |
1334 g_free(real_who); | |
1335 } | |
1336 | |
1337 static void | |
10810 | 1338 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1339 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1340 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1341 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1342 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1343 GtkTreeSelection *sel; |
9554 | 1344 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1345 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1346 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1347 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1348 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1349 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1350 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1351 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1352 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
|
1353 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1354 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1355 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1356 chat_do_im(gtkconv, name); |
9554 | 1357 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1358 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1359 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1360 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1361 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1362 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1363 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1364 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1365 GaimConvChat *chat; |
11869 | 1366 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1367 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1368 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1369 GtkTreeSelection *sel; |
10504 | 1370 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1371 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1372 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1373 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1374 gtkchat = gtkconv->u.chat; |
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 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1377 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1378 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1379 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1380 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1381 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1382 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1383 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1384 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1385 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1386 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1387 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1388 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1389 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1390 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1391 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1392 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1393 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1394 |
11869 | 1395 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1396 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1397 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1398 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1399 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1401 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1402 { |
1403 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1404 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1405 chat_do_im(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1406 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1407 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1408 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1409 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1410 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1411 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1412 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1413 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1414 | |
1415 serv_send_file(gc, who, NULL); | |
1416 } | |
1417 | |
1418 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1419 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1420 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1421 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1422 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1423 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1424 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1425 chat_do_info(gtkconv, who); |
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_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1430 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1431 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1432 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1433 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1434 char *who; |
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 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1437 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1438 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1439 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1440 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1441 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1442 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1443 * 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
|
1444 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1445 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1446 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1447 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1448 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1449 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1450 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1451 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1452 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1453 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1454 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1455 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1456 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1457 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1458 GaimAccount *account; |
6695 | 1459 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1460 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1461 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1462 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1463 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1464 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1465 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1466 if (b != NULL) |
9730 | 1467 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1468 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1469 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
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 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
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 |
8143 | 1474 static GtkWidget * |
10504 | 1475 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1476 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1477 { | |
1478 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1479 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1480 gboolean is_me = FALSE; |
8143 | 1481 GtkWidget *button; |
1482 | |
1483 /* | |
1484 * If a menu already exists, destroy it before creating a new one, | |
1485 * thus freeing-up the memory it occupied. | |
1486 */ | |
1487 if (menu) | |
1488 gtk_widget_destroy(menu); | |
1489 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1490 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1491 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1492 |
8143 | 1493 menu = gtk_menu_new(); |
1494 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1495 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1496 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1497 G_CALLBACK(menu_chat_im_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1498 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
|
1499 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1500 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1501 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1502 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1503 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1504 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1505 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
|
1506 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1507 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1508 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
|
1509 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
|
1510 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1511 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1512 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1513 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1514 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1515 } |
9498 | 1516 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1517 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1518 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
|
1519 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1520 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1521 } |
1522 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1523 if (prpl_info->get_cb_away) { |
10221 | 1524 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
|
1525 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1526 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1527 } |
1528 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1529 if (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1530 if (gaim_find_buddy(gc->account, who)) |
10221 | 1531 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
|
1532 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1533 else |
10221 | 1534 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
|
1535 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1536 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1537 } |
1538 | |
1539 return menu; | |
1540 } | |
1541 | |
1542 | |
1543 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1544 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1545 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1546 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1547 GaimPluginProtocolInfo *prpl_info = NULL; |
1548 GaimGtkChatPane *gtkchat; | |
1549 GaimConnection *gc; | |
1550 GaimAccount *account; | |
1551 GtkTreeSelection *sel; | |
1552 GtkTreeIter iter; | |
1553 GtkTreeModel *model; | |
1554 GtkWidget *menu; | |
1555 gchar *who; | |
1556 | |
1557 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1558 gtkchat = gtkconv->u.chat; | |
1559 account = gaim_conversation_get_account(conv); | |
1560 gc = account->gc; | |
1561 | |
1562 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1563 | |
1564 if (gc != NULL) | |
1565 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1566 | |
1567 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1568 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1569 return FALSE; | |
1570 | |
9498 | 1571 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1572 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1573 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1574 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1575 0, GDK_CURRENT_TIME); |
10504 | 1576 g_free(who); |
8143 | 1577 |
1578 return TRUE; | |
1579 } | |
1580 | |
1581 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1582 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1583 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1584 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1585 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1586 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1587 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1588 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1589 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1590 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1591 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1592 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1593 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1594 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1595 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1596 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1597 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1598 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1599 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1600 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1601 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1602 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1603 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1604 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
|
1605 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1606 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1607 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1608 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1609 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1610 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1611 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1612 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1613 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1614 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1615 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1616 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1617 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
|
1618 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1619 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1620 chat_do_im(gtkconv, who); |
7398 | 1621 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1622 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1623 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1624 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1625 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1626 |
10504 | 1627 g_free(who); |
1628 gtk_tree_path_free(path); | |
1629 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1630 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1631 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1632 |
8133 | 1633 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1634 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1635 { |
10827 | 1636 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1637 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1638 int index, i, total, found = 0; |
8133 | 1639 |
11581 | 1640 win = gtkconv->win; |
1641 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1642 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1643 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1644 /* First check the tabs after (forward) or before (!forward) this position. */ |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1645 for (i = forward ? index + 1 : index - 1; |
11581 | 1646 !found && (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1647 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1648 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1649 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1650 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1651 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1652 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1653 found = 1; |
8133 | 1654 } |
11252 | 1655 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1656 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1657 /* Now check from the beginning up to (forward) or end back to (!forward) this position. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1658 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1659 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1660 (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1661 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1662 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1663 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1664 found = 1; |
8133 | 1665 } |
10827 | 1666 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1667 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1668 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1669 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1670 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1671 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1672 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1673 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1674 } |
11581 | 1675 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1676 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1677 } |
8133 | 1678 } |
1679 | |
10827 | 1680 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1681 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1682 } |
1683 | |
4359 | 1684 static gboolean |
8105 | 1685 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1686 { |
11581 | 1687 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1688 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1689 GaimGtkConversation *gtkconv; |
8105 | 1690 int curconv; |
1691 | |
10810 | 1692 gtkconv = (GaimGtkConversation *)data; |
10849 | 1693 conv = gtkconv->active_conv; |
11581 | 1694 win = gtkconv->win; |
1695 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1696 |
8105 | 1697 /* If CTRL was held down... */ |
1698 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1699 switch (event->keyval) { |
1700 case GDK_Up: | |
1701 if (!conv->send_history) | |
1702 break; | |
1703 | |
1704 if (!conv->send_history->prev) { | |
1705 GtkTextIter start, end; | |
1706 | |
1707 if (conv->send_history->data) | |
1708 g_free(conv->send_history->data); | |
1709 | |
1710 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1711 &start); | |
1712 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1713 | |
1714 conv->send_history->data = | |
8506 | 1715 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1716 } |
8677 | 1717 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1718 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1719 GObject *object; |
8677 | 1720 GtkTextIter iter; |
1721 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1722 |
1723 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1724 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1725 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1726 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1727 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
|
1728 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1729 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1730 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1731 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1732 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
|
1733 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1734 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1735 |
8061 | 1736 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1737 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1738 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1739 0, NULL); |
8677 | 1740 /* this is mainly just a hack so the formatting at the |
1741 * cursor gets picked up. */ | |
1742 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1743 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1744 } |
1745 | |
8105 | 1746 return TRUE; |
4359 | 1747 break; |
1748 | |
1749 case GDK_Down: | |
1750 if (!conv->send_history) | |
1751 break; | |
1752 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1753 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1754 GObject *object; |
8677 | 1755 GtkTextIter iter; |
1756 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1757 |
4359 | 1758 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1759 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1760 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1761 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1762 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
|
1763 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1764 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1765 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1766 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1767 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
|
1768 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1769 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1770 |
8105 | 1771 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1772 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1773 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1774 0, NULL); |
8677 | 1775 /* this is mainly just a hack so the formatting at the |
1776 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1777 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1778 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1779 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1780 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1781 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1782 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1783 } |
4359 | 1784 } |
1785 | |
8105 | 1786 return TRUE; |
4359 | 1787 break; |
8105 | 1788 |
8108 | 1789 case GDK_Page_Down: |
8143 | 1790 case ']': |
11581 | 1791 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1792 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1793 else |
11581 | 1794 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1795 return TRUE; |
1796 break; | |
1797 | |
8108 | 1798 case GDK_Page_Up: |
8143 | 1799 case '[': |
11581 | 1800 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1801 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1802 else |
11581 | 1803 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1804 return TRUE; |
1805 break; | |
1806 | |
8108 | 1807 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1808 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1809 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1810 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1811 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1812 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1813 } |
8108 | 1814 |
1815 return TRUE; | |
1816 break; | |
1817 | |
11252 | 1818 case GDK_comma: |
11581 | 1819 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1820 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1821 curconv - 1); |
1822 break; | |
1823 | |
1824 case GDK_period: | |
11581 | 1825 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1826 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1827 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1828 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1829 #else |
1830 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1831 #endif | |
11252 | 1832 break; |
1833 | |
8105 | 1834 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1835 } |
8758 | 1836 |
8105 | 1837 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1838 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1839 { |
10864 | 1840 if (event->keyval > '0' && event->keyval <= '9') |
1841 { | |
8105 | 1842 int switchto = event->keyval - '1'; |
11581 | 1843 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1844 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1845 |
1846 return TRUE; | |
1847 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1848 } |
8758 | 1849 |
8105 | 1850 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1851 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1852 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1853 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1854 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1855 case GDK_Tab: |
9605 | 1856 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1857 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1858 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1859 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1860 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1861 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1862 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1863 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1864 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1865 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1866 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1867 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1868 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1869 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1870 } |
4359 | 1871 return FALSE; |
1872 } | |
1873 | |
1874 /* | |
1875 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1876 * 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
|
1877 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1878 * 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
|
1879 * going all the way down to the notebook. I suspect a bug in |
4359 | 1880 * GtkTextView, but I'm not ready to point any fingers yet. |
1881 */ | |
1882 static gboolean | |
1883 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1884 { | |
1885 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1886 /* Right single click */ | |
1887 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1888 | |
1889 return TRUE; | |
1890 } | |
1891 | |
1892 return FALSE; | |
1893 } | |
1894 | |
8173 | 1895 /* |
1896 * If someone tries to type into the conversation backlog of a | |
1897 * conversation window then we yank focus from the conversation backlog | |
1898 * and give it to the text entry box so that people can type | |
1899 * all the live long day and it will get entered into the entry box. | |
1900 */ | |
6057 | 1901 static gboolean |
8105 | 1902 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1903 { |
1904 GaimGtkConversation *gtkconv = data; | |
1905 | |
8237 | 1906 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1907 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1908 (event->keyval == GDK_F10) || |
1909 (event->keyval == GDK_Shift_L) || | |
1910 (event->keyval == GDK_Shift_R) || | |
1911 (event->keyval == GDK_Escape) || | |
8177 | 1912 (event->keyval == GDK_Up) || |
1913 (event->keyval == GDK_Down) || | |
1914 (event->keyval == GDK_Left) || | |
8191 | 1915 (event->keyval == GDK_Right) || |
1916 (event->keyval == GDK_Home) || | |
9297 | 1917 (event->keyval == GDK_End) || |
1918 (event->keyval == GDK_Tab) || | |
1919 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1920 return FALSE; |
1921 | |
1922 if (event->type == GDK_KEY_RELEASE) | |
1923 gtk_widget_grab_focus(gtkconv->entry); | |
1924 | |
1925 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1926 | |
1927 return TRUE; | |
6057 | 1928 } |
1929 | |
4359 | 1930 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1931 gaim_gtkconv_set_active_conversation(GaimConversation *conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1932 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1933 GaimGtkConversation *gtkconv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1934 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1935 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1936 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1937 gtkconv = GAIM_GTK_CONVERSATION(conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1938 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1939 if (gtkconv->active_conv == conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1940 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1941 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1942 gaim_conversation_close_logs(gtkconv->active_conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1943 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1944 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1945 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1946 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1947 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging))); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1948 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1949 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
1950 void |
11604 | 1951 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
1952 { | |
1953 GaimGtkConversation *gtkconv; | |
1954 | |
1955 g_return_if_fail(conv != NULL); | |
1956 | |
1957 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1958 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1959 gaim_gtkconv_set_active_conversation(conv); |
11604 | 1960 |
1961 gray_stuff_out(gtkconv); | |
1962 update_typing_icon(gtkconv); | |
1963 | |
1964 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
1965 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
1966 | |
11671
4ebd27e664c4
[gaim-migrate @ 13957]
Luke Schierer <lschiere@pidgin.im>
parents:
11669
diff
changeset
|
1967 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT); |
11604 | 1968 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
1969 gaim_account_get_protocol_name(conv->account)); | |
1970 } | |
1971 | |
1972 static void | |
4673 | 1973 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1974 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
1975 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 1976 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1977 GaimConversation *conv; |
4359 | 1978 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1979 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1980 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1981 |
11594 | 1982 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 1983 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 1984 } |
1985 | |
1986 static void | |
1987 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
1988 gchar *new_text, gint new_text_length, gpointer user_data) | |
1989 { | |
10810 | 1990 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
1991 GaimConversation *conv; | |
1992 | |
1993 g_return_if_fail(gtkconv != NULL); | |
11508 | 1994 |
10810 | 1995 conv = gtkconv->active_conv; |
4359 | 1996 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
1997 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 1998 return; |
1999 | |
10810 | 2000 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2001 gtk_text_iter_is_end(position))); | |
4359 | 2002 } |
2003 | |
2004 static void | |
2005 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2006 GtkTextIter *end_pos, gpointer user_data) | |
2007 { | |
10810 | 2008 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2009 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2010 GaimConvIm *im; |
4359 | 2011 |
10810 | 2012 g_return_if_fail(gtkconv != NULL); |
11508 | 2013 |
10810 | 2014 conv = gtkconv->active_conv; |
4359 | 2015 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2016 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2017 return; |
2018 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2019 im = GAIM_CONV_IM(conv); |
4359 | 2020 |
2021 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2022 | |
2023 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2024 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2025 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2026 |
2027 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2028 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2029 GAIM_NOT_TYPING); |
4359 | 2030 } |
2031 else { | |
2032 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2033 got_typing_keypress(gtkconv, FALSE); |
4359 | 2034 } |
2035 } | |
2036 | |
8189 | 2037 /************************************************************************** |
2038 * A bunch of buddy icon functions | |
2039 **************************************************************************/ | |
11581 | 2040 GdkPixbuf * |
2041 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2042 { |
10116 | 2043 GaimAccount *account = NULL; |
2044 const char *name = NULL; | |
7143 | 2045 GdkPixbuf *status = NULL; |
2046 | |
10116 | 2047 g_return_val_if_fail(conv != NULL, NULL); |
2048 | |
2049 account = gaim_conversation_get_account(conv); | |
2050 name = gaim_conversation_get_name(conv); | |
2051 | |
2052 g_return_val_if_fail(account != NULL, NULL); | |
2053 g_return_val_if_fail(name != NULL, NULL); | |
2054 | |
11338 | 2055 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2056 GaimBuddy *b = gaim_find_buddy(account, name); |
2057 if (b != NULL) { | |
2058 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2059 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2060 } |
2061 } | |
2062 | |
2063 if (!status) { | |
2064 GdkPixbuf *pixbuf; | |
10884 | 2065 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2066 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2067 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2068 { |
7143 | 2069 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2070 GDK_INTERP_BILINEAR); | |
2071 g_object_unref(pixbuf); | |
2072 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2073 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2074 status = pixbuf; |
7143 | 2075 } |
2076 return status; | |
2077 } | |
2078 | |
8189 | 2079 static void |
2080 update_tab_icon(GaimConversation *conv) | |
2081 { | |
2082 GaimGtkConversation *gtkconv; | |
11581 | 2083 GaimGtkWindow *win; |
8189 | 2084 GaimAccount *account; |
2085 const char *name; | |
2086 GdkPixbuf *status = NULL; | |
2087 | |
10116 | 2088 g_return_if_fail(conv != NULL); |
2089 | |
8189 | 2090 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2091 win = gtkconv->win; |
8189 | 2092 name = gaim_conversation_get_name(conv); |
2093 account = gaim_conversation_get_account(conv); | |
2094 | |
11581 | 2095 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2096 |
10116 | 2097 g_return_if_fail(status != NULL); |
2098 | |
8189 | 2099 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2100 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2101 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2102 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2103 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2104 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2105 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2106 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2107 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2108 { |
11581 | 2109 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2110 | |
2111 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2112 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2113 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2114 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2115 } |
8189 | 2116 } |
2117 | |
2118 static gboolean | |
2119 redraw_icon(gpointer data) | |
2120 { | |
10810 | 2121 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2122 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2123 GaimAccount *account; |
2124 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2125 |
2126 GdkPixbuf *buf; | |
2127 GdkPixbuf *scale; | |
2128 GdkPixmap *pm; | |
2129 GdkBitmap *bm; | |
2130 gint delay; | |
9318 | 2131 int scale_width, scale_height; |
8189 | 2132 |
2133 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2134 account = gaim_conversation_get_account(conv); |
2135 if(account && account->gc) | |
2136 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2137 |
2138 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2139 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2140 | |
10483 | 2141 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2142 NULL, &scale_width, &scale_height); |
2143 | |
2144 /* this code is ugly, and scares me */ | |
8189 | 2145 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2146 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2147 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2148 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2149 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2150 GDK_INTERP_BILINEAR); |
8189 | 2151 |
2152 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2153 g_object_unref(G_OBJECT(scale)); | |
2154 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2155 g_object_unref(G_OBJECT(pm)); | |
2156 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2157 | |
2158 if (bm) | |
2159 g_object_unref(G_OBJECT(bm)); | |
2160 | |
9131 | 2161 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2162 |
2163 if (delay < 100) | |
9131 | 2164 delay = 100; |
2165 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2166 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2167 |
2168 return FALSE; | |
2169 } | |
2170 | |
2171 static void | |
10810 | 2172 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2173 { |
2174 int delay; | |
2175 | |
8228 | 2176 if (gtkconv->u.im->anim == NULL) |
2177 return; | |
2178 | |
8202 | 2179 if (gtkconv->u.im->icon_timer != 0) |
2180 return; | |
2181 | |
8189 | 2182 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2183 return; | |
2184 | |
10639 | 2185 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2186 | |
2187 if (delay < 100) | |
2188 delay = 100; | |
2189 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2190 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2191 } |
2192 | |
2193 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2194 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2195 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2196 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2197 GaimGtkWindow *gtkwin; |
2198 | |
2199 g_return_if_fail(conv != NULL); | |
2200 | |
9887 | 2201 if (gtkconv->u.im->icon_container != NULL) |
2202 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2203 |
2204 if (gtkconv->u.im->anim != NULL) | |
2205 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2206 | |
2207 if (gtkconv->u.im->icon_timer != 0) | |
2208 g_source_remove(gtkconv->u.im->icon_timer); | |
2209 | |
2210 if (gtkconv->u.im->iter != NULL) | |
2211 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2212 | |
2213 gtkconv->u.im->icon_timer = 0; | |
2214 gtkconv->u.im->icon = NULL; | |
2215 gtkconv->u.im->anim = NULL; | |
2216 gtkconv->u.im->iter = NULL; | |
10456 | 2217 gtkconv->u.im->icon_container = NULL; |
9687 | 2218 gtkconv->u.im->show_icon = FALSE; |
10456 | 2219 |
11581 | 2220 gtkwin = gtkconv->win; |
10456 | 2221 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2222 } |
2223 | |
9497 | 2224 static void |
9504 | 2225 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2226 { |
10810 | 2227 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2228 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2229 FILE *fp; |
2230 GaimBuddyIcon *icon; | |
2231 const void *data; | |
2232 size_t len; | |
2233 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2234 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2235 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2236 return; |
2237 } | |
2238 | |
2239 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2240 data = gaim_buddy_icon_get_data(icon, &len); | |
2241 | |
2242 if ((len <= 0) || (data == NULL)) { | |
9504 | 2243 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2244 return; |
2245 } | |
2246 | |
2247 fwrite(data, 1, len, fp); | |
2248 fclose(fp); | |
2249 } | |
2250 | |
2251 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2252 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2253 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2254 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2255 const gchar *ext; |
9497 | 2256 gchar *buf; |
2257 | |
2258 g_return_if_fail(conv != NULL); | |
9504 | 2259 |
10953 | 2260 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2261 if (ext == NULL) | |
2262 ext = "icon"; | |
2263 | |
2264 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2265 |
2266 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2267 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2268 |
2269 g_free(buf); | |
2270 } | |
2271 | |
11581 | 2272 static void |
2273 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2274 { | |
2275 if (gtkconv->u.im->icon_timer != 0) | |
2276 g_source_remove(gtkconv->u.im->icon_timer); | |
2277 | |
2278 gtkconv->u.im->icon_timer = 0; | |
2279 } | |
2280 | |
2281 | |
2282 static void | |
2283 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2284 { | |
2285 gtkconv->u.im->animate = | |
2286 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2287 | |
2288 if (gtkconv->u.im->animate) | |
2289 start_anim(NULL, gtkconv); | |
2290 else | |
2291 stop_anim(NULL, gtkconv); | |
2292 } | |
2293 | |
8189 | 2294 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2295 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2296 { |
2297 static GtkWidget *menu = NULL; | |
2298 GtkWidget *button; | |
2299 | |
2300 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2301 return FALSE; | |
2302 | |
2303 /* | |
2304 * If a menu already exists, destroy it before creating a new one, | |
2305 * thus freeing-up the memory it occupied. | |
2306 */ | |
2307 if (menu != NULL) | |
2308 gtk_widget_destroy(menu); | |
2309 | |
2310 menu = gtk_menu_new(); | |
2311 | |
2312 if (gtkconv->u.im->anim && | |
2313 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2314 { | |
2315 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2316 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2317 gtkconv->u.im->icon_timer); |
2318 } | |
2319 | |
2320 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2321 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2322 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2323 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2324 gtk_widget_show(button); | |
2325 | |
2326 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
|
2327 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2328 0, 0, NULL); |
2329 | |
2330 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2331 | |
2332 return TRUE; | |
2333 } | |
10456 | 2334 |
2335 static void | |
2336 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2337 { | |
11581 | 2338 GaimGtkWindow *win = data; |
10456 | 2339 GaimConversation *conv; |
2340 GaimGtkConversation *gtkconv; | |
2341 gboolean active; | |
2342 | |
11581 | 2343 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2344 |
2345 if (!conv) | |
2346 return; | |
2347 | |
11338 | 2348 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2349 |
2350 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2351 | |
2352 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2353 gtkconv->u.im->show_icon = active; | |
2354 if (active) | |
2355 gaim_gtkconv_update_buddy_icon(conv); | |
2356 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2357 remove_icon(gtkconv); |
10456 | 2358 } |
2359 | |
8189 | 2360 /************************************************************************** |
2361 * End of the bunch of buddy icon functions | |
2362 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2363 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2364 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2365 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2366 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2367 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2368 if(gtkconv->win==hidden_convwin) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2369 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2370 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2371 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2372 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2373 gaim_gtkconv_set_active_conversation(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2374 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2375 gaim_gtk_conv_window_raise(gtkconv->win); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2376 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2377 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2378 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2379 GaimConversation * |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2380 gaim_gtk_conversations_get_first_unseen(GaimConversationType type, |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2381 GaimUnseenState min_state) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2382 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2383 GList *l; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2384 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2385 if(type==GAIM_CONV_TYPE_IM) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2386 l = gaim_get_ims(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2387 } else if(type==GAIM_CONV_TYPE_CHAT) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2388 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2389 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2390 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2391 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2392 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2393 for(; l!=NULL; l=l->next) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2394 GaimConversation *conv = (GaimConversation*)l->data; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2395 if(GAIM_IS_GTK_CONVERSATION(conv)) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2396 if(GAIM_GTK_CONVERSATION(conv)->unseen_state>=min_state) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2397 return conv; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2398 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2399 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2400 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2401 |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2402 return NULL; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2403 } |
8189 | 2404 |
11581 | 2405 GaimGtkWindow * |
2406 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2407 { | |
2408 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2409 return gtkconv->win; | |
2410 } | |
2411 | |
2412 static GtkItemFactoryEntry menu_items[] = | |
2413 { | |
2414 /* Conversation menu */ | |
2415 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, | |
2416 | |
2417 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2418 0, "<StockItem>", GAIM_STOCK_IM }, | |
2419 | |
2420 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
2421 | |
2422 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2423 "<StockItem>", GTK_STOCK_FIND }, | |
2424 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, NULL }, | |
2425 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, | |
2426 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
2427 { N_("/Conversation/Clear"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, | |
2428 | |
2429 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, | |
2430 | |
2431 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2432 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
2433 0, NULL }, | |
2434 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, | |
2435 "<StockItem>", GAIM_STOCK_INFO }, | |
2436 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2437 "<StockItem>", GAIM_STOCK_INVITE }, | |
2438 | |
2439 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
2440 | |
2441 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2442 "<StockItem>", GAIM_STOCK_EDIT }, | |
2443 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2444 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2445 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2446 "<StockItem>", GTK_STOCK_ADD }, | |
2447 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2448 "<StockItem>", GTK_STOCK_REMOVE }, | |
2449 | |
2450 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, | |
2451 | |
2452 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2453 "<StockItem>", GAIM_STOCK_LINK }, | |
2454 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2455 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2456 | |
2457 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, | |
2458 | |
2459 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2460 "<StockItem>", GTK_STOCK_CLOSE }, | |
2461 | |
2462 /* Options */ | |
2463 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, | |
2464 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2465 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
2466 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, | |
2467 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, | |
2468 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>" }, | |
2469 }; | |
2470 | |
2471 static const int menu_item_count = | |
2472 sizeof(menu_items) / sizeof(*menu_items); | |
2473 | |
2474 static char * | |
2475 item_factory_translate_func (const char *path, gpointer func_data) | |
2476 { | |
2477 return _((char *)path); | |
2478 } | |
2479 | |
2480 static GtkWidget * | |
2481 setup_menubar(GaimGtkWindow *win) | |
2482 { | |
2483 GtkAccelGroup *accel_group; | |
2484 | |
2485 accel_group = gtk_accel_group_new (); | |
2486 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2487 g_object_unref(accel_group); | |
2488 | |
2489 win->menu.item_factory = | |
2490 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2491 | |
2492 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2493 item_factory_translate_func, | |
2494 NULL, NULL); | |
2495 | |
2496 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2497 menu_items, win); | |
2498 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2499 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2500 | |
2501 | |
2502 win->menu.menubar = | |
2503 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2504 | |
2505 | |
2506 win->menu.view_log = | |
2507 gtk_item_factory_get_widget(win->menu.item_factory, | |
2508 N_("/Conversation/View Log")); | |
2509 | |
2510 /* --- */ | |
2511 | |
2512 win->menu.send_file = | |
2513 gtk_item_factory_get_widget(win->menu.item_factory, | |
2514 N_("/Conversation/Send File...")); | |
2515 | |
2516 win->menu.add_pounce = | |
2517 gtk_item_factory_get_widget(win->menu.item_factory, | |
2518 N_("/Conversation/Add Buddy Pounce...")); | |
2519 | |
2520 /* --- */ | |
2521 | |
2522 win->menu.get_info = | |
2523 gtk_item_factory_get_widget(win->menu.item_factory, | |
2524 N_("/Conversation/Get Info")); | |
2525 | |
2526 win->menu.invite = | |
2527 gtk_item_factory_get_widget(win->menu.item_factory, | |
2528 N_("/Conversation/Invite...")); | |
2529 | |
2530 /* --- */ | |
2531 | |
2532 win->menu.alias = | |
2533 gtk_item_factory_get_widget(win->menu.item_factory, | |
2534 N_("/Conversation/Alias...")); | |
2535 | |
2536 win->menu.block = | |
2537 gtk_item_factory_get_widget(win->menu.item_factory, | |
2538 N_("/Conversation/Block...")); | |
2539 | |
2540 win->menu.add = | |
2541 gtk_item_factory_get_widget(win->menu.item_factory, | |
2542 N_("/Conversation/Add...")); | |
2543 | |
2544 win->menu.remove = | |
2545 gtk_item_factory_get_widget(win->menu.item_factory, | |
2546 N_("/Conversation/Remove...")); | |
2547 | |
2548 /* --- */ | |
2549 | |
2550 win->menu.insert_link = | |
2551 gtk_item_factory_get_widget(win->menu.item_factory, | |
2552 N_("/Conversation/Insert Link...")); | |
2553 | |
2554 win->menu.insert_image = | |
2555 gtk_item_factory_get_widget(win->menu.item_factory, | |
2556 N_("/Conversation/Insert Image...")); | |
2557 | |
2558 /* --- */ | |
2559 | |
2560 win->menu.logging = | |
2561 gtk_item_factory_get_widget(win->menu.item_factory, | |
2562 N_("/Options/Enable Logging")); | |
2563 win->menu.sounds = | |
2564 gtk_item_factory_get_widget(win->menu.item_factory, | |
2565 N_("/Options/Enable Sounds")); | |
2566 win->menu.show_formatting_toolbar = | |
2567 gtk_item_factory_get_widget(win->menu.item_factory, | |
2568 N_("/Options/Show Formatting Toolbars")); | |
2569 win->menu.show_timestamps = | |
2570 gtk_item_factory_get_widget(win->menu.item_factory, | |
2571 N_("/Options/Show Timestamps")); | |
2572 win->menu.show_icon = | |
2573 gtk_item_factory_get_widget(win->menu.item_factory, | |
2574 N_("/Options/Show Buddy Icon")); | |
2575 | |
2576 | |
2577 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2578 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2579 win->menu.tray); | |
2580 gtk_widget_show(win->menu.tray); | |
2581 | |
2582 gtk_widget_show(win->menu.menubar); | |
2583 | |
2584 return win->menu.menubar; | |
2585 } | |
2586 | |
4359 | 2587 |
2588 /************************************************************************** | |
2589 * Utility functions | |
2590 **************************************************************************/ | |
2591 | |
2592 static void | |
10810 | 2593 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2594 { |
10810 | 2595 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2596 GaimConvIm *im; |
4685 | 2597 |
4359 | 2598 /* |
2599 * 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
|
2600 * send GAIM_TYPED any time soon. |
4359 | 2601 */ |
2602 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2603 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2604 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2605 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2606 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2607 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2608 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2609 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2610 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2611 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2612 |
2613 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2614 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2615 GAIM_TYPING); |
4359 | 2616 |
2617 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2618 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2619 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2620 gaim_conv_im_set_type_again(im, 0); |
4359 | 2621 } |
2622 } | |
2623 | |
4736 | 2624 static void |
10810 | 2625 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2626 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2627 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2628 GaimConvIm *im = NULL; |
10810 | 2629 GaimConversation *conv = gtkconv->active_conv; |
12008 | 2630 char *stock_id, *tooltip; |
11508 | 2631 |
11581 | 2632 gtkwin = gtkconv->win; |
4736 | 2633 |
12008 | 2634 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2635 im = GAIM_CONV_IM(conv); |
4736 | 2636 |
12008 | 2637 if (gtkwin->menu.typing_icon) { |
2638 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2639 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2640 |
12008 | 2641 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2642 return; | |
2643 | |
2644 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2645 stock_id = GAIM_STOCK_TYPING; | |
2646 tooltip = _("User is typing..."); | |
2647 } else { | |
2648 stock_id = GAIM_STOCK_TYPED; | |
2649 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2650 } |
12008 | 2651 |
2652 if (gtkwin->menu.typing_icon == NULL) | |
2653 { | |
2654 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
|
2655 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
|
2656 gtkwin->menu.typing_icon, |
12008 | 2657 tooltip); |
4736 | 2658 } |
12008 | 2659 else |
2660 { | |
2661 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2662 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2663 gtkwin->menu.typing_icon, | |
2664 tooltip); | |
2665 } | |
2666 | |
2667 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2668 } |
2669 | |
4685 | 2670 static gboolean |
11594 | 2671 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2672 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2673 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2674 GaimConversation *conv; |
4359 | 2675 GtkWidget *menu; |
2676 GList *child; | |
11594 | 2677 GaimBuddy *b; |
11581 | 2678 |
2679 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2680 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2681 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2682 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2683 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2684 account = gaim_conversation_get_account(conv); |
11581 | 2685 |
11594 | 2686 if (win->menu.send_to == NULL) |
4685 | 2687 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2688 |
11594 | 2689 if (!(b = gaim_find_buddy(account, conv->name))) |
2690 return FALSE; | |
2691 | |
2692 | |
2693 gtk_widget_show(win->menu.send_to); | |
4359 | 2694 |
2695 menu = gtk_menu_item_get_submenu( | |
11594 | 2696 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2697 |
2698 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2699 child != NULL; | |
2700 child = child->next) { | |
2701 | |
2702 GtkWidget *item = child->data; | |
11594 | 2703 GaimBuddy *item_buddy; |
2704 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2705 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2706 "gaim_buddy_name"); | |
2707 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2708 | |
2709 if (b == item_buddy) { | |
4359 | 2710 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2711 break; | |
2712 } | |
2713 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2714 |
4685 | 2715 return FALSE; |
4359 | 2716 } |
2717 | |
2718 static void | |
11594 | 2719 create_sendto_item(GtkWidget *menu, GtkSizeGroup *sg, GSList **group, GaimBuddy *bud) |
2720 { | |
2721 GaimAccount *account; | |
2722 GtkWidget *box; | |
2723 GtkWidget *label; | |
2724 GtkWidget *image; | |
2725 GtkWidget *menuitem; | |
11625 | 2726 GdkPixbuf *pixbuf; |
11616 | 2727 gchar *text; |
11594 | 2728 |
2729 account = bud->account; | |
2730 | |
2731 /* Create a pixmap for the protocol icon. */ | |
11625 | 2732 pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)bud, GAIM_STATUS_ICON_SMALL); |
11594 | 2733 /* Now convert it to GtkImage */ |
2734 if (pixbuf == NULL) | |
2735 image = gtk_image_new(); | |
2736 else | |
11625 | 2737 image = gtk_image_new_from_pixbuf(pixbuf); |
11594 | 2738 |
2739 gtk_size_group_add_widget(sg, image); | |
2740 | |
2741 g_object_unref(G_OBJECT(pixbuf)); | |
2742 | |
2743 /* Make our menu item */ | |
11616 | 2744 text = g_strdup_printf("%s (%s)", gaim_buddy_get_name(bud), gaim_account_get_username(bud->account)); |
2745 menuitem = gtk_radio_menu_item_new_with_label(*group, text); | |
2746 g_free(text); | |
11594 | 2747 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2748 | |
2749 /* Do some evil, see some evil, speak some evil. */ | |
2750 box = gtk_hbox_new(FALSE, 0); | |
2751 | |
2752 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
2753 g_object_ref(label); | |
2754 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
2755 | |
2756 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
2757 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
2758 | |
2759 g_object_unref(label); | |
2760 | |
2761 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
2762 | |
2763 gtk_widget_show(label); | |
2764 gtk_widget_show(image); | |
2765 gtk_widget_show(box); | |
2766 | |
2767 /* Set our data and callbacks. */ | |
2768 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
2769 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(gaim_buddy_get_name(bud)), g_free); | |
2770 | |
2771 g_signal_connect(G_OBJECT(menuitem), "activate", | |
2772 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2773 | |
2774 gtk_widget_show(menuitem); | |
2775 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2776 } | |
2777 | |
2778 static void | |
2779 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 2780 { |
4359 | 2781 GtkWidget *menu; |
2782 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2783 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 2784 GaimGtkConversation *gtkconv; |
2785 GSList *l, *buds; | |
2786 | |
2787 g_return_if_fail(win != NULL); | |
2788 | |
2789 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
2790 | |
11604 | 2791 g_return_if_fail(gtkconv != NULL); |
2792 | |
11594 | 2793 if (win->menu.send_to != NULL) |
2794 gtk_widget_destroy(win->menu.send_to); | |
2795 | |
4359 | 2796 |
2797 /* Build the Send As menu */ | |
11594 | 2798 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
2799 gtk_widget_show(win->menu.send_to); | |
4359 | 2800 |
2801 menu = gtk_menu_new(); | |
11581 | 2802 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 2803 win->menu.send_to, 2); |
2804 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 2805 |
2806 gtk_widget_show(menu); | |
2807 | |
11604 | 2808 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
2809 buds = gaim_find_buddies(gtkconv->active_conv->account, gtkconv->active_conv->name); | |
2810 for (l = buds; l != NULL; l = l->next) { | |
2811 GaimBuddy *b; | |
2812 GaimBlistNode *node; | |
2813 | |
2814 b = l->data; | |
2815 node = (GaimBlistNode *) gaim_buddy_get_contact(b); | |
2816 | |
2817 for (node = node->child; node != NULL; node = node->next) | |
2818 if (GAIM_BLIST_NODE_IS_BUDDY(node) && gaim_account_is_connected(((GaimBuddy *)node)->account)) | |
2819 create_sendto_item(menu, sg, &group, (GaimBuddy *) node); | |
2820 } | |
2821 | |
2822 g_slist_free(buds); | |
4359 | 2823 } |
2824 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2825 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2826 |
11594 | 2827 gtk_widget_show(win->menu.send_to); |
2828 if (!group) | |
2829 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
2830 update_send_to_selection(win); | |
4359 | 2831 } |
2832 | |
2833 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2834 generate_invite_user_names(GaimConnection *gc) |
4359 | 2835 { |
6695 | 2836 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 2837 static GList *tmp = NULL; |
2838 | |
2839 if (tmp) | |
2840 g_list_free(tmp); | |
2841 | |
2842 tmp = g_list_append(NULL, ""); | |
2843 | |
2844 if (gc != NULL) { | |
4785 | 2845 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2846 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2847 continue; | |
6695 | 2848 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
2849 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 2850 continue; |
6695 | 2851 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
2852 GaimBuddy *buddy; | |
2853 | |
2854 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2855 continue; | |
2856 | |
2857 buddy = (GaimBuddy *)bnode; | |
2858 | |
2859 if (buddy->account == gc->account && | |
2860 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 2861 tmp = g_list_insert_sorted(tmp, buddy->name, |
2862 (GCompareFunc)g_utf8_collate); | |
6695 | 2863 } |
4359 | 2864 } |
2865 } | |
2866 } | |
2867 | |
2868 return tmp; | |
2869 } | |
2870 | |
9498 | 2871 static GdkPixbuf * |
9554 | 2872 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 2873 { |
9554 | 2874 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 2875 char *filename; |
10274 | 2876 const char *image = NULL; |
9554 | 2877 |
2878 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 2879 image = "founder.png"; |
9554 | 2880 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 2881 image = "op.png"; |
9554 | 2882 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 2883 image = "halfop.png"; |
9554 | 2884 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 2885 image = "voice.png"; |
9554 | 2886 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 2887 image = "ignored.png"; |
2888 } else { | |
2889 return NULL; | |
9554 | 2890 } |
10274 | 2891 |
2892 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
2893 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
2894 g_free(filename); | |
2895 | |
2896 if (!pixbuf) | |
2897 return NULL; | |
2898 | |
2899 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
2900 g_object_unref(pixbuf); | |
2901 | |
2902 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
2903 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 2904 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
2905 g_free(filename); | |
10274 | 2906 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 2907 g_object_unref(pixbuf); |
10274 | 2908 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
2909 g_object_unref(scale2); | |
9498 | 2910 } |
2911 | |
10274 | 2912 return scale; |
9498 | 2913 } |
2914 | |
4359 | 2915 static void |
11869 | 2916 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 2917 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2918 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2919 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2920 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2921 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2922 GaimPluginProtocolInfo *prpl_info; |
4359 | 2923 GtkListStore *ls; |
9498 | 2924 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2925 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2926 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2927 gboolean is_buddy; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2928 GdkColor send_color; |
11508 | 2929 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2930 gdk_color_parse(SEND_COLOR, &send_color); |
4359 | 2931 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2932 chat = GAIM_CONV_CHAT(conv); |
4359 | 2933 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2934 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2935 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2936 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2937 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2938 return; |
4359 | 2939 |
2940 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
2941 | |
9554 | 2942 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 2943 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
2944 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
|
2945 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2946 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2947 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2948 |
4359 | 2949 gtk_list_store_append(ls, &iter); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2950 gtk_list_store_set(ls, &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2951 CHAT_USERS_ICON_COLUMN, pixbuf, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2952 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2953 CHAT_USERS_NAME_COLUMN, name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2954 CHAT_USERS_FLAGS_COLUMN, flags, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2955 CHAT_USERS_COLOR_COLUMN, is_me ? &send_color : get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2956 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2957 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2958 |
9554 | 2959 if (pixbuf) |
2960 g_object_unref(pixbuf); | |
4359 | 2961 } |
2962 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2963 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2964 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
|
2965 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2966 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2967 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2968 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2969 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2970 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2971 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2972 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2973 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2974 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2975 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2976 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2977 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2978 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2979 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2980 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2981 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2982 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2983 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2984 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2985 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2986 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2987 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2988 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2989 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2990 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2991 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2992 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2993 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2994 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2995 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2996 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2997 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2998 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
2999 |
9605 | 3000 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3001 tab_complete(GaimConversation *conv) |
4359 | 3002 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3003 GaimGtkConversation *gtkconv; |
4359 | 3004 GtkTextIter cursor, word_start, start_buffer; |
3005 int start; | |
3006 int most_matched = -1; | |
3007 char *entered, *partial = NULL; | |
3008 char *text; | |
8021 | 3009 char *nick_partial; |
9605 | 3010 const char *prefix; |
4359 | 3011 GList *matches = NULL; |
9605 | 3012 gboolean command = FALSE; |
4359 | 3013 |
3014 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3015 | |
3016 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3017 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3018 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3019 | |
3020 word_start = cursor; | |
3021 | |
3022 /* if there's nothing there just return */ | |
3023 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3024 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
|
3025 |
4359 | 3026 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3027 &cursor, FALSE); | |
3028 | |
3029 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3030 start = strlen(text) - 1; | |
3031 | |
8021 | 3032 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3033 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3034 start-=2; |
3035 } | |
4359 | 3036 |
3037 /* find the start of the word that we're tabbing */ | |
3038 while (start >= 0 && text[start] != ' ') { | |
3039 gtk_text_iter_backward_char(&word_start); | |
3040 start--; | |
3041 } | |
3042 | |
9605 | 3043 prefix = gaim_gtk_get_cmd_prefix(); |
3044 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3045 command = TRUE; | |
3046 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3047 } | |
3048 | |
4359 | 3049 g_free(text); |
3050 | |
3051 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3052 &cursor, FALSE); | |
3053 | |
8021 | 3054 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3055 g_free(entered); |
11338 | 3056 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3057 } |
3058 | |
8021 | 3059 nick_partial = g_malloc(strlen(entered)+1); |
3060 | |
9605 | 3061 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3062 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3063 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3064 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3065 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3066 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3067 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3068 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3069 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3070 g_list_free(list); |
11338 | 3071 } 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
|
3072 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3073 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3074 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
|
3075 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3076 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3077 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3078 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3079 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3080 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3081 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3082 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3083 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3084 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3085 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3086 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
|
3087 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3088 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3089 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3090 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3091 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3092 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3093 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3094 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3095 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3096 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3097 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3098 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3099 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3100 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3101 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3102 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3103 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3104 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3105 } |
9605 | 3106 } else { |
3107 g_free(nick_partial); | |
3108 g_free(entered); | |
3109 return FALSE; | |
3110 } | |
3111 | |
8021 | 3112 g_free(nick_partial); |
3113 | |
4359 | 3114 /* we're only here if we're doing new style */ |
3115 | |
3116 /* if there weren't any matches, return */ | |
3117 if (!matches) { | |
3118 /* if matches isn't set partials won't be either */ | |
3119 g_free(entered); | |
11338 | 3120 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3121 } |
3122 | |
3123 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3124 | |
3125 if (!matches->next) { | |
3126 /* there was only one match. fill it in. */ | |
3127 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3128 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3129 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3130 | |
3131 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3132 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3133 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3134 g_free(tmp); | |
3135 } | |
3136 else | |
3137 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3138 matches->data, -1); | |
3139 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3140 g_free(matches->data); |
4359 | 3141 matches = g_list_remove(matches, matches->data); |
3142 } | |
3143 else { | |
3144 /* | |
3145 * there were lots of matches, fill in as much as possible | |
3146 * and display all of them | |
3147 */ | |
3148 char *addthis = g_malloc0(1); | |
3149 | |
3150 while (matches) { | |
3151 char *tmp = addthis; | |
3152 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3153 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3154 g_free(matches->data); |
4359 | 3155 matches = g_list_remove(matches, matches->data); |
3156 } | |
3157 | |
6982 | 3158 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3159 time(NULL)); |
3160 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3161 g_free(addthis); | |
3162 } | |
3163 | |
3164 g_free(entered); | |
3165 g_free(partial); | |
9605 | 3166 |
3167 return TRUE; | |
4359 | 3168 } |
3169 | |
10810 | 3170 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3171 { |
3172 GaimPluginProtocolInfo *prpl_info = NULL; | |
3173 GaimConnection *gc; | |
10810 | 3174 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3175 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3176 char *new_topic; |
8858 | 3177 const char *current_topic; |
7971 | 3178 |
3179 gc = gaim_conversation_get_gc(conv); | |
3180 | |
3181 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3182 return; | |
3183 | |
3184 if(prpl_info->set_chat_topic == NULL) | |
3185 return; | |
3186 | |
3187 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3188 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3189 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3190 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3191 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3192 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3193 g_free(new_topic); |
7971 | 3194 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3195 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3196 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3197 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3198 |
8858 | 3199 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3200 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3201 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3202 g_free(new_topic); |
7971 | 3203 } |
3204 | |
9554 | 3205 static gint |
3206 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3207 { | |
3208 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3209 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3210 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3211 gint ret = 0; |
3212 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3213 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3214 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3215 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3216 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3217 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3218 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3219 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3220 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3221 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3222 -1); |
9554 | 3223 |
3224 if (user1 == NULL || user2 == NULL) { | |
3225 if (!(user1 == NULL && user2 == NULL)) | |
3226 ret = (user1 == NULL) ? -1: 1; | |
3227 } else if (f1 != f2) { | |
3228 /* sort more important users first */ | |
3229 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3230 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3231 ret = buddy1 ? -1 : 1; |
9554 | 3232 } else { |
10904 | 3233 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3234 } |
3235 | |
3236 g_free(user1); | |
3237 g_free(user2); | |
3238 | |
3239 return ret; | |
3240 } | |
3241 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3242 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3243 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
|
3244 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3245 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3246 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3247 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3248 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3249 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3250 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3251 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3252 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3253 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3254 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3255 /* 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
|
3256 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
|
3257 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3258 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
|
3259 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3260 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3261 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3262 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3263 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3264 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3265 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3266 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
|
3267 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3268 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3269 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3270 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3271 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3272 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3273 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3274 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3275 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3276 alias = gaim_buddy_get_contact_alias(buddy2); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3277 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3278 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3279 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3280 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, alias), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3281 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3282 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3283 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3284 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3285 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3286 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3287 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3288 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3289 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3290 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3291 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3292 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3293 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3294 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3295 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3296 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
|
3297 { |
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; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3300 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3301 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3302 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3303 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3304 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3305 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3306 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3307 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3308 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3309 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3310 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3311 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3312 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3313 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3314 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3315 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3316 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3317 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3318 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3319 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3320 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3321 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3322 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3323 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3324 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3325 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
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 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3328 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3329 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3330 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3331 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3332 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3333 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3334 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3335 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3336 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3337 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3338 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3339 /* 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
|
3340 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3341 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3342 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3343 /* 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
|
3344 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
|
3345 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3346 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
|
3347 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3348 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3349 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3350 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3351 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3352 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3353 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3354 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
|
3355 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3356 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3357 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
|
3358 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3359 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3360 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3361 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3362 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3363 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3364 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3365 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3366 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3367 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3368 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3369 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3370 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3371 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3372 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3373 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3374 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3375 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3376 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3377 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3378 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3379 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3380 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3381 /* 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
|
3382 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3383 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3384 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3385 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3386 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3387 |
4359 | 3388 static GtkWidget * |
10810 | 3389 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3390 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3391 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3392 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3393 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3394 GaimConnection *gc; |
4359 | 3395 GtkWidget *vpaned, *hpaned; |
10175 | 3396 GtkWidget *vbox, *hbox, *frame; |
4359 | 3397 GtkWidget *lbox, *bbox; |
3398 GtkWidget *label; | |
3399 GtkWidget *list; | |
3400 GtkWidget *button; | |
7949 | 3401 GtkWidget *sw; |
4359 | 3402 GtkListStore *ls; |
3403 GtkCellRenderer *rend; | |
3404 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3405 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3406 GList *focus_chain = NULL; |
4359 | 3407 |
3408 gtkchat = gtkconv->u.chat; | |
3409 gc = gaim_conversation_get_gc(conv); | |
3410 | |
3411 /* Setup the outer pane. */ | |
3412 vpaned = gtk_vpaned_new(); | |
3413 gtk_widget_show(vpaned); | |
3414 | |
3415 /* Setup the top part of the pane. */ | |
11243 | 3416 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3417 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3418 gtk_widget_show(vbox); |
3419 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3420 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3421 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3422 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3423 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3424 { |
11243 | 3425 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3426 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3427 gtk_widget_show(hbox); |
3428 | |
3429 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3430 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3431 gtk_widget_show(label); |
3432 | |
3433 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3434 |
7971 | 3435 if(prpl_info->set_chat_topic == NULL) { |
3436 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3437 } else { | |
3438 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3439 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3440 } |
3441 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3442 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3443 gtk_widget_show(gtkchat->topic_text); |
3444 } | |
3445 | |
3446 /* Setup the horizontal pane. */ | |
3447 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3448 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3449 gtk_widget_show(hpaned); |
3450 | |
10175 | 3451 /* Setup gtkihmtml. */ |
3452 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3453 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3454 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3455 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3456 gtk_widget_show(frame); | |
3457 | |
3458 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3459 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3460 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3461 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3462 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3463 |
4359 | 3464 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3465 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3466 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3467 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3468 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3469 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3470 |
3471 /* Build the right pane. */ | |
11243 | 3472 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3473 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3474 gtk_widget_show(lbox); |
3475 | |
3476 /* Setup the label telling how many people are in the room. */ | |
3477 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3478 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3479 gtk_widget_show(gtkchat->count); | |
3480 | |
3481 /* Setup the list of users. */ | |
7949 | 3482 sw = gtk_scrolled_window_new(NULL, NULL); |
3483 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3484 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3485 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3486 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3487 gtk_widget_show(sw); | |
4359 | 3488 |
9554 | 3489 ls = gtk_list_store_new(CHAT_USERS_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3490 G_TYPE_STRING, G_TYPE_INT, GDK_TYPE_COLOR, G_TYPE_BOOLEAN); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3491 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3492 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3493 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3494 GTK_SORT_ASCENDING); |
3495 | |
3496 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3497 | |
9498 | 3498 rend = gtk_cell_renderer_pixbuf_new(); |
3499 | |
4359 | 3500 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3501 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3502 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3503 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3504 |
3505 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3506 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3507 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3508 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3509 |
9498 | 3510 rend = gtk_cell_renderer_text_new(); |
3511 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3512 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3513 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3514 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3515 NULL); |
4359 | 3516 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3517 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3518 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3519 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3520 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3521 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3522 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3523 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3524 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3525 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3526 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3527 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
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 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3530 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3531 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3532 #endif |
4359 | 3533 |
3534 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3535 | |
3536 gtk_widget_set_size_request(list, 150, -1); | |
3537 | |
3538 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3539 gtk_widget_show(list); | |
3540 | |
3541 gtkchat->list = list; | |
3542 | |
7949 | 3543 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3544 |
3545 /* Setup the user list toolbar. */ | |
11243 | 3546 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3547 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3548 gtk_widget_show(bbox); | |
3549 | |
3550 /* IM */ | |
10221 | 3551 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3552 GAIM_BUTTON_VERTICAL); |
10500 | 3553 gtkchat->userlist_im = button; |
4359 | 3554 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3555 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3556 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3557 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3558 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3559 |
3560 gtk_widget_show(button); | |
3561 | |
3562 /* Ignore */ | |
3563 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3564 GAIM_BUTTON_VERTICAL); | |
10500 | 3565 gtkchat->userlist_ignore = button; |
4359 | 3566 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3567 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3568 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3569 _("Ignore the user"), NULL); |
4359 | 3570 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3571 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3572 gtk_widget_show(button); |
3573 | |
3574 /* Info */ | |
3575 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3576 GAIM_BUTTON_VERTICAL); | |
10500 | 3577 gtkchat->userlist_info = button; |
4359 | 3578 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3579 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3580 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3581 _("Get the user's information"), NULL); |
4359 | 3582 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3583 G_CALLBACK(info_cb), gtkconv); |
4359 | 3584 |
3585 gtk_widget_show(button); | |
3586 | |
10175 | 3587 /* Setup the bottom half of the conversation window */ |
11243 | 3588 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3589 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3590 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3591 |
11243 | 3592 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3593 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3594 gtk_widget_show(gtkconv->lower_hbox); | |
3595 | |
11243 | 3596 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3597 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3598 gtk_widget_show(vbox); | |
3599 | |
10175 | 3600 /* Setup the toolbar, entry widget and all signals */ |
3601 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3602 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3603 gtk_widget_show(frame); |
3604 | |
9005 | 3605 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3606 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3607 gaim_account_get_protocol_name(conv->account)); |
10175 | 3608 gtk_widget_set_size_request(gtkconv->entry, -1, |
3609 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3610 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3611 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3612 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3613 |
3614 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3615 G_CALLBACK(entry_key_press_cb), gtkconv); |
10115 | 3616 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
10810 | 3617 G_CALLBACK(send_cb), gtkconv); |
4359 | 3618 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3619 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3620 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3621 G_CALLBACK(size_allocate_cb), gtkconv); |
3622 | |
3623 default_formatize(gtkconv); | |
4359 | 3624 |
9080 | 3625 /* |
3626 * Focus for chat windows should be as follows: | |
3627 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3628 * user list buttons -> entry -> buttons at bottom | |
3629 */ | |
9332 | 3630 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3631 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3632 | |
4359 | 3633 return vpaned; |
3634 } | |
3635 | |
3636 static GtkWidget * | |
10810 | 3637 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 3638 { |
10810 | 3639 GaimConversation *conv = gtkconv->active_conv; |
10175 | 3640 GtkWidget *frame; |
4359 | 3641 GtkWidget *paned; |
10175 | 3642 GtkWidget *vbox; |
3643 GtkWidget *vbox2; | |
9080 | 3644 GList *focus_chain = NULL; |
4359 | 3645 |
10175 | 3646 /* Setup the outer pane */ |
4359 | 3647 paned = gtk_vpaned_new(); |
3648 gtk_widget_show(paned); | |
3649 | |
10175 | 3650 /* Setup the top part of the pane */ |
11243 | 3651 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3652 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3653 gtk_widget_show(vbox); |
3654 | |
10175 | 3655 /* Setup the gtkimhtml widget */ |
3656 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3657 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3658 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 3659 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
3660 gtk_widget_show(frame); | |
3661 | |
3662 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3663 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3664 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 3665 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3666 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3667 |
3668 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 3669 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 3670 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 3671 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3672 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 3673 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 3674 |
10175 | 3675 /* Setup the bottom half of the conversation window */ |
11243 | 3676 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3677 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3678 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3679 |
11243 | 3680 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3681 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3682 gtk_widget_show(gtkconv->lower_hbox); | |
3683 | |
11243 | 3684 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3685 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
3686 gtk_widget_show(vbox2); | |
8821 | 3687 |
10175 | 3688 /* Setup the toolbar, entry widget and all signals */ |
3689 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3690 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 3691 gtk_widget_show(frame); |
3692 | |
9005 | 3693 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3694 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3695 gaim_account_get_protocol_name(conv->account)); |
10175 | 3696 gtk_widget_set_size_request(gtkconv->entry, -1, |
3697 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3698 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3699 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3700 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
|
3701 |
4359 | 3702 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 3703 G_CALLBACK(entry_key_press_cb), gtkconv); |
3704 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), gtkconv); | |
4359 | 3705 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3706 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3707 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3708 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3709 |
3710 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 3711 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 3712 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 3713 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 3714 |
8481 | 3715 /* had to move this after the imtoolbar is attached so that the |
3716 * signals get fired to toggle the buttons on the toolbar as well. | |
3717 */ | |
10810 | 3718 default_formatize(gtkconv); |
4359 | 3719 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3720 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3721 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3722 |
8758 | 3723 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 3724 gtkconv->u.im->show_icon = TRUE; |
4359 | 3725 |
9080 | 3726 /* |
3727 * Focus for IM windows should be as follows: | |
10356 | 3728 * Tab title -> conversation scrollback -> entry |
9080 | 3729 */ |
9332 | 3730 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3731 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 3732 |
4359 | 3733 return paned; |
3734 } | |
3735 | |
3736 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3737 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 3738 GtkSelectionData *sd, guint info, guint t, |
3739 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3740 { |
10810 | 3741 GaimConversation *conv = gtkconv->active_conv; |
11581 | 3742 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3743 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3744 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3745 { |
4781 | 3746 GaimBlistNode *n = NULL; |
6695 | 3747 GaimBuddy *b; |
11581 | 3748 GaimGtkConversation *gtkconv = NULL; |
9622 | 3749 |
11812 | 3750 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3751 |
6695 | 3752 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
3753 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
3754 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
3755 b = (GaimBuddy*)n; | |
3756 else | |
4781 | 3757 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3758 |
9622 | 3759 /* |
3760 * If we already have an open conversation with this buddy, then | |
3761 * just move the conv to this window. Otherwise, create a new | |
3762 * conv and add it to this window. | |
3763 */ | |
11338 | 3764 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 3765 if (c != NULL) { |
11581 | 3766 GaimGtkWindow *oldwin; |
3767 gtkconv = GAIM_GTK_CONVERSATION(c); | |
3768 oldwin = gtkconv->win; | |
9622 | 3769 if (oldwin != win) { |
11581 | 3770 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
3771 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 3772 } |
3773 } else { | |
11338 | 3774 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 3775 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3776 if (gtkconv->win != win) |
3777 { | |
3778 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3779 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3780 } | |
9622 | 3781 } |
3782 | |
3783 /* Make this conversation the active conversation */ | |
11581 | 3784 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3785 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3786 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 3787 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3788 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
|
3789 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3790 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3791 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3792 GaimAccount *account; |
11581 | 3793 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3794 |
11137 | 3795 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 3796 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3797 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3798 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3799 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3800 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3801 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3802 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3803 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3804 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3805 { |
11338 | 3806 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 3807 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3808 if (gtkconv->win != win) |
3809 { | |
3810 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3811 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3812 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3813 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3814 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3815 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3816 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3817 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3818 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3819 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3820 } |
9525 | 3821 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 3822 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 3823 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 3824 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 3825 } |
10145 | 3826 else |
3827 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3828 } |
4359 | 3829 |
3830 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3831 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3832 { |
10145 | 3833 GTK_IMHTML_DND_TARGETS, |
3834 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
3835 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3836 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3837 |
10810 | 3838 static GaimGtkConversation * |
3839 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
3840 { | |
3841 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
3842 GaimContact *c; | |
3843 GaimBlistNode *cn; | |
10935 | 3844 |
10810 | 3845 if (!bud) |
3846 return NULL; | |
10935 | 3847 |
10810 | 3848 if (!(c = gaim_buddy_get_contact(bud))) |
3849 return NULL; | |
10935 | 3850 |
10810 | 3851 cn = (GaimBlistNode *)c; |
3852 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
3853 GaimConversation *conv; | |
11338 | 3854 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 3855 if (conv->ui_data) |
3856 return conv->ui_data; | |
3857 } | |
3858 } | |
10935 | 3859 |
10810 | 3860 return NULL; |
3861 } | |
3862 | |
11855 | 3863 static void |
3864 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
3865 { | |
3866 GList *list; | |
3867 | |
3868 g_return_if_fail(bnode); | |
3869 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
3870 | |
3871 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
3872 { | |
3873 GaimGtkWindow *win = list->data; | |
3874 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
3875 | |
3876 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
3877 continue; | |
3878 | |
3879 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); | |
3880 } | |
3881 } | |
3882 | |
11581 | 3883 /************************************************************************** |
3884 * Conversation UI operations | |
3885 **************************************************************************/ | |
3886 void | |
3887 gaim_gtkconv_new(GaimConversation *conv) | |
3888 { | |
3889 GaimGtkConversation *gtkconv; | |
3890 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 3891 GtkWidget *pane = NULL; |
3892 GtkWidget *tab_cont; | |
11581 | 3893 |
3894 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 3895 conv->ui_data = gtkconv; |
3896 if (!g_list_find(gtkconv->convs, conv)) | |
3897 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 3898 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 3899 return; |
4359 | 3900 } |
3901 | |
11581 | 3902 gtkconv = g_new0(GaimGtkConversation, 1); |
3903 conv->ui_data = gtkconv; | |
3904 gtkconv->active_conv = conv; | |
3905 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
3906 | |
3907 /* Setup some initial variables. */ | |
3908 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
3909 gtkconv->tooltips = gtk_tooltips_new(); | |
3910 | |
3911 if (conv_type == GAIM_CONV_TYPE_IM) { | |
3912 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
3913 | |
3914 pane = setup_im_pane(gtkconv); | |
3915 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
3916 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
3917 pane = setup_chat_pane(gtkconv); | |
3918 } | |
3919 | |
12101 | 3920 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
3921 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
3922 | |
11581 | 3923 if (pane == NULL) { |
3924 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
3925 g_free(gtkconv->u.chat); | |
3926 else if (conv_type == GAIM_CONV_TYPE_IM) | |
3927 g_free(gtkconv->u.im); | |
3928 | |
3929 g_free(gtkconv); | |
3930 conv->ui_data = NULL; | |
3931 return; | |
10449 | 3932 } |
11581 | 3933 |
3934 /* Setup drag-and-drop */ | |
3935 gtk_drag_dest_set(pane, | |
3936 GTK_DEST_DEFAULT_MOTION | | |
3937 GTK_DEST_DEFAULT_DROP, | |
3938 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3939 GDK_ACTION_COPY); | |
3940 gtk_drag_dest_set(pane, | |
3941 GTK_DEST_DEFAULT_MOTION | | |
3942 GTK_DEST_DEFAULT_DROP, | |
3943 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3944 GDK_ACTION_COPY); | |
3945 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
3946 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3947 GDK_ACTION_COPY); | |
3948 | |
3949 gtk_drag_dest_set(gtkconv->entry, 0, | |
3950 te, sizeof(te) / sizeof(GtkTargetEntry), | |
3951 GDK_ACTION_COPY); | |
3952 | |
3953 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
3954 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3955 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
3956 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3957 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
3958 G_CALLBACK(conv_dnd_recv), gtkconv); | |
3959 | |
3960 /* Setup the container for the tab. */ | |
3961 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
3962 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
3963 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
3964 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
3965 gtk_widget_show(pane); | |
3966 | |
3967 gtkconv->make_sound = TRUE; | |
3968 | |
3969 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
3970 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
3971 else |
11581 | 3972 gtk_widget_hide(gtkconv->toolbar); |
3973 | |
3974 gtkconv->show_timestamps = TRUE; | |
3975 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
3976 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
3977 gaim_account_get_protocol_name(conv->account)); |
11581 | 3978 |
3979 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
3980 G_CALLBACK(gtk_widget_grab_focus), | |
3981 gtkconv->entry); | |
3982 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3983 if (conv_type == GAIM_CONV_TYPE_IM) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3984 /* put conv in hidden_convwin if hide_new pref is always */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3985 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
|
3986 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3987 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3988 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3989 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3990 /* put conv in hidden_convwin if hide_new pref is away and account is away */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3991 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
|
3992 && gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3993 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3994 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3995 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3996 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3997 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3998 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
3999 |
11581 | 4000 gaim_gtkconv_placement_place(gtkconv); |
4001 } | |
4002 | |
4359 | 4003 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4004 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4005 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4006 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4007 |
10810 | 4008 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4009 /* Don't destroy ourselves until all our convos are gone */ | |
4010 if (gtkconv->convs) | |
4011 return; | |
11508 | 4012 |
11581 | 4013 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4014 | |
9504 | 4015 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4016 gaim_request_close_with_handle(conv); | |
4359 | 4017 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4018 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4019 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4020 |
11338 | 4021 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4022 if (gtkconv->u.im->icon_timer != 0) |
4023 g_source_remove(gtkconv->u.im->icon_timer); | |
4024 | |
4359 | 4025 if (gtkconv->u.im->anim != NULL) |
4793 | 4026 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4027 |
4028 g_free(gtkconv->u.im); | |
11581 | 4029 } 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
|
4030 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4031 g_free(gtkconv->u.chat); |
4032 } | |
4033 | |
4633 | 4034 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4035 | |
4359 | 4036 g_free(gtkconv); |
4037 } | |
4038 | |
4039 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4040 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4041 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4042 time_t mtime) |
4359 | 4043 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4044 GaimGtkConversation *gtkconv; |
4359 | 4045 |
4046 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4047 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4048 |
6982 | 4049 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4050 } |
4051 | |
4052 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4053 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4054 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4055 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4056 GaimGtkConversation *gtkconv; |
4359 | 4057 |
4058 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4059 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4060 |
10398 | 4061 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4062 |
6982 | 4063 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4064 } |
4065 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4066 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4067 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4068 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4069 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4070 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4071 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4072 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4073 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4074 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4075 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4076 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4077 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4078 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4079 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4080 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4081 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4082 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4083 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4084 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4085 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4086 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4087 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4088 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4089 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4090 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4091 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4092 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4093 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4094 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4095 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4096 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4097 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4098 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4099 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4100 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4101 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4102 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4103 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4104 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4105 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4106 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4107 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4108 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4109 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4110 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4111 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4112 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4113 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4114 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4115 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4116 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4117 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4118 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4119 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4120 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4121 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4122 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4123 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4124 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4125 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4126 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4127 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4128 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4129 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4130 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4131 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4132 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4133 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4134 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4135 buddytag = gtk_text_buffer_create_tag( |
11096 | 4136 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4137 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4138 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4139 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4140 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4141 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4142 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4143 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4144 |
4359 | 4145 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4146 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4147 const char *message, GaimMessageFlags flags, |
4359 | 4148 time_t mtime) |
4149 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4150 GaimGtkConversation *gtkconv; |
11581 | 4151 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4152 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4153 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4154 GaimPluginProtocolInfo *prpl_info; |
4359 | 4155 int gtk_font_options = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4156 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4157 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4158 int line_count; |
4359 | 4159 char buf2[BUF_LONG]; |
4160 char mdate[64]; | |
4161 char color[10]; | |
4162 char *str; | |
4163 char *with_font_tag; | |
4896 | 4164 char *sml_attrib = NULL; |
6982 | 4165 size_t length = strlen(message) + 1; |
4895 | 4166 |
4359 | 4167 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4168 |
4169 /* Set the active conversation to the one that just messaged us. */ | |
4170 /* TODO: consider not doing this if the account is offline or something */ | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4171 gaim_gtkconv_set_active_conversation(conv); |
11581 | 4172 |
4359 | 4173 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4174 account = gaim_conversation_get_account(conv); |
11581 | 4175 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4176 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4177 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4178 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4179 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4180 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4181 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4182 /* 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
|
4183 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4184 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4185 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4186 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4187 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4188 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4189 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4190 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4191 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4192 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4193 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4194 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4195 |
8677 | 4196 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
4197 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
4198 | |
5133 | 4199 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4200 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4201 else | |
4202 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4203 |
4896 | 4204 if(gc) |
9699 | 4205 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4206 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4207 |
10503 | 4208 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4209 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4210 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4211 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4212 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4213 |
7956 | 4214 /* this is gonna crash one day, I can feel it. */ |
4215 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4216 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4217 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4218 } |
4359 | 4219 |
10737 | 4220 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4221 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4222 g_snprintf(buf2, sizeof(buf2), |
8690 | 4223 "<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
|
4224 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4225 |
8962 | 4226 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 4227 |
8722 | 4228 } else if (flags & GAIM_MESSAGE_ERROR) { |
4229 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4230 "<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
|
4231 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4232 |
8962 | 4233 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
4234 | |
7431 | 4235 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4236 g_snprintf(buf2, BUF_LONG, |
8690 | 4237 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4238 sml_attrib ? sml_attrib : "", message); |
7440 | 4239 |
10884 | 4240 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
10346 | 4241 } else if (flags & GAIM_MESSAGE_RAW) { |
10348 | 4242 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); |
10346 | 4243 } else { |
4895 | 4244 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4245 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
|
4246 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4247 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4248 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
|
4249 int tag_end_offset = 0; |
7440 | 4250 |
6621 | 4251 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4252 str = g_malloc(1024); |
7440 | 4253 |
4359 | 4254 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4255 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4256 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4257 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4258 tag_start_offset += 3; |
4359 | 4259 } |
4260 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4261 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4262 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4263 tag_end_offset = 2; |
4359 | 4264 strcpy(color, "#00FF00"); |
4265 } | |
7440 | 4266 } |
4359 | 4267 else { |
10504 | 4268 if (gaim_message_meify(new_message, -1)) { |
4359 | 4269 str = g_malloc(1024); |
7440 | 4270 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4271 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4272 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
|
4273 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4274 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4275 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4276 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4277 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4278 } |
7440 | 4279 |
6621 | 4280 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4281 strcpy(color, "#AF7F00"); |
4282 else | |
4283 strcpy(color, "#062585"); | |
4284 } | |
4285 else { | |
4286 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4287 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4288 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
|
4289 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4290 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4291 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4292 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4293 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4294 } |
6621 | 4295 if (flags & GAIM_MESSAGE_NICK) |
4359 | 4296 strcpy(color, "#AF7F00"); |
6621 | 4297 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4298 if (flags & GAIM_MESSAGE_COLORIZE) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4299 GdkColor *col = get_nick_color(gtkconv, alias); |
10346 | 4300 |
10108 | 4301 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4302 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4303 } else |
7854 | 4304 strcpy(color, RECV_COLOR); |
4359 | 4305 } |
6621 | 4306 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4307 strcpy(color, SEND_COLOR); |
10892 | 4308 else { |
4309 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4310 strcpy(color, "#000000"); | |
4311 } | |
4359 | 4312 } |
4313 } | |
10892 | 4314 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4315 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4316 g_free(alias_escaped); |
11508 | 4317 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4318 /* 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
|
4319 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4320 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4321 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4322 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4323 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4324 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4325 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4326 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4327 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4328 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4329 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4330 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4331 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4332 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4333 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4334 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4335 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4336 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4337 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4338 /* 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
|
4339 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4340 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4341 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4342 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4343 } |
7440 | 4344 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4345 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4346 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4347 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4348 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4349 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4350 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4351 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4352 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4353 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4354 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4355 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4356 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4357 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4358 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4359 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4360 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4361 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4362 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4363 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4364 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4365 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4366 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4367 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4368 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4369 |
4359 | 4370 g_free(str); |
4371 | |
4895 | 4372 if(gc){ |
4896 | 4373 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4374 char *post = "</font>"; |
4375 int pre_len = strlen(pre); | |
4376 int post_len = strlen(post); | |
7440 | 4377 |
4895 | 4378 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4379 |
4895 | 4380 strcpy(with_font_tag, pre); |
4381 memcpy(with_font_tag + pre_len, new_message, length); | |
4382 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4383 |
4895 | 4384 length += pre_len + post_len; |
4385 g_free(pre); | |
4386 } | |
4608 | 4387 else |
4895 | 4388 with_font_tag = g_memdup(new_message, length); |
7440 | 4389 |
8962 | 4390 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
4391 with_font_tag, gtk_font_options); | |
7440 | 4392 |
4393 g_free(with_font_tag); | |
7447 | 4394 g_free(new_message); |
7440 | 4395 } |
4396 | |
5012 | 4397 if(sml_attrib) |
4398 g_free(sml_attrib); | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4399 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4400 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4401 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4402 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4403 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4404 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4405 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4406 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4407 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4408 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4409 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4410 else if ((flags & GAIM_MESSAGE_NO_LOG) == GAIM_MESSAGE_NO_LOG) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4411 unseen = GAIM_UNSEEN_NOLOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4412 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4413 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4414 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4415 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4416 } |
4359 | 4417 } |
4418 | |
4419 static void | |
11869 | 4420 gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users, GList *flags, GList *aliases) |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4421 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4422 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4423 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4424 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4425 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4426 GList *ll; |
11869 | 4427 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4428 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4429 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4430 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4431 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4432 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4433 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4434 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4435 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
|
4436 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4437 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4438 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4439 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4440 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4441 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4442 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4443 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4444 l = users; |
11869 | 4445 ll = flags; |
4446 lll = aliases; | |
4447 while (l != NULL && ll != NULL && lll != NULL) { | |
4448 add_chat_buddy_common(conv, (const char *)l->data, GPOINTER_TO_INT(ll->data), (const char *)lll->data, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4449 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4450 ll = ll->next; |
11869 | 4451 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4452 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4453 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4454 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4455 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4456 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
|
4457 const char *new_name, const char *new_alias) |
4359 | 4458 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4459 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4460 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4461 GaimGtkChatPane *gtkchat; |
11869 | 4462 GaimConvChatBuddyFlags flags; |
4359 | 4463 GtkTreeIter iter; |
4464 GtkTreeModel *model; | |
4465 int f = 1; | |
4466 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4467 chat = GAIM_CONV_CHAT(conv); |
4359 | 4468 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4469 gtkchat = gtkconv->u.chat; | |
4470 | |
9554 | 4471 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4472 | |
4473 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4474 return; | |
4475 | |
4476 while (f != 0) { | |
4477 char *val; | |
4478 | |
11869 | 4479 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4480 |
4481 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4482 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4483 g_free(val); | |
4359 | 4484 break; |
4485 } | |
9554 | 4486 |
4487 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4488 | |
4489 g_free(val); | |
4359 | 4490 } |
4491 | |
9554 | 4492 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4493 return; |
4494 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4495 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4496 |
11869 | 4497 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4498 } |
4499 | |
4500 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4501 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 4502 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4503 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4504 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4505 GaimGtkChatPane *gtkchat; |
4359 | 4506 GtkTreeIter iter; |
4507 GtkTreeModel *model; | |
4508 char tmp[BUF_LONG]; | |
4509 int num_users; | |
4510 int f = 1; | |
4511 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4512 chat = GAIM_CONV_CHAT(conv); |
4359 | 4513 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4514 gtkchat = gtkconv->u.chat; | |
4515 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4516 num_users = g_list_length(gaim_conv_chat_get_users(chat)) - 1; |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4517 |
9554 | 4518 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4519 | |
4520 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4521 return; | |
4522 | |
4523 while (f != 0) { | |
4524 char *val; | |
4525 | |
4526 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4527 | |
4528 if (!gaim_utf8_strcasecmp(user, val)) { | |
4529 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4530 g_free(val); | |
4359 | 4531 break; |
4532 } | |
9554 | 4533 |
4534 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4535 | |
4536 g_free(val); | |
4359 | 4537 } |
4538 | |
9554 | 4539 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 4540 return; |
4541 | |
4542 g_snprintf(tmp, sizeof(tmp), | |
9554 | 4543 ngettext("%d person in room", "%d people in room", |
4544 num_users), num_users); | |
4359 | 4545 |
4546 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4547 | |
4548 } | |
4549 | |
4550 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4551 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4552 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4553 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4554 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4555 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4556 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4557 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4558 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4559 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4560 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4561 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4562 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4563 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4564 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4565 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4566 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4567 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
|
4568 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4569 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4570 for (l = users; l != NULL; l = l->next) { |
9554 | 4571 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4572 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4573 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4574 continue; |
4575 | |
4576 do { | |
4577 char *val; | |
4578 | |
4579 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4580 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4581 | |
9696 | 4582 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4583 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4584 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4585 #else |
4586 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4587 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4588 #endif | |
4589 } | |
9554 | 4590 else |
4591 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4592 | |
4593 g_free(val); | |
4594 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4595 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4596 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4597 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4598 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4599 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4600 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4601 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4602 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4603 |
9554 | 4604 static void |
4605 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4606 { | |
4607 GaimConvChat *chat; | |
11869 | 4608 GaimConvChatBuddyFlags flags; |
9554 | 4609 GaimGtkConversation *gtkconv; |
4610 GaimGtkChatPane *gtkchat; | |
4611 GtkTreeIter iter; | |
4612 GtkTreeModel *model; | |
4613 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4614 char *alias = NULL; |
9554 | 4615 |
4616 chat = GAIM_CONV_CHAT(conv); | |
4617 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4618 gtkchat = gtkconv->u.chat; | |
4619 | |
4620 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4621 | |
4622 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4623 return; | |
4624 | |
4625 while (f != 0) { | |
4626 char *val; | |
4627 | |
4628 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4629 | |
4630 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4631 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4632 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4633 g_free(val); | |
4634 break; | |
4635 } | |
4636 | |
4637 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4638 | |
4639 g_free(val); | |
4640 } | |
4641 | |
4642 if (!gaim_conv_chat_find_user(chat, user)) | |
4643 return; | |
4644 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4645 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4646 |
11869 | 4647 flags = gaim_conv_chat_user_get_flags(chat, user); |
4648 | |
4649 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4650 g_free(alias); |
9554 | 4651 } |
4652 | |
11581 | 4653 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4654 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4655 { |
11581 | 4656 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4657 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4658 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4659 |
11581 | 4660 win = gtkconv->win; |
4661 | |
4662 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
|
4663 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4664 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4665 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4666 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4667 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4668 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4669 |
10526 | 4670 static gboolean |
4671 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
4672 { | |
4673 GaimGtkConversation *gtkconv; | |
4674 GtkIMHtmlSmiley *smiley; | |
4675 GdkPixbufLoader *loader; | |
11525 | 4676 struct smiley_list *list; |
4677 const char *sml = NULL, *conv_sml; | |
4678 | |
4679 if (!conv || !smile || !*smile) { | |
10526 | 4680 return FALSE; |
4681 } | |
4682 | |
11525 | 4683 /* If smileys are off, return false */ |
4684 if (gaim_gtkthemes_smileys_disabled()) | |
4685 return FALSE; | |
4686 | |
4687 /* If possible add this smiley to the current theme. | |
4688 * The addition is only temporary: custom smilies aren't saved to disk. */ | |
4689 conv_sml = gaim_account_get_protocol_name(conv->account); | |
10526 | 4690 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11525 | 4691 |
4692 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | |
4693 if (!strcmp(list->sml, conv_sml)) { | |
4694 sml = list->sml; | |
4695 break; | |
4696 } | |
4697 } | |
4698 | |
10526 | 4699 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
4700 | |
4701 if (smiley) { | |
11525 | 4702 |
4703 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
4704 return FALSE; | |
4705 } | |
4706 | |
4707 /* Close the old GdkPixbufAnimation, then create a new one for | |
4708 * the smiley we are about to receive */ | |
4709 g_object_unref(G_OBJECT(smiley->icon)); | |
4710 | |
4711 smiley->loader = gdk_pixbuf_loader_new(); | |
4712 smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); | |
4713 if (smiley->icon) | |
4714 g_object_ref(G_OBJECT(smiley->icon)); | |
4715 | |
4716 /* A custom smiley is already associated */ | |
4717 return TRUE; | |
10526 | 4718 } |
4719 | |
4720 loader = gdk_pixbuf_loader_new(); | |
4721 | |
4722 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
4723 /* 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
|
4724 GtkIMHtmlSmiley by opaque */ |
10526 | 4725 smiley = g_new0(GtkIMHtmlSmiley, 1); |
4726 smiley->file = NULL; | |
4727 smiley->smile = g_strdup(smile); | |
4728 smiley->loader = loader; | |
11525 | 4729 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 4730 |
4731 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
4732 if (smiley->icon) | |
4733 g_object_ref(G_OBJECT(smiley->icon)); | |
4734 | |
11525 | 4735 |
10526 | 4736 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); |
10537 | 4737 |
10526 | 4738 return TRUE; |
4739 } | |
4740 | |
10537 | 4741 static void |
10526 | 4742 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 4743 const guchar *data, gsize size) |
10526 | 4744 { |
4745 GaimGtkConversation *gtkconv; | |
4746 GtkIMHtmlSmiley *smiley; | |
10537 | 4747 GdkPixbufLoader *loader; |
10526 | 4748 const char *sml; |
4749 | |
4750 sml = gaim_account_get_protocol_name(conv->account); | |
4751 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4752 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4753 | |
10537 | 4754 if (!smiley) |
10526 | 4755 return; |
10537 | 4756 |
10526 | 4757 loader = smiley->loader; |
10537 | 4758 if (!loader) |
10526 | 4759 return; |
4760 | |
4761 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
4762 } | |
4763 | |
4764 static void | |
4765 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
4766 { | |
4767 GaimGtkConversation *gtkconv; | |
4768 GtkIMHtmlSmiley *smiley; | |
4769 GdkPixbufLoader *loader; | |
4770 const char *sml; | |
11525 | 4771 GtkWidget *icon = NULL; |
4772 GtkTextChildAnchor *anchor = NULL; | |
4773 GtkTextIter end; | |
4774 GtkIMHtml *imhtml; | |
4775 GSList *current = NULL; | |
10526 | 4776 |
4777 g_return_if_fail(conv != NULL); | |
4778 g_return_if_fail(smile != NULL); | |
4779 | |
4780 sml = gaim_account_get_protocol_name(conv->account); | |
4781 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4782 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
4783 | |
10537 | 4784 if (!smiley) |
10526 | 4785 return; |
4786 | |
4787 loader = smiley->loader; | |
4788 | |
10537 | 4789 if (!loader) |
10526 | 4790 return; |
10537 | 4791 |
11525 | 4792 smiley->icon = gdk_pixbuf_loader_get_animation(loader); |
4793 if (smiley->icon) | |
4794 g_object_ref(G_OBJECT(smiley->icon)); | |
4795 | |
4796 for (current = smiley->anchors; current != NULL; current = g_slist_next(current)) { | |
4797 | |
4798 icon = gtk_image_new_from_animation(smiley->icon); | |
4799 | |
4800 if (icon) { | |
12047 | 4801 gtk_widget_show(icon); |
4802 | |
11525 | 4803 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
4804 | |
4805 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smile)), g_free); | |
4806 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smile), g_free); | |
4807 | |
4808 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(gtkconv->imhtml), icon, anchor); | |
4809 } | |
4810 | |
4811 } | |
4812 | |
4813 g_slist_free(smiley->anchors); | |
4814 smiley->anchors = NULL; | |
4815 | |
4816 /* Scroll to the end of the widget in case the smiley height was big... */ | |
4817 /* FIXME: need to test this actually works, previous dealings with scrolling | |
4818 * makes me question it */ | |
4819 imhtml = GTK_IMHTML(gtkconv->imhtml); | |
4820 gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(imhtml->text_buffer), &end); | |
4821 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(gtkconv->imhtml), &end, 0, TRUE, 0, 0); | |
4822 | |
10526 | 4823 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
4824 | |
4825 gdk_pixbuf_loader_close(loader, NULL); | |
4826 g_object_unref(G_OBJECT(loader)); | |
4827 smiley->loader = NULL; | |
4828 } | |
4829 | |
11581 | 4830 /* |
4831 * Makes sure all the menu items and all the buttons are hidden/shown and | |
4832 * sensitive/insensitive. This is called after changing tabs and when an | |
4833 * account signs on or off. | |
4834 */ | |
4835 static void | |
4836 gray_stuff_out(GaimGtkConversation *gtkconv) | |
4837 { | |
4838 GaimGtkWindow *win; | |
4839 GaimConversation *conv = gtkconv->active_conv; | |
4840 GaimConnection *gc; | |
4841 GaimPluginProtocolInfo *prpl_info = NULL; | |
4842 GdkPixbuf *window_icon = NULL; | |
4843 GtkIMHtmlButtons buttons; | |
4844 GaimAccount *account; | |
4845 | |
4846 win = gaim_gtkconv_get_window(gtkconv); | |
4847 gc = gaim_conversation_get_gc(conv); | |
4848 account = gaim_conversation_get_account(conv); | |
4849 | |
4850 if (gc != NULL) | |
4851 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
4852 | |
11594 | 4853 if (win->menu.send_to != NULL) |
11734 | 4854 update_send_to_selection(win); |
11581 | 4855 |
4856 /* | |
4857 * Handle hiding and showing stuff based on what type of conv this is. | |
4858 * Stuff that Gaim IMs support in general should be shown for IM | |
4859 * conversations. Stuff that Gaim chats support in general should be | |
4860 * shown for chat conversations. It doesn't matter whether the PRPL | |
4861 * supports it or not--that only affects if the button or menu item | |
4862 * is sensitive or not. | |
4863 */ | |
4864 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
4865 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
4866 | |
4867 /* Deal with menu items */ | |
4868 gtk_widget_show(win->menu.view_log); | |
4869 gtk_widget_show(win->menu.send_file); | |
4870 gtk_widget_show(win->menu.add_pounce); | |
4871 gtk_widget_show(win->menu.get_info); | |
4872 gtk_widget_hide(win->menu.invite); | |
4873 gtk_widget_show(win->menu.alias); | |
4874 gtk_widget_show(win->menu.block); | |
4875 | |
4876 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
4877 gtk_widget_show(win->menu.add); | |
4878 gtk_widget_hide(win->menu.remove); | |
4879 } else { | |
4880 gtk_widget_show(win->menu.remove); | |
4881 gtk_widget_hide(win->menu.add); | |
4882 } | |
4883 | |
4884 gtk_widget_show(win->menu.insert_link); | |
4885 gtk_widget_show(win->menu.insert_image); | |
4886 gtk_widget_show(win->menu.show_icon); | |
4887 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
4888 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
4889 | |
4890 /* Deal with menu items */ | |
4891 gtk_widget_show(win->menu.view_log); | |
4892 gtk_widget_hide(win->menu.send_file); | |
4893 gtk_widget_hide(win->menu.add_pounce); | |
4894 gtk_widget_hide(win->menu.get_info); | |
4895 gtk_widget_show(win->menu.invite); | |
4896 gtk_widget_show(win->menu.alias); | |
4897 gtk_widget_hide(win->menu.block); | |
4898 gtk_widget_hide(win->menu.show_icon); | |
4899 | |
4900 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
4901 /* If the chat is NOT in the buddy list */ | |
4902 gtk_widget_show(win->menu.add); | |
4903 gtk_widget_hide(win->menu.remove); | |
4904 } else { | |
4905 /* If the chat IS in the buddy list */ | |
4906 gtk_widget_hide(win->menu.add); | |
4907 gtk_widget_show(win->menu.remove); | |
4908 } | |
4909 | |
4910 gtk_widget_show(win->menu.insert_link); | |
4911 gtk_widget_hide(win->menu.insert_image); | |
4912 } | |
4913 | |
4914 /* | |
4915 * Handle graying stuff out based on whether an account is connected | |
4916 * and what features that account supports. | |
4917 */ | |
4918 if ((gc != NULL) && | |
12012 | 4919 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
4920 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
4921 { | |
11581 | 4922 /* Account is online */ |
4923 /* Deal with the toolbar */ | |
12012 | 4924 if (conv->features & GAIM_CONNECTION_HTML) |
4925 { | |
4926 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
4927 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
4928 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
4929 buttons &= ~GTK_IMHTML_IMAGE; | |
4930 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
4931 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
4932 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
4933 { | |
4934 buttons &= ~GTK_IMHTML_GROW; | |
4935 buttons &= ~GTK_IMHTML_SHRINK; | |
4936 } | |
4937 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
4938 buttons &= ~GTK_IMHTML_LINKDESC; | |
4939 } else { | |
4940 buttons = GTK_IMHTML_SMILEY; | |
4941 } | |
4942 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); | |
4943 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 4944 |
4945 /* Deal with menu items */ | |
12012 | 4946 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
4947 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
4948 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
4949 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
4950 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
4951 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 4952 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 4953 |
4954 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
4955 { | |
4956 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
4957 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
4958 gtk_widget_set_sensitive(win->menu.send_file, | |
4959 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
4960 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
4961 gtk_widget_set_sensitive(win->menu.alias, | |
4962 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
4963 } | |
4964 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
4965 { | |
4966 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
4967 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
4968 gtk_widget_set_sensitive(win->menu.alias, | |
4969 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
4970 } | |
11581 | 4971 |
4972 /* Deal with chat userlist buttons */ | |
12012 | 4973 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
4974 { | |
4975 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
4976 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
4977 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
4978 } | |
4979 } else { | |
11581 | 4980 /* Account is offline */ |
4981 /* Or it's a chat that we've left. */ | |
4982 | |
4983 /* Then deal with menu items */ | |
12012 | 4984 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
4985 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
4986 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
4987 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
4988 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
4989 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
4990 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
4991 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
4992 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
4993 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
4994 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 4995 |
4996 /* Deal with chat userlist buttons */ | |
12012 | 4997 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
4998 { | |
4999 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5000 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5001 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5002 } | |
5003 } | |
11581 | 5004 |
5005 /* | |
5006 * Update the window's icon | |
5007 */ | |
5008 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
12012 | 5009 (gtkconv->u.im->anim)) |
11581 | 5010 { |
5011 window_icon = | |
5012 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5013 g_object_ref(window_icon); | |
5014 } else { | |
5015 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5016 } | |
5017 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5018 if (window_icon != NULL) | |
5019 g_object_unref(G_OBJECT(window_icon)); | |
5020 } | |
5021 | |
10526 | 5022 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5023 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5024 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 5025 { |
11581 | 5026 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5027 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5028 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5029 GaimConvChat *chat; |
4359 | 5030 |
10116 | 5031 g_return_if_fail(conv != NULL); |
5032 | |
4359 | 5033 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5034 win = gtkconv->win; |
10810 | 5035 conv = gtkconv->active_conv; /* Gross hack */ |
11581 | 5036 /* Maybe we should just ignore it if conv != gtkconv->active_conv, |
5037 * instead of the gross hack? | |
5038 */ | |
4359 | 5039 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5040 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5041 { |
4359 | 5042 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5043 |
11338 | 5044 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5045 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5046 |
4359 | 5047 gaim_gtkconv_update_buttons_by_protocol(conv); |
5048 | |
11734 | 5049 update_send_to_selection(win); |
4359 | 5050 |
11525 | 5051 gaim_gtkthemes_smiley_themeize(gtkconv->imhtml); |
6394 | 5052 |
6395 | 5053 update_tab_icon(conv); |
4359 | 5054 } |
5055 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5056 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5057 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5058 { |
9472 | 5059 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5060 GaimConvIm *im = NULL; |
9472 | 5061 GaimConnection *gc = gaim_conversation_get_gc(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5062 /* 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
|
5063 char style[51]; |
4736 | 5064 |
11338 | 5065 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5066 im = GAIM_CONV_IM(conv); |
4359 | 5067 |
11338 | 5068 if (!gc || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5069 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5070 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5071 else | |
5072 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5073 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5074 *style = '\0'; |
4359 | 5075 |
5076 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5077 gtk_widget_realize(gtkconv->tab_label); | |
5078 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5079 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5080 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5081 { |
11759 | 5082 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5083 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5084 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5085 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5086 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5087 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5088 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5089 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5090 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5091 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5092 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5093 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5094 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5095 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5096 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5097 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5098 { |
11758 | 5099 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5100 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5101 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5102 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5103 { |
8536 | 5104 char *html_title,*label; |
5105 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5106 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5107 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5108 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5109 style, html_title); |
8536 | 5110 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5111 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5112 g_free(label); |
4359 | 5113 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5114 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5115 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5116 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5117 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5118 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5119 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5120 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5121 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5122 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5123 gtk_window_set_title(GTK_WINDOW(win->window), title); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5124 } |
9472 | 5125 |
5126 g_free(title); | |
4359 | 5127 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5128 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5129 { |
7154 | 5130 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5131 chat = GAIM_CONV_CHAT(conv); |
4359 | 5132 gtkchat = gtkconv->u.chat; |
5133 | |
7154 | 5134 topic = gaim_conv_chat_get_topic(chat); |
5135 | |
9554 | 5136 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5137 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5138 topic ? topic : "", NULL); |
4359 | 5139 } |
5140 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5141 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5142 { |
11581 | 5143 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); |
11594 | 5144 generate_send_to_items(win); |
8946 | 5145 update_tab_icon(conv); |
9472 | 5146 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5147 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5148 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5149 { |
8946 | 5150 update_tab_icon(conv); |
4359 | 5151 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5152 else if (type == GAIM_CONV_UPDATE_ADD || type == GAIM_CONV_UPDATE_REMOVE || |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5153 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5154 { |
9472 | 5155 gaim_conversation_autoset_title(conv); |
10810 | 5156 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5157 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5158 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5159 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5160 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5161 } |
10665 | 5162 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5163 { | |
10810 | 5164 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5165 } |
4359 | 5166 } |
5167 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5168 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5169 { |
11581 | 5170 gaim_gtkconv_new, |
4359 | 5171 gaim_gtkconv_destroy, /* destroy_conversation */ |
5172 gaim_gtkconv_write_chat, /* write_chat */ | |
5173 gaim_gtkconv_write_im, /* write_im */ | |
5174 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5175 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5176 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5177 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5178 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5179 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5180 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5181 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5182 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5183 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5184 gaim_gtkconv_updated /* updated */ |
5185 }; | |
5186 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5187 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5188 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5189 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5190 return &conversation_ui_ops; |
4359 | 5191 } |
5192 | |
5193 /************************************************************************** | |
5194 * Public conversation utility functions | |
5195 **************************************************************************/ | |
5196 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5197 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5198 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5199 GaimGtkConversation *gtkconv; |
11581 | 5200 GaimGtkWindow *win; |
4359 | 5201 |
10381 | 5202 GdkPixbufLoader *loader; |
5203 GdkPixbufAnimation *anim; | |
4359 | 5204 GError *err = NULL; |
5205 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5206 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5207 size_t len; |
4359 | 5208 |
5209 GdkPixbuf *buf; | |
5210 | |
5211 GtkWidget *event; | |
5212 GtkWidget *frame; | |
5213 GdkPixbuf *scale; | |
5214 GdkPixmap *pm; | |
5215 GdkBitmap *bm; | |
9318 | 5216 int scale_width, scale_height; |
5217 | |
5218 GaimAccount *account; | |
5219 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5220 |
9324 | 5221 GaimBuddyIcon *icon; |
5222 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5223 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5224 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5225 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5226 |
5227 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5228 win = gtkconv->win; |
10175 | 5229 |
9687 | 5230 if (!gtkconv->u.im->show_icon) |
5231 return; | |
5232 | |
9318 | 5233 account = gaim_conversation_get_account(conv); |
5234 if(account && account->gc) | |
5235 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5236 |
9845 | 5237 /* Remove the current icon stuff */ |
9885 | 5238 if (gtkconv->u.im->icon_container != NULL) |
5239 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5240 gtkconv->u.im->icon_container = NULL; | |
9845 | 5241 |
5242 if (gtkconv->u.im->anim != NULL) | |
5243 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5244 | |
9887 | 5245 gtkconv->u.im->anim = NULL; |
5246 | |
9845 | 5247 if (gtkconv->u.im->icon_timer != 0) |
5248 g_source_remove(gtkconv->u.im->icon_timer); | |
5249 | |
5250 gtkconv->u.im->icon_timer = 0; | |
5251 | |
5252 if (gtkconv->u.im->iter != NULL) | |
5253 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5254 |
10116 | 5255 gtkconv->u.im->iter = NULL; |
5256 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5257 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5258 return; |
5259 | |
5260 if (gaim_conversation_get_gc(conv) == NULL) | |
5261 return; | |
5262 | |
9324 | 5263 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5264 | |
5265 if (icon == NULL) | |
5266 return; | |
5267 | |
5268 data = gaim_buddy_icon_get_data(icon, &len); | |
5269 | |
10381 | 5270 loader = gdk_pixbuf_loader_new(); |
5271 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5272 anim = gdk_pixbuf_loader_get_animation(loader); | |
5273 if (anim) | |
5274 g_object_ref(G_OBJECT(anim)); | |
5275 gdk_pixbuf_loader_close(loader, &err); | |
5276 g_object_unref(loader); | |
5277 | |
5278 if (!anim) | |
9324 | 5279 return; |
10381 | 5280 gtkconv->u.im->anim = anim; |
9324 | 5281 |
4359 | 5282 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5283 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5284 "Buddy icon error: %s\n", err->message); |
4359 | 5285 g_error_free(err); |
5286 } | |
5287 | |
5288 if (!gtkconv->u.im->anim) | |
5289 return; | |
5290 | |
5291 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5292 gtkconv->u.im->iter = NULL; | |
5293 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5294 } else { | |
5295 gtkconv->u.im->iter = | |
8496 | 5296 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5297 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5298 if (gtkconv->u.im->animate) |
10810 | 5299 start_anim(NULL, gtkconv); |
4359 | 5300 } |
5301 | |
10483 | 5302 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5303 NULL, &scale_width, &scale_height); |
4359 | 5304 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5305 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5306 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5307 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5308 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5309 GDK_INTERP_BILINEAR); |
4359 | 5310 |
5311 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5312 g_object_unref(G_OBJECT(scale)); |
4359 | 5313 |
8821 | 5314 |
9885 | 5315 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5316 |
4359 | 5317 frame = gtk_frame_new(NULL); |
5318 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5319 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5320 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5321 FALSE, FALSE, 0); | |
8821 | 5322 |
4359 | 5323 event = gtk_event_box_new(); |
5324 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5325 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5326 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5327 gtk_widget_show(event); |
5328 | |
4635 | 5329 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5330 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5331 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5332 gtk_widget_show(gtkconv->u.im->icon); | |
5333 | |
4793 | 5334 g_object_unref(G_OBJECT(pm)); |
4359 | 5335 |
5336 if (bm) | |
4793 | 5337 g_object_unref(G_OBJECT(bm)); |
7143 | 5338 |
10356 | 5339 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5340 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5341 |
9885 | 5342 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5343 gtk_widget_show(frame); |
5344 | |
7143 | 5345 /* The buddy icon code needs badly to be fixed. */ |
5346 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5347 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5348 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
4359 | 5349 } |
5350 | |
5351 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5352 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5353 { |
11581 | 5354 GaimGtkWindow *win; |
4359 | 5355 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5356 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5357 return; |
5358 | |
11581 | 5359 win = GAIM_GTK_CONVERSATION(conv)->win; |
5360 | |
5361 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5362 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5363 } |
5364 | |
5365 int | |
11614 | 5366 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5367 { |
4359 | 5368 gint nb_x, nb_y, x_rel, y_rel; |
5369 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5370 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5371 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5372 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5373 gboolean horiz; |
4359 | 5374 |
11614 | 5375 if (to_right) |
5376 *to_right = FALSE; | |
5377 | |
11581 | 5378 notebook = GTK_NOTEBOOK(win->notebook); |
5379 | |
5380 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5381 x_rel = x - nb_x; |
5382 y_rel = y - nb_y; | |
5383 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5384 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5385 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5386 |
11780 | 5387 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5388 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5389 #else |
5390 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5391 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5392 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5393 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5394 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5395 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5396 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5397 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5398 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5399 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5400 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5401 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
|
5402 page_num = i; |
11614 | 5403 |
5404 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5405 *to_right = TRUE; | |
5406 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5407 break; |
4359 | 5408 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5409 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5410 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5411 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
|
5412 page_num = i; |
11614 | 5413 |
5414 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5415 *to_right = TRUE; | |
5416 | |
4359 | 5417 break; |
5418 } | |
5419 } | |
5420 } | |
5421 | |
5422 return page_num; | |
5423 } | |
5424 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5425 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5426 close_on_tabs_pref_cb(const char *name, GaimPrefType type, gpointer value, |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5427 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5428 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5429 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5430 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5431 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5432 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5433 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5434 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5435 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5436 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5437 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5438 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5439 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5440 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5441 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5442 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5443 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5444 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5445 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5446 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5447 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5448 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5449 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5450 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5451 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5452 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5453 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5454 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5455 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5456 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5457 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5458 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5459 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5460 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5461 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5462 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5463 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5464 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5465 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5466 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5467 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5468 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5469 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5470 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5471 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5472 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5473 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5474 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5475 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5476 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5477 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5478 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5479 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5480 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5481 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5482 GtkPositionType pos; |
11581 | 5483 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5484 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5485 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5486 |
11581 | 5487 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5488 win = l->data; | |
5489 | |
11619 | 5490 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
|
5491 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5492 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5493 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5494 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5495 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5496 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5497 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5498 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5499 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5500 GaimGtkConversation *gtkconv; |
11581 | 5501 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5502 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5503 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5504 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5505 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5506 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5507 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5508 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5509 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5510 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5511 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5512 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5513 gtk_check_menu_item_set_active( |
11581 | 5514 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5515 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5516 |
5517 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5518 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5519 else |
8317 | 5520 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5521 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5522 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5523 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5524 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5525 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5526 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5527 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5528 GList *l; |
8189 | 5529 GaimConversation *conv; |
5530 GaimGtkConversation *gtkconv; | |
11581 | 5531 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5532 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5533 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
|
5534 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5535 |
8189 | 5536 /* Set the "animate" flag for each icon based on the new preference */ |
5537 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5538 conv = (GaimConversation *)l->data; | |
5539 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5540 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5541 } |
8189 | 5542 |
5543 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5544 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5545 win = l->data; | |
5546 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5547 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5548 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5549 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5550 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5551 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5552 show_buddy_icons_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5553 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5554 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5555 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5556 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5557 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5558 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5559 |
11338 | 5560 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 5561 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5562 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5563 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5564 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
5565 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5566 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5567 gpointer value, gpointer data) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5568 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5569 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5570 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5571 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5572 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5573 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5574 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5575 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5576 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5577 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5578 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5579 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5580 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
|
5581 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5582 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5583 if(gaim_status_type_get_primitive(gaim_status_get_type(oldstatus))!=GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5584 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5585 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5586 if(gaim_status_type_get_primitive(gaim_status_get_type(newstatus))==GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5587 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5588 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5589 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5590 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5591 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5592 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5593 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5594 if(gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5595 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5596 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5597 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5598 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5599 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5600 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5601 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5602 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5603 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5604 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5605 hide_new_pref_cb(const char *name, GaimPrefType type, gpointer value, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5606 gpointer data) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5607 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5608 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5609 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5610 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5611 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5612 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5613 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5614 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5615 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5616 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
|
5617 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5618 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5619 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
|
5620 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5621 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5622 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5623 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5624 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5625 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5626 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5627 if(when_away && gaim_status_type_get_primitive( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5628 gaim_status_get_type(gaim_account_get_active_status( |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5629 gaim_conversation_get_account(conv)))) == GAIM_STATUS_AWAY) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5630 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5631 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5632 private_remove_gtkconv(hidden_convwin, gtkconv, FALSE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5633 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5634 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5635 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5636 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5637 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5638 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5639 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5640 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5641 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5642 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5643 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5644 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5645 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5646 |
11581 | 5647 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5648 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5649 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5650 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5651 |
11581 | 5652 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5653 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5654 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5655 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5656 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5657 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5658 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5659 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5660 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5661 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5662 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5663 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5664 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5665 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5666 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5667 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5668 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5669 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5670 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5671 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5672 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5673 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5674 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5675 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5676 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5677 |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5678 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 5679 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 5680 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5681 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 5682 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 5683 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5684 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5685 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5686 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5687 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5688 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
|
5689 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5690 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5691 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5692 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5693 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5694 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5695 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5696 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5697 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5698 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 5699 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5700 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 5701 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5702 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5703 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5704 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 5705 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
|
5706 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5707 /* convert old queuing prefs to hide_new 3-way pref */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5708 if(gaim_prefs_exists("/plugins/gtk/docklet/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5709 gaim_prefs_get_bool("/plugins/gtk/docklet/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5710 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "always"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5711 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5712 else if(gaim_prefs_exists("/gaim/gtk/away/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5713 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5714 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "away"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5715 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5716 else { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5717 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "never"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5718 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5719 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5720 /* Connect callbacks. */ |
10087 | 5721 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
|
5722 close_on_tabs_pref_cb, NULL); |
10087 | 5723 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
|
5724 show_formatting_toolbar_pref_cb, NULL); |
10087 | 5725 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5726 spellcheck_pref_cb, NULL); |
10087 | 5727 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5728 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5729 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5730 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5731 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5732 |
10087 | 5733 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5734 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5735 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5736 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5737 /* IM callbacks */ |
10087 | 5738 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
|
5739 animate_buddy_icons_pref_cb, NULL); |
10087 | 5740 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
|
5741 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5742 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5743 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5744 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5745 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5746 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5747 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5748 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5749 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
5750 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5751 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5752 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5753 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5754 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5755 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 5756 |
5757 /********************************************************************** | |
5758 * Register commands | |
5759 **********************************************************************/ | |
9829 | 5760 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
5761 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
5762 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 5763 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
5764 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5765 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 5766 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
5767 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 5768 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
|
5769 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5770 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
5771 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 5772 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 5773 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
5774 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 5775 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5776 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5777 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5778 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5779 |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5780 gaim_signal_connect(blist_handle, "buddy-added", handle, |
11855 | 5781 G_CALLBACK(buddy_update_cb), NULL); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5782 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
11855 | 5783 G_CALLBACK(buddy_update_cb), NULL); |
5784 | |
11581 | 5785 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5786 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5787 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5788 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5789 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5790 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5791 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5792 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5793 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5794 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5795 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5796 { |
10443 | 5797 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 5798 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5799 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5800 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5801 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5802 } |
11581 | 5803 |
5804 | |
5805 | |
5806 | |
5807 | |
5808 | |
5809 | |
5810 | |
5811 | |
5812 | |
5813 | |
5814 | |
5815 | |
5816 | |
5817 | |
5818 | |
5819 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
5820 * and touch each others' private members all day long */ | |
5821 | |
5822 /** | |
5823 * @file gtkconvwin.c GTK+ Conversation Window API | |
5824 * @ingroup gtkui | |
5825 * | |
5826 * gaim | |
5827 * | |
5828 * Gaim is the legal property of its developers, whose names are too numerous | |
5829 * to list here. Please refer to the COPYRIGHT file distributed with this | |
5830 * source distribution. | |
5831 * | |
5832 * This program is free software; you can redistribute it and/or modify | |
5833 * it under the terms of the GNU General Public License as published by | |
5834 * the Free Software Foundation; either version 2 of the License, or | |
5835 * (at your option) any later version. | |
5836 * | |
5837 * This program is distributed in the hope that it will be useful, | |
5838 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
5839 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
5840 * GNU General Public License for more details. | |
5841 * | |
5842 * You should have received a copy of the GNU General Public License | |
5843 * along with this program; if not, write to the Free Software | |
5844 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
5845 * | |
5846 */ | |
5847 #include "internal.h" | |
5848 #include "gtkgaim.h" | |
5849 | |
5850 | |
5851 #include <gdk/gdkkeysyms.h> | |
5852 | |
5853 #include "account.h" | |
5854 #include "cmds.h" | |
5855 #include "debug.h" | |
5856 #include "imgstore.h" | |
5857 #include "log.h" | |
5858 #include "notify.h" | |
5859 #include "prpl.h" | |
5860 #include "request.h" | |
5861 #include "util.h" | |
5862 | |
5863 #include "gtkdnd-hints.h" | |
5864 #include "gtkblist.h" | |
5865 #include "gtkconv.h" | |
5866 #include "gtkdialogs.h" | |
5867 #include "gtkmenutray.h" | |
5868 #include "gtkpounce.h" | |
5869 #include "gtkprefs.h" | |
5870 #include "gtkprivacy.h" | |
5871 #include "gtkutils.h" | |
5872 #include "gtkstock.h" | |
5873 #include "gtkimhtml.h" | |
5874 #include "gtkimhtmltoolbar.h" | |
5875 | |
5876 static void | |
5877 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
5878 { | |
5879 gtk_widget_destroy(warn_close_dialog); | |
5880 warn_close_dialog = NULL; | |
5881 | |
5882 if (resp == GTK_RESPONSE_OK) | |
5883 gaim_gtk_conv_window_destroy(win); | |
5884 } | |
5885 | |
5886 static void | |
5887 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
5888 { | |
5889 GtkWidget *label; | |
5890 GtkWidget *vbox, *hbox; | |
5891 GtkWidget *img; | |
5892 | |
5893 g_return_if_fail(warn_close_dialog == NULL); | |
5894 | |
5895 | |
5896 warn_close_dialog = gtk_dialog_new_with_buttons( | |
5897 _("Confirm close"), | |
5898 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
5899 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
5900 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
5901 | |
5902 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
5903 GTK_RESPONSE_OK); | |
5904 | |
5905 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
5906 6); | |
5907 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
5908 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
5909 FALSE); | |
5910 | |
5911 /* Setup the outside spacing. */ | |
5912 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
5913 | |
5914 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
5915 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
5916 | |
5917 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
5918 GTK_ICON_SIZE_DIALOG); | |
5919 /* Setup the inner hbox and put the dialog's icon in it. */ | |
5920 hbox = gtk_hbox_new(FALSE, 12); | |
5921 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
5922 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
5923 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
5924 | |
5925 /* Setup the right vbox. */ | |
5926 vbox = gtk_vbox_new(FALSE, 12); | |
5927 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
5928 | |
5929 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
5930 gtk_widget_set_size_request(label, 350, -1); | |
5931 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
5932 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
5933 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
5934 | |
5935 /* Connect the signals. */ | |
5936 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
5937 G_CALLBACK(do_close), gtkwin); | |
5938 | |
5939 } | |
5940 | |
5941 /************************************************************************** | |
5942 * Callbacks | |
5943 **************************************************************************/ | |
5944 | |
5945 static gboolean | |
5946 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
5947 { | |
5948 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5949 GList *l; |
11581 | 5950 |
5951 /* If there are unread messages then show a warning dialog */ | |
5952 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
5953 l != NULL; l = l->next) | |
5954 { | |
5955 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5956 if (gaim_conversation_get_type(gtkconv->active_conv) == GAIM_CONV_TYPE_IM && |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5957 gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5958 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5959 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5960 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5961 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5962 return TRUE; |
11581 | 5963 } |
5964 } | |
5965 | |
5966 gaim_gtk_conv_window_destroy(win); | |
5967 | |
5968 return TRUE; | |
5969 } | |
5970 | |
11604 | 5971 static void |
5972 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
5973 { | |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5974 /* only allow NONE or higher priority unseen state */ |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5975 if((state==GAIM_UNSEEN_NONE && gtkconv->unseen_state!=GAIM_UNSEEN_NONE) |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5976 || state > gtkconv->unseen_state) { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5977 gtkconv->unseen_state = state; |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5978 gaim_conversation_update(gtkconv->active_conv, GAIM_CONV_UPDATE_UNSEEN); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5979 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5980 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
5981 |
11581 | 5982 /* |
5983 * When a conversation window is focused, we know the user | |
5984 * has looked at it so we know there are no longer unseen | |
5985 * messages. | |
5986 */ | |
5987 static gint | |
5988 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
5989 { | |
5990 GaimGtkWindow *win = d; | |
11604 | 5991 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
5992 | |
5993 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 5994 |
5995 return FALSE; | |
5996 } | |
5997 | |
11851 | 5998 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 5999 /* Courtesy of Galeon! */ |
6000 static void | |
6001 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6002 { | |
6003 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6004 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6005 } | |
11851 | 6006 #endif |
11581 | 6007 |
6008 static void | |
6009 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6010 { | |
6011 static GdkCursor *cursor = NULL; | |
6012 | |
6013 gtkwin->in_drag = TRUE; | |
6014 | |
6015 if (gtkwin->drag_leave_signal) { | |
6016 g_signal_handler_disconnect(G_OBJECT(widget), | |
6017 gtkwin->drag_leave_signal); | |
6018 gtkwin->drag_leave_signal = 0; | |
6019 } | |
6020 | |
6021 if (cursor == NULL) | |
6022 cursor = gdk_cursor_new(GDK_FLEUR); | |
6023 | |
6024 /* Grab the pointer */ | |
6025 gtk_grab_add(gtkwin->notebook); | |
6026 #ifndef _WIN32 | |
6027 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6028 always be true after a button press. */ | |
6029 if (!gdk_pointer_is_grabbed()) | |
6030 #endif | |
6031 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6032 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6033 NULL, cursor, GDK_CURRENT_TIME); | |
6034 } | |
6035 | |
6036 static gboolean | |
6037 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6038 { | |
6039 | |
6040 /* | |
6041 * Make sure the user moved the mouse far enough for the | |
6042 * drag to be initiated. | |
6043 */ | |
6044 if (win->in_predrag) { | |
6045 if (e->x_root < win->drag_min_x || | |
6046 e->x_root >= win->drag_max_x || | |
6047 e->y_root < win->drag_min_y || | |
6048 e->y_root >= win->drag_max_y) { | |
6049 | |
6050 win->in_predrag = FALSE; | |
6051 notebook_init_grab(win, widget); | |
6052 } | |
6053 } | |
6054 else { /* Otherwise, draw the arrows. */ | |
6055 GaimGtkWindow *dest_win; | |
6056 GtkNotebook *dest_notebook; | |
6057 GtkWidget *tab; | |
6058 gint nb_x, nb_y, page_num; | |
6059 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6060 gboolean horiz_tabs = FALSE; | |
11614 | 6061 GaimGtkConversation *gtkconv; |
6062 gboolean to_right = FALSE; | |
11581 | 6063 |
6064 /* Get the window that the cursor is over. */ | |
6065 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6066 | |
6067 if (dest_win == NULL) { | |
6068 dnd_hints_hide_all(); | |
6069 | |
6070 return TRUE; | |
6071 } | |
6072 | |
6073 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6074 | |
6075 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6076 | |
6077 arrow1_x = arrow2_x = nb_x; | |
6078 arrow1_y = arrow2_y = nb_y; | |
6079 | |
6080 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6081 e->x_root, e->y_root, &to_right); |
6082 to_right = to_right && (win != dest_win); | |
11581 | 6083 |
6084 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6085 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6086 | |
6087 horiz_tabs = TRUE; | |
6088 } | |
6089 | |
11614 | 6090 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6091 tab = gtkconv->tabby; | |
11581 | 6092 |
6093 if (horiz_tabs) { | |
6094 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6095 | |
11614 | 6096 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6097 arrow1_x += tab->allocation.width; |
6098 arrow2_x += tab->allocation.width; | |
6099 } | |
6100 | |
6101 arrow1_y = nb_y + tab->allocation.y; | |
6102 arrow2_y = nb_y + tab->allocation.y + | |
6103 tab->allocation.height; | |
6104 } else { | |
6105 arrow1_x = nb_x + tab->allocation.x; | |
6106 arrow2_x = nb_x + tab->allocation.x + | |
6107 tab->allocation.width; | |
6108 arrow1_y = arrow2_y = nb_y + tab->allocation.y + tab->allocation.height/2; | |
6109 | |
6110 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
6111 arrow1_y += tab->allocation.height; | |
6112 arrow2_y += tab->allocation.height; | |
6113 } | |
6114 } | |
6115 | |
6116 if (horiz_tabs) { | |
6117 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6118 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6119 } else { | |
6120 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6121 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6122 } | |
6123 } | |
6124 | |
6125 return TRUE; | |
6126 } | |
6127 | |
6128 static gboolean | |
6129 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6130 { | |
6131 if (win->in_drag) | |
6132 return FALSE; | |
6133 | |
6134 if (e->x_root < win->drag_min_x || | |
6135 e->x_root >= win->drag_max_x || | |
6136 e->y_root < win->drag_min_y || | |
6137 e->y_root >= win->drag_max_y) { | |
6138 | |
6139 win->in_predrag = FALSE; | |
6140 notebook_init_grab(win, widget); | |
6141 } | |
6142 | |
6143 return TRUE; | |
6144 } | |
6145 | |
6146 /* | |
6147 * THANK YOU GALEON! | |
6148 */ | |
6149 static gboolean | |
6150 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6151 { | |
6152 gint nb_x, nb_y, x_rel, y_rel; | |
6153 int tab_clicked; | |
6154 GtkWidget *page; | |
6155 GtkWidget *tab; | |
6156 | |
6157 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6158 return FALSE; | |
6159 | |
6160 | |
6161 if (win->in_drag) { | |
6162 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6163 "Already in the middle of a window drag at tab_press_cb\n"); | |
6164 return TRUE; | |
6165 } | |
6166 | |
6167 /* | |
6168 * Make sure a tab was actually clicked. The arrow buttons | |
6169 * mess things up. | |
6170 */ | |
11614 | 6171 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6172 |
6173 if (tab_clicked == -1) | |
6174 return FALSE; | |
6175 | |
6176 /* | |
6177 * Get the relative position of the press event, with regards to | |
6178 * the position of the notebook. | |
6179 */ | |
6180 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6181 | |
6182 x_rel = e->x_root - nb_x; | |
6183 y_rel = e->y_root - nb_y; | |
6184 | |
6185 /* Reset the min/max x/y */ | |
6186 win->drag_min_x = 0; | |
6187 win->drag_min_y = 0; | |
6188 win->drag_max_x = 0; | |
6189 win->drag_max_y = 0; | |
6190 | |
6191 /* Find out which tab was dragged. */ | |
6192 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6193 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6194 | |
6195 win->drag_min_x = tab->allocation.x + nb_x; | |
6196 win->drag_min_y = tab->allocation.y + nb_y; | |
6197 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6198 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6199 | |
6200 /* Make sure the click occurred in the tab. */ | |
6201 if (e->x_root < win->drag_min_x || | |
6202 e->x_root >= win->drag_max_x || | |
6203 e->y_root < win->drag_min_y || | |
6204 e->y_root >= win->drag_max_y) { | |
6205 | |
6206 return FALSE; | |
6207 } | |
6208 | |
6209 win->in_predrag = TRUE; | |
6210 win->drag_tab = tab_clicked; | |
6211 | |
6212 /* Connect the new motion signals. */ | |
6213 win->drag_motion_signal = | |
6214 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6215 G_CALLBACK(notebook_motion_cb), win); | |
6216 | |
6217 win->drag_leave_signal = | |
6218 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6219 G_CALLBACK(notebook_leave_cb), win); | |
6220 | |
6221 return FALSE; | |
6222 } | |
6223 | |
6224 static gboolean | |
6225 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6226 { | |
6227 GaimGtkWindow *dest_win; | |
6228 GaimConversation *conv; | |
6229 GaimGtkConversation *gtkconv; | |
6230 gint dest_page_num = 0; | |
6231 gboolean new_window = FALSE; | |
11614 | 6232 gboolean to_right = FALSE; |
11581 | 6233 |
6234 /* | |
6235 * Don't check to make sure that the event's window matches the | |
6236 * widget's, because we may be getting an event passed on from the | |
6237 * close button. | |
6238 */ | |
6239 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6240 return FALSE; | |
6241 | |
6242 if (gdk_pointer_is_grabbed()) { | |
6243 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6244 gtk_grab_remove(widget); | |
6245 } | |
6246 | |
6247 if (!win->in_predrag && !win->in_drag) | |
6248 return FALSE; | |
6249 | |
6250 /* Disconnect the motion signal. */ | |
6251 if (win->drag_motion_signal) { | |
6252 g_signal_handler_disconnect(G_OBJECT(widget), | |
6253 win->drag_motion_signal); | |
6254 | |
6255 win->drag_motion_signal = 0; | |
6256 } | |
6257 | |
6258 /* | |
6259 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6260 * signal. | |
6261 */ | |
6262 if (win->in_predrag) { | |
6263 win->in_predrag = FALSE; | |
6264 | |
6265 if (win->drag_leave_signal) { | |
6266 g_signal_handler_disconnect(G_OBJECT(widget), | |
6267 win->drag_leave_signal); | |
6268 | |
6269 win->drag_leave_signal = 0; | |
6270 } | |
6271 } | |
6272 | |
6273 /* If we're not in drag... */ | |
6274 /* We're perfectly normal people! */ | |
6275 if (!win->in_drag) | |
6276 return FALSE; | |
6277 | |
6278 win->in_drag = FALSE; | |
6279 | |
6280 dnd_hints_hide_all(); | |
6281 | |
6282 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6283 | |
6284 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6285 | |
6286 if (dest_win == NULL) { | |
6287 /* If the current window doesn't have any other conversations, | |
6288 * there isn't much point transferring the conv to a new window. */ | |
6289 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6290 /* Make a new window to stick this to. */ | |
6291 dest_win = gaim_gtk_conv_window_new(); | |
6292 new_window = TRUE; | |
6293 } | |
6294 } | |
6295 | |
6296 if (dest_win == NULL) | |
6297 return FALSE; | |
6298 | |
6299 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6300 "conversation-dragging", win, dest_win); | |
6301 | |
6302 /* Get the destination page number. */ | |
6303 if (!new_window) | |
6304 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6305 e->x_root, e->y_root, &to_right); |
11581 | 6306 |
6307 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6308 | |
6309 if (win == dest_win) { | |
6310 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6311 } else { | |
6312 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6313 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 6314 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 6315 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
6316 if (new_window) { | |
6317 gint win_width, win_height; | |
6318 | |
6319 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6320 &win_width, &win_height); | |
6321 | |
6322 gtk_window_move(GTK_WINDOW(dest_win->window), | |
6323 e->x_root - (win_width / 2), | |
6324 e->y_root - (win_height / 2)); | |
6325 | |
6326 gaim_gtk_conv_window_show(dest_win); | |
6327 } | |
6328 } | |
6329 | |
6330 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
6331 | |
6332 return TRUE; | |
6333 } | |
6334 | |
6335 | |
6336 static void | |
6337 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6338 gpointer user_data) | |
6339 { | |
6340 GaimGtkWindow *win; | |
6341 GaimConversation *conv; | |
6342 GaimGtkConversation *gtkconv; | |
6343 | |
6344 win = user_data; | |
6345 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6346 | |
6347 g_return_if_fail(conv != NULL); | |
6348 | |
6349 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
6350 return; | |
6351 | |
6352 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6353 | |
6354 stop_anim(NULL, gtkconv); | |
6355 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6356 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6357 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6358 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6359 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6360 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6361 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6362 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6363 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6364 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6365 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6366 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6367 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6368 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6369 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6370 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6371 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6372 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6373 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6374 /* 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
|
6375 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6376 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6377 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6378 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6379 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6380 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6381 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6382 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6383 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6384 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6385 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6386 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6387 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6388 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6389 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6390 GaimGtkWindow *win; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6391 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6392 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6393 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6394 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6395 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6396 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6397 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6398 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6399 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6400 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6401 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6402 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6403 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6404 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6405 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6406 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6407 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6408 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6409 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6410 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6411 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6412 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6413 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6414 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6415 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6416 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6417 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6418 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6419 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6420 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6421 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6422 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6423 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6424 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6425 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6426 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6427 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6428 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6429 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6430 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6431 gaim_gtkconv_get_tab_at_xy(win, event->x, event->y, NULL)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6432 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6433 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6434 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6435 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6436 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6437 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6438 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6439 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6440 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6441 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6442 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6443 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6444 item = gtk_menu_item_new_with_label("Detach this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6445 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6446 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6447 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6448 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6449 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6450 item = gtk_menu_item_new_with_label("Close this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6451 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6452 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6453 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6454 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6455 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6456 gaim_separator(menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6457 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6458 item = gtk_menu_item_new_with_label("Close other tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6459 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6460 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6461 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6462 G_CALLBACK(close_others_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6463 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6464 item = gtk_menu_item_new_with_label("Close all tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6465 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6466 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6467 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6468 G_CALLBACK(close_window), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6469 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6470 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6471 } |
11581 | 6472 |
6473 static void | |
6474 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6475 gpointer user_data) | |
6476 { | |
6477 GaimGtkWindow *win; | |
6478 GaimConversation *conv; | |
6479 GaimGtkConversation *gtkconv; | |
6480 | |
6481 win = user_data; | |
6482 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
6483 conv = gtkconv->active_conv; | |
6484 | |
6485 g_return_if_fail(conv != NULL); | |
6486 | |
6487 /* | |
6488 * Only set "unseen" to "none" if the window has focus | |
6489 */ | |
6490 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 6491 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 6492 |
6493 /* Update the menubar */ | |
6494 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6495 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
|
6496 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6497 |
11594 | 6498 generate_send_to_items(win); |
6499 | |
11604 | 6500 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 6501 |
6502 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), | |
6503 gtkconv->make_sound); | |
6504 | |
6505 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
6506 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
6507 | |
6508 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
6509 gtkconv->show_timestamps); | |
6510 | |
6511 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6512 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), | |
6513 gtkconv->u.im->show_icon); | |
11604 | 6514 |
11581 | 6515 /* |
6516 * We pause icons when they are not visible. If this icon should | |
6517 * be animated then start it back up again. | |
6518 */ | |
6519 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
6520 (gtkconv->u.im->animate)) | |
6521 start_anim(NULL, gtkconv); | |
6522 } | |
6523 | |
6524 /************************************************************************** | |
6525 * GTK+ window ops | |
6526 **************************************************************************/ | |
6527 | |
6528 GList * | |
6529 gaim_gtk_conv_windows_get_list() | |
6530 { | |
6531 return window_list; | |
6532 } | |
6533 | |
6534 GaimGtkWindow * | |
6535 gaim_gtk_conv_window_new() | |
6536 { | |
6537 GaimGtkWindow *win; | |
6538 GtkPositionType pos; | |
6539 GtkWidget *testidea; | |
6540 GtkWidget *menubar; | |
6541 | |
6542 win = g_malloc0(sizeof(GaimGtkWindow)); | |
6543 | |
6544 window_list = g_list_append(window_list, win); | |
6545 | |
6546 /* Create the window. */ | |
6547 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
6548 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
6549 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
6550 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
6551 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
6552 | |
6553 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
6554 G_CALLBACK(close_win_cb), win); | |
6555 | |
6556 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
6557 G_CALLBACK(focus_win_cb), win); | |
6558 | |
6559 /* Create the notebook. */ | |
6560 win->notebook = gtk_notebook_new(); | |
6561 | |
6562 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
6563 | |
6564 #if 0 | |
6565 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
6566 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
6567 #endif | |
6568 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
6569 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
6570 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
6571 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
6572 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
6573 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6574 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6575 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6576 |
11581 | 6577 gtk_widget_show(win->notebook); |
6578 | |
6579 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
6580 G_CALLBACK(before_switch_conv_cb), win); | |
6581 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
6582 G_CALLBACK(switch_conv_cb), win); | |
6583 | |
6584 /* Setup the tab drag and drop signals. */ | |
6585 gtk_widget_add_events(win->notebook, | |
6586 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
6587 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
6588 G_CALLBACK(notebook_press_cb), win); | |
6589 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
6590 G_CALLBACK(notebook_release_cb), win); | |
6591 | |
6592 testidea = gtk_vbox_new(FALSE, 0); | |
6593 | |
6594 /* Setup the menubar. */ | |
6595 menubar = setup_menubar(win); | |
6596 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
6597 | |
6598 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
6599 | |
6600 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
6601 | |
6602 gtk_widget_show(testidea); | |
6603 | |
6604 return win; | |
6605 } | |
6606 | |
6607 void | |
6608 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
6609 { | |
6610 window_list = g_list_remove(window_list, win); | |
6611 | |
11611 | 6612 if (win->gtkconvs) { |
6613 while (win->gtkconvs) { | |
6614 GList *nextgtk = win->gtkconvs->next; | |
6615 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
6616 GList *nextcore = gtkconv->convs->next; | |
6617 GaimConversation *conv = gtkconv->convs->data; | |
6618 gaim_conversation_destroy(conv); | |
6619 if (!nextgtk && !nextcore) | |
6620 /* we'll end up invoking ourselves when we destroy our last child */ | |
6621 /* so don't destroy ourselves right now */ | |
6622 return; | |
6623 } | |
6624 return; | |
6625 } | |
11581 | 6626 gtk_widget_destroy(win->window); |
6627 | |
6628 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
6629 | |
6630 g_free(win); | |
6631 } | |
6632 | |
6633 void | |
6634 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
6635 { | |
6636 gtk_widget_show(win->window); | |
6637 } | |
6638 | |
6639 void | |
6640 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
6641 { | |
6642 gtk_widget_hide(win->window); | |
6643 } | |
6644 | |
6645 void | |
6646 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
6647 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
6648 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 6649 } |
6650 | |
6651 void | |
6652 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6653 { | |
6654 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
6655 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
6656 gtkconv->tab_cont)); | |
6657 } | |
6658 | |
6659 void | |
6660 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6661 { | |
6662 GaimConversation *conv = gtkconv->active_conv; | |
6663 GaimGtkConversation *focus_gtkconv; | |
6664 GtkWidget *tabby, *menu_tabby; | |
6665 GtkWidget *tab_cont = gtkconv->tab_cont; | |
6666 GtkWidget *close_image; | |
6667 GaimConversationType conv_type; | |
6668 const char *name; | |
6669 const gchar *tmp_lab; | |
6670 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 6671 gboolean tabs_side = FALSE; |
6672 gint angle = 0; | |
11581 | 6673 |
6674 name = gaim_conversation_get_name(conv); | |
6675 conv_type = gaim_conversation_get_type(conv); | |
6676 | |
6677 | |
6678 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
6679 gtkconv->win = win; | |
6680 | |
11619 | 6681 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
6682 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
6683 tabs_side = TRUE; | |
6684 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
6685 angle = 90; | |
6686 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6687 angle = 270; | |
6688 | |
6689 if (angle) | |
6690 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
6691 else | |
6692 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 6693 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
6694 | |
6695 /* Close button. */ | |
6696 gtkconv->close = gtk_button_new(); | |
6697 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
6698 if (gtk_check_version(2, 4, 2) == NULL) { | |
6699 /* Need to account for extra padding around the gtkbutton */ | |
6700 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
6701 "focus-line-width", &focus_width, | |
6702 "focus-padding", &focus_pad, | |
6703 NULL); | |
6704 close_button_width += (focus_width + focus_pad) * 2; | |
6705 close_button_height += (focus_width + focus_pad) * 2; | |
6706 } | |
6707 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
6708 close_button_width, close_button_height); | |
6709 | |
6710 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
6711 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
6712 gtk_widget_show(close_image); | |
6713 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
6714 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
6715 _("Close conversation"), NULL); | |
6716 | |
6717 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
6718 G_CALLBACK(close_conv_cb), gtkconv); | |
6719 | |
11851 | 6720 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6721 /* |
6722 * I love Galeon. They have a fix for that stupid annoying visible | |
6723 * border bug. I love you guys! -- ChipX86 | |
6724 */ | |
11851 | 6725 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 6726 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
6727 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 6728 #endif |
11581 | 6729 |
6730 /* Status icon. */ | |
6731 gtkconv->icon = gtk_image_new(); | |
6732 gtkconv->menu_icon = gtk_image_new(); | |
6733 update_tab_icon(conv); | |
6734 | |
6735 /* Tab label. */ | |
6736 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 6737 |
11581 | 6738 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 6739 if (!angle) |
6740 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 6741 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 6742 if (tabs_side) { |
6743 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
6744 } | |
6745 if (angle) | |
6746 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 6747 #endif |
6748 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6749 #if 0 | |
6750 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
6751 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
6752 #endif | |
6753 | |
6754 /* Pack it all together. */ | |
11619 | 6755 if (angle == 90) |
6756 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
6757 else | |
6758 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 6759 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
6760 FALSE, FALSE, 0); | |
6761 | |
6762 gtk_widget_show_all(gtkconv->icon); | |
6763 gtk_widget_show_all(gtkconv->menu_icon); | |
6764 | |
6765 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
6766 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
6767 gtk_widget_show(gtkconv->tab_label); | |
6768 gtk_widget_show(gtkconv->menu_label); | |
6769 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
6770 | |
11619 | 6771 if (angle == 90) |
6772 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
6773 else | |
6774 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 6775 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
6776 gtk_widget_show(gtkconv->close); | |
6777 | |
6778 gtk_widget_show(tabby); | |
6779 gtk_widget_show(menu_tabby); | |
6780 | |
6781 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
6782 gaim_gtkconv_update_buddy_icon(conv); | |
6783 | |
6784 /* Add this pane to the conversation's notebook. */ | |
6785 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 6786 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 6787 |
6788 | |
6789 gtk_widget_show(tab_cont); | |
6790 | |
6791 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
6792 /* Er, bug in notebooks? Switch to the page manually. */ | |
6793 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
6794 | |
6795 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6796 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6797 } else | |
6798 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
6799 | |
6800 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
6801 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
6802 gtk_widget_grab_focus(focus_gtkconv->entry); | |
6803 | |
6804 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 6805 update_send_to_selection(win); |
11581 | 6806 } |
6807 | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6808 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6809 private_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv, gboolean destroy_empty) |
11581 | 6810 { |
6811 unsigned int index; | |
6812 GaimConversationType conv_type; | |
6813 | |
6814 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
6815 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
6816 | |
6817 g_object_ref(gtkconv->tab_cont); | |
6818 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
6819 | |
6820 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
6821 | |
6822 /* go back to tabless if need be */ | |
6823 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
6824 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
6825 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
6826 } | |
6827 | |
6828 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 6829 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6830 if (destroy_empty && !win->gtkconvs) |
11582 | 6831 gaim_gtk_conv_window_destroy(win); |
11581 | 6832 } |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6833 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6834 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6835 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6836 private_remove_gtkconv(win, gtkconv, TRUE); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6837 } |
11581 | 6838 |
6839 GaimGtkConversation * | |
6840 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
6841 { | |
6842 GtkWidget *tab_cont; | |
6843 | |
6844 if (index == -1) | |
6845 index = 0; | |
6846 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 6847 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 6848 } |
6849 | |
6850 GaimGtkConversation * | |
6851 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
6852 { | |
6853 int index; | |
6854 GtkWidget *tab_cont; | |
6855 | |
6856 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
6857 if (index == -1) | |
6858 index = 0; | |
6859 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
6860 if (!tab_cont) | |
6861 return NULL; | |
6862 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
6863 } | |
6864 | |
6865 | |
6866 GaimConversation * | |
6867 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
6868 { | |
6869 GaimGtkConversation *gtkconv; | |
6870 | |
6871 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
6872 return gtkconv ? gtkconv->active_conv : NULL; | |
6873 } | |
6874 | |
6875 gboolean | |
6876 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
6877 { | |
6878 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
6879 } | |
6880 | |
6881 gboolean | |
6882 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
6883 { | |
6884 gboolean has_focus = FALSE; | |
6885 | |
6886 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
6887 | |
6888 return has_focus; | |
6889 } | |
6890 | |
6891 GaimGtkWindow * | |
6892 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
6893 { | |
6894 GaimGtkWindow *win; | |
6895 GdkWindow *gdkwin; | |
6896 GList *l; | |
6897 | |
6898 gdkwin = gdk_window_at_pointer(&x, &y); | |
6899 | |
6900 if (gdkwin) | |
6901 gdkwin = gdk_window_get_toplevel(gdkwin); | |
6902 | |
6903 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
6904 win = l->data; | |
6905 | |
6906 if (gdkwin == win->window->window) | |
6907 return win; | |
6908 } | |
6909 | |
6910 return NULL; | |
6911 } | |
6912 | |
6913 GList * | |
6914 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
6915 { | |
6916 return win->gtkconvs; | |
6917 } | |
6918 | |
6919 guint | |
6920 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
6921 { | |
6922 return g_list_length(win->gtkconvs); | |
6923 } | |
6924 | |
6925 GaimGtkWindow * | |
6926 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
6927 { | |
6928 GList *wins, *convs; | |
6929 GaimGtkWindow *win; | |
6930 GaimGtkConversation *conv; | |
6931 | |
6932 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
6933 return NULL; | |
6934 | |
6935 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
6936 win = wins->data; | |
6937 | |
6938 for (convs = win->gtkconvs; | |
6939 convs != NULL; | |
6940 convs = convs->next) { | |
6941 | |
6942 conv = convs->data; | |
6943 | |
6944 if (gaim_conversation_get_type(conv->active_conv) == type) | |
6945 return win; | |
6946 } | |
6947 } | |
6948 | |
6949 return NULL; | |
6950 } | |
6951 | |
6952 GaimGtkWindow * | |
6953 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
6954 { | |
6955 GList *wins, *convs; | |
6956 GaimGtkWindow *win; | |
6957 GaimGtkConversation *conv; | |
6958 | |
6959 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
6960 return NULL; | |
6961 | |
6962 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
6963 wins != NULL; | |
6964 wins = wins->prev) { | |
6965 | |
6966 win = wins->data; | |
6967 | |
6968 for (convs = win->gtkconvs; | |
6969 convs != NULL; | |
6970 convs = convs->next) { | |
6971 | |
6972 conv = convs->data; | |
6973 | |
6974 if (gaim_conversation_get_type(conv->active_conv) == type) | |
6975 return win; | |
6976 } | |
6977 } | |
6978 | |
6979 return NULL; | |
6980 } | |
6981 | |
6982 | |
6983 /************************************************************************** | |
6984 * Conversation placement functions | |
6985 **************************************************************************/ | |
6986 typedef struct | |
6987 { | |
6988 char *id; | |
6989 char *name; | |
6990 GaimConvPlacementFunc fnc; | |
6991 | |
6992 } ConvPlacementData; | |
6993 | |
6994 static GList *conv_placement_fncs = NULL; | |
6995 static GaimConvPlacementFunc place_conv = NULL; | |
6996 | |
6997 /* This one places conversations in the last made window. */ | |
6998 static void | |
6999 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7000 { | |
7001 GaimGtkWindow *win; | |
7002 | |
7003 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7004 win = l ? l->data : NULL;; | |
7005 | |
7006 if (win == NULL) { | |
7007 win = gaim_gtk_conv_window_new(); | |
7008 | |
7009 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7010 gaim_gtk_conv_window_show(win); | |
7011 } else { | |
7012 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7013 } | |
7014 } | |
7015 | |
7016 /* This one places conversations in the last made window of the same type. */ | |
7017 static void | |
7018 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7019 { | |
7020 GaimGtkWindow *win; | |
7021 | |
7022 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7023 | |
7024 if (win == NULL) { | |
7025 win = gaim_gtk_conv_window_new(); | |
7026 | |
7027 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7028 gaim_gtk_conv_window_show(win); | |
7029 } else | |
7030 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7031 } | |
7032 | |
7033 /* This one places each conversation in its own window. */ | |
7034 static void | |
7035 conv_placement_new_window(GaimGtkConversation *conv) | |
7036 { | |
7037 GaimGtkWindow *win; | |
7038 | |
7039 win = gaim_gtk_conv_window_new(); | |
7040 | |
7041 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7042 | |
7043 gaim_gtk_conv_window_show(win); | |
7044 } | |
7045 | |
7046 static GaimGroup * | |
7047 conv_get_group(GaimGtkConversation *conv) | |
7048 { | |
7049 GaimGroup *group = NULL; | |
7050 | |
7051 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7052 GaimBuddy *buddy; | |
7053 | |
7054 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7055 gaim_conversation_get_name(conv->active_conv)); | |
7056 | |
7057 if (buddy != NULL) | |
12088 | 7058 group = gaim_buddy_get_group(buddy); |
11581 | 7059 |
7060 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7061 GaimChat *chat; | |
7062 | |
7063 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7064 gaim_conversation_get_name(conv->active_conv)); | |
7065 | |
7066 if (chat != NULL) | |
7067 group = gaim_chat_get_group(chat); | |
7068 } | |
7069 | |
7070 return group; | |
7071 } | |
7072 | |
7073 /* | |
7074 * This groups things by, well, group. Buddies from groups will always be | |
7075 * grouped together, and a buddy from a group not belonging to any currently | |
7076 * open windows will get a new window. | |
7077 */ | |
7078 static void | |
7079 conv_placement_by_group(GaimGtkConversation *conv) | |
7080 { | |
7081 GaimConversationType type; | |
7082 GaimGroup *group = NULL; | |
7083 GList *wl, *cl; | |
7084 | |
7085 type = gaim_conversation_get_type(conv->active_conv); | |
7086 | |
7087 group = conv_get_group(conv); | |
7088 | |
7089 /* Go through the list of IMs and find one with this group. */ | |
7090 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7091 GaimGtkWindow *win2; | |
7092 GaimGtkConversation *conv2; | |
7093 GaimGroup *group2 = NULL; | |
7094 | |
7095 win2 = wl->data; | |
7096 | |
7097 for (cl = win2->gtkconvs; | |
7098 cl != NULL; | |
7099 cl = cl->next) { | |
7100 conv2 = cl->data; | |
7101 | |
7102 group2 = conv_get_group(conv2); | |
7103 | |
7104 if (group == group2) { | |
7105 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7106 | |
7107 return; | |
7108 } | |
7109 } | |
7110 } | |
7111 | |
7112 /* Make a new window. */ | |
7113 conv_placement_new_window(conv); | |
7114 } | |
7115 | |
7116 /* This groups things by account. Otherwise, the same semantics as above */ | |
7117 static void | |
7118 conv_placement_by_account(GaimGtkConversation *conv) | |
7119 { | |
7120 GaimConversationType type; | |
7121 GList *wins, *convs; | |
7122 GaimAccount *account; | |
7123 | |
7124 account = gaim_conversation_get_account(conv->active_conv); | |
7125 type = gaim_conversation_get_type(conv->active_conv); | |
7126 | |
7127 /* Go through the list of IMs and find one with this group. */ | |
7128 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7129 GaimGtkWindow *win2; | |
7130 GaimGtkConversation *conv2; | |
7131 | |
7132 win2 = wins->data; | |
7133 | |
7134 for (convs = win2->gtkconvs; | |
7135 convs != NULL; | |
7136 convs = convs->next) { | |
7137 conv2 = convs->data; | |
7138 | |
7139 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7140 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7141 return; | |
7142 } | |
7143 } | |
7144 } | |
7145 | |
7146 /* Make a new window. */ | |
7147 conv_placement_new_window(conv); | |
7148 } | |
7149 | |
7150 static ConvPlacementData * | |
7151 get_conv_placement_data(const char *id) | |
7152 { | |
7153 ConvPlacementData *data = NULL; | |
7154 GList *n; | |
7155 | |
7156 for (n = conv_placement_fncs; n; n = n->next) { | |
7157 data = n->data; | |
7158 if (!strcmp(data->id, id)) | |
7159 return data; | |
7160 } | |
7161 | |
7162 return NULL; | |
7163 } | |
7164 | |
7165 static void | |
7166 add_conv_placement_fnc(const char *id, const char *name, | |
7167 GaimConvPlacementFunc fnc) | |
7168 { | |
7169 ConvPlacementData *data; | |
7170 | |
7171 data = g_new(ConvPlacementData, 1); | |
7172 | |
7173 data->id = g_strdup(id); | |
7174 data->name = g_strdup(name); | |
7175 data->fnc = fnc; | |
7176 | |
7177 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7178 } | |
7179 | |
7180 static void | |
7181 ensure_default_funcs(void) | |
7182 { | |
7183 if (conv_placement_fncs == NULL) { | |
7184 add_conv_placement_fnc("last", _("Last created window"), | |
7185 conv_placement_last_created_win); | |
7186 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7187 conv_placement_last_created_win_type); | |
7188 add_conv_placement_fnc("new", _("New window"), | |
7189 conv_placement_new_window); | |
7190 add_conv_placement_fnc("group", _("By group"), | |
7191 conv_placement_by_group); | |
7192 add_conv_placement_fnc("account", _("By account"), | |
7193 conv_placement_by_account); | |
7194 } | |
7195 } | |
7196 | |
7197 GList * | |
7198 gaim_gtkconv_placement_get_options(void) | |
7199 { | |
7200 GList *n, *list = NULL; | |
7201 ConvPlacementData *data; | |
7202 | |
7203 ensure_default_funcs(); | |
7204 | |
7205 for (n = conv_placement_fncs; n; n = n->next) { | |
7206 data = n->data; | |
7207 list = g_list_append(list, data->name); | |
7208 list = g_list_append(list, data->id); | |
7209 } | |
7210 | |
7211 return list; | |
7212 } | |
7213 | |
7214 | |
7215 void | |
7216 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
7217 GaimConvPlacementFunc fnc) | |
7218 { | |
7219 g_return_if_fail(id != NULL); | |
7220 g_return_if_fail(name != NULL); | |
7221 g_return_if_fail(fnc != NULL); | |
7222 | |
7223 ensure_default_funcs(); | |
7224 | |
7225 add_conv_placement_fnc(id, name, fnc); | |
7226 } | |
7227 | |
7228 void | |
7229 gaim_gtkconv_placement_remove_fnc(const char *id) | |
7230 { | |
7231 ConvPlacementData *data = get_conv_placement_data(id); | |
7232 | |
7233 if (data == NULL) | |
7234 return; | |
7235 | |
7236 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
7237 | |
7238 g_free(data->id); | |
7239 g_free(data->name); | |
7240 g_free(data); | |
7241 } | |
7242 | |
7243 const char * | |
7244 gaim_gtkconv_placement_get_name(const char *id) | |
7245 { | |
7246 ConvPlacementData *data; | |
7247 | |
7248 ensure_default_funcs(); | |
7249 | |
7250 data = get_conv_placement_data(id); | |
7251 | |
7252 if (data == NULL) | |
7253 return NULL; | |
7254 | |
7255 return data->name; | |
7256 } | |
7257 | |
7258 GaimConvPlacementFunc | |
7259 gaim_gtkconv_placement_get_fnc(const char *id) | |
7260 { | |
7261 ConvPlacementData *data; | |
7262 | |
7263 ensure_default_funcs(); | |
7264 | |
7265 data = get_conv_placement_data(id); | |
7266 | |
7267 if (data == NULL) | |
7268 return NULL; | |
7269 | |
7270 return data->fnc; | |
7271 } | |
7272 | |
7273 void | |
7274 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
7275 { | |
7276 g_return_if_fail(func != NULL); | |
7277 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7278 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7279 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7280 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7281 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7282 place_conv = NULL; |
11581 | 7283 } |
7284 | |
7285 GaimConvPlacementFunc | |
7286 gaim_gtkconv_placement_get_current_func(void) | |
7287 { | |
7288 return place_conv; | |
7289 } | |
7290 | |
7291 void | |
7292 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
7293 { | |
7294 if (place_conv) | |
7295 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7296 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7297 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7298 } |