Mercurial > pidgin
annotate src/gtkconv.c @ 11219:0fabe3892b97
[gaim-migrate @ 13351]
temporary removal of crazychat sources
committer: Tailor Script <tailor@pidgin.im>
author | Charlie Stockman <chuckleberry> |
---|---|
date | Tue, 09 Aug 2005 07:22:41 +0000 |
parents | e552095ec599 |
children | 409d6a11da51 |
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 "sound.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
51 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
52 |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
53 #include "gtkdnd-hints.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
54 #include "gtkblist.h" |
5717 | 55 #include "gtkconv.h" |
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" |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
60 #include "gtkpounce.h" |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
61 #include "gtkprefs.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
62 #include "gtkprivacy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
63 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
64 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
65 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
66 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
67 |
10175 | 68 #define SEND_COLOR "#16569E" |
69 #define RECV_COLOR "#A82F2F" | |
7854 | 70 |
10108 | 71 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
72 | |
73 /* These colors come from the default GNOME palette */ | |
74 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
75 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
76 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
77 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
78 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
79 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
80 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
81 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
82 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
83 {0, 34816, 17920, 12544}, /* Red Dark */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
84 {0, 49408, 14336, 8704}, /* Red Shadow */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
85 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
86 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
87 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
88 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
89 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
90 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
91 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
92 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
93 {0, 57088, 16896, 7680}, /* Accent Red */ |
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
94 {0, 39168, 0, 0}, /* Accent Red Dark */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
95 {0, 60928, 54784, 32768}, /* Accent Yellow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
96 {0, 17920, 40960, 17920}, /* Accent Green */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
97 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 98 }; |
6291 | 99 |
4359 | 100 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
101 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
102 typedef struct |
4359 | 103 { |
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 |
116 /* Prototypes. <-- because Paco-Paco hates this comment. */ | |
10810 | 117 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
118 static GList *generate_invite_user_names(GaimConnection *gc); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
119 static void add_chat_buddy_common(GaimConversation *conv, |
9554 | 120 const char *name); |
9605 | 121 static gboolean tab_complete(GaimConversation *conv); |
10810 | 122 static void update_typing_icon(GaimGtkConversation *gtkconv); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
123 static gboolean update_send_as_selection(GaimConvWindow *win); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
124 static char *item_factory_translate_func (const char *path, gpointer func_data); |
4359 | 125 |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
126 static void |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
127 do_close(GtkWidget *w, int resp, GaimConvWindow *win) |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
128 { |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
129 gtk_widget_destroy(warn_close_dialog); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
130 warn_close_dialog = NULL; |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
131 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
132 if (resp == GTK_RESPONSE_OK) |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
133 gaim_conv_window_destroy(win); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
134 } |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
135 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
136 static void build_warn_close_dialog(GaimConvWindow *win) |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
137 { |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
138 GaimGtkWindow *gtkwin; |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
139 GtkWidget *label; |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
140 GtkWidget *vbox, *hbox; |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
141 GtkWidget *img; |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
142 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
143 g_return_if_fail(warn_close_dialog == NULL); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
144 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
145 gtkwin = GAIM_GTK_WINDOW(win); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
146 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
147 warn_close_dialog = gtk_dialog_new_with_buttons( |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
148 _("Confirm close"), |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
149 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
150 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
151 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
152 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
153 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
154 GTK_RESPONSE_OK); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
155 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
156 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
157 6); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
158 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
159 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
160 FALSE); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
161 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
162 /* Setup the outside spacing. */ |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
163 vbox = GTK_DIALOG(warn_close_dialog)->vbox; |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
164 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
165 gtk_box_set_spacing(GTK_BOX(vbox), 12); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
166 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
167 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
168 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
169 GTK_ICON_SIZE_DIALOG); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
170 /* Setup the inner hbox and put the dialog's icon in it. */ |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
171 hbox = gtk_hbox_new(FALSE, 12); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
172 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
173 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
174 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
175 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
176 /* Setup the right vbox. */ |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
177 vbox = gtk_vbox_new(FALSE, 12); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
178 gtk_container_add(GTK_CONTAINER(hbox), vbox); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
179 |
11209
e552095ec599
[gaim-migrate @ 13340]
Richard Laager <rlaager@wiktel.com>
parents:
11206
diff
changeset
|
180 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
181 gtk_widget_set_size_request(label, 350, -1); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
182 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
183 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
184 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
185 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
186 gaim_gtk_prefs_checkbox(_("Warn me when I close the window with unread messages"), |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
187 "/gaim/gtk/conversations/warn_on_unread_close", vbox); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
188 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
189 /* Connect the signals. */ |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
190 g_signal_connect(G_OBJECT(warn_close_dialog), "response", |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
191 G_CALLBACK(do_close), win); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
192 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
193 } |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
194 |
4359 | 195 /************************************************************************** |
196 * Callbacks | |
197 **************************************************************************/ | |
198 static gint | |
199 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
200 { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
201 GaimConvWindow *win = (GaimConvWindow *)d; |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
202 |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
203 if (gaim_prefs_get_bool( |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
204 "/gaim/gtk/conversations/warn_on_unread_close")) |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
205 { |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
206 GList *l; |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
207 for (l = gaim_conv_window_get_conversations(win); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
208 l != NULL; l = l->next) |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
209 { |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
210 GaimConversation *conv = l->data; |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
211 if (gaim_conversation_get_type(conv) |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
212 == GAIM_CONV_IM |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
213 && gaim_conversation_get_unseen(conv) |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
214 == GAIM_UNSEEN_TEXT) |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
215 { |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
216 build_warn_close_dialog(win); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
217 gtk_widget_show_all(warn_close_dialog); |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
218 |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
219 return TRUE; |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
220 } |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
221 } |
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
222 } |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
223 gaim_conv_window_destroy(win); |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
224 |
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
225 return TRUE; |
4359 | 226 } |
227 | |
10971 | 228 /* |
229 * When a conversation window is focused, we know the user | |
230 * has looked at it so we know there are no longer unseen | |
231 * messages. | |
232 */ | |
233 static gint | |
234 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
235 { | |
236 GaimConvWindow *win = (GaimConvWindow *)d; | |
237 GaimConversation *conv = gaim_conv_window_get_active_conversation(win); | |
238 | |
239 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE); | |
240 | |
241 return FALSE; | |
242 } | |
243 | |
4359 | 244 static gint |
10810 | 245 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 246 { |
10810 | 247 GList *list = g_list_copy(gtkconv->convs), *l; |
248 | |
249 l = list; | |
250 while (l) { | |
251 GaimConversation *conv = l->data; | |
252 gaim_conversation_destroy(conv); | |
253 l = l->next; | |
254 } | |
255 | |
256 g_list_free(list); | |
257 | |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
258 return TRUE; |
4359 | 259 } |
260 | |
8914 | 261 static gboolean |
10810 | 262 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 263 { |
10810 | 264 GaimConversation *conv = gtkconv->active_conv; |
9048 | 265 GaimConvWindow *win = gaim_conversation_get_window(conv); |
10377 | 266 |
8914 | 267 if (!GTK_WIDGET_VISIBLE(w)) |
268 return FALSE; | |
269 | |
270 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
271 return FALSE; | |
272 | |
9048 | 273 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the tab bar |
274 * will fit, but then I don't want new windows taking up the entire screen. I check to see if there is only one | |
275 * conversation in the window. This way we'll be setting new windows to the size of the last resized new window. */ | |
276 | |
8914 | 277 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
278 { | |
10175 | 279 if (w == gtkconv->imhtml && (gaim_conv_window_get_conversation_count(win) == 1)) |
8914 | 280 { |
281 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_width", allocation->width); | |
10377 | 282 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_height", allocation->height); |
8914 | 283 } |
284 if (w == gtkconv->entry) | |
285 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
286 } | |
287 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
288 { | |
10175 | 289 if (w == gtkconv->imhtml && (gaim_conv_window_get_conversation_count(win) == 1)) |
8914 | 290 { |
291 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_width", allocation->width); | |
10377 | 292 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_height", allocation->height); |
8914 | 293 } |
294 if (w == gtkconv->entry) | |
295 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
296 } | |
297 | |
298 return FALSE; | |
299 } | |
300 | |
7446
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
301 /* Courtesy of Galeon! */ |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
302 static void |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
303 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
304 { |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
305 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
306 gtk_widget_set_state(widget, GTK_STATE_NORMAL); |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
307 } |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
308 |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
309 static void |
10810 | 310 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
311 { |
10810 | 312 GaimConversation *conv = c->active_conv; |
10666 | 313 |
10665 | 314 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
315 { |
9025 | 316 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_formatting")) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
317 { |
9025 | 318 char *color; |
319 GdkColor fg_color, bg_color; | |
320 | |
10666 | 321 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold") != GTK_IMHTML(c->entry)->edit.bold) |
9025 | 322 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
323 | |
10666 | 324 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic") != GTK_IMHTML(c->entry)->edit.italic) |
9025 | 325 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
326 | |
10666 | 327 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline") != GTK_IMHTML(c->entry)->edit.underline) |
9025 | 328 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
329 | |
330 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), | |
331 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); | |
332 | |
10665 | 333 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
9025 | 334 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
335 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
9025 | 336 |
337 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) | |
338 { | |
339 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), | |
340 &fg_color); | |
341 color = g_strdup_printf("#%02x%02x%02x", | |
342 fg_color.red / 256, | |
343 fg_color.green / 256, | |
344 fg_color.blue / 256); | |
345 } | |
346 else | |
347 color = g_strdup(""); | |
348 | |
8061 | 349 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
350 g_free(color); | |
9025 | 351 |
10665 | 352 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
9025 | 353 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
354 { | |
355 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), | |
356 &bg_color); | |
357 color = g_strdup_printf("#%02x%02x%02x", | |
358 bg_color.red / 256, | |
359 bg_color.green / 256, | |
360 bg_color.blue / 256); | |
361 } | |
362 else | |
363 color = g_strdup(""); | |
364 | |
8061 | 365 gtk_imhtml_toggle_backcolor(GTK_IMHTML(c->entry), color); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
366 g_free(color); |
8061 | 367 } |
8677 | 368 |
9025 | 369 |
10665 | 370 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 371 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
372 else | |
373 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 374 } |
375 } | |
9130 | 376 |
377 static const char * | |
378 gaim_gtk_get_cmd_prefix(void) | |
379 { | |
380 return "/"; | |
381 } | |
382 | |
9167 | 383 static GaimCmdRet |
9829 | 384 say_command_cb(GaimConversation *conv, |
385 const char *cmd, char **args, char **error, void *data) | |
386 { | |
387 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
388 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); | |
389 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
390 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); | |
391 | |
392 return GAIM_CMD_RET_OK; | |
393 } | |
394 | |
395 static GaimCmdRet | |
9167 | 396 me_command_cb(GaimConversation *conv, |
9597 | 397 const char *cmd, char **args, char **error, void *data) |
9167 | 398 { |
399 char *tmp; | |
400 | |
401 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 402 |
9167 | 403 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
404 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); | |
405 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
406 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); | |
407 | |
408 g_free(tmp); | |
409 return GAIM_CMD_RET_OK; | |
410 } | |
411 | |
9212 | 412 static GaimCmdRet |
413 debug_command_cb(GaimConversation *conv, | |
9597 | 414 const char *cmd, char **args, char **error, void *data) |
9212 | 415 { |
416 char *tmp, *markup; | |
417 GaimCmdStatus status; | |
418 | |
419 if (!g_ascii_strcasecmp(args[0], "version")) { | |
420 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
|
421 markup = g_markup_escape_text(tmp, -1); |
9212 | 422 |
423 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
424 | |
425 g_free(tmp); | |
426 g_free(markup); | |
427 return status; | |
428 } else { | |
429 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
430 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
431 return GAIM_CMD_STATUS_OK; | |
432 } | |
433 } | |
434 | |
9213 | 435 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
436 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
437 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
438 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
439 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
440 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
441 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
442 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
443 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
444 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
445 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
446 } |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
447 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
448 static GaimCmdRet |
9213 | 449 help_command_cb(GaimConversation *conv, |
9597 | 450 const char *cmd, char **args, char **error, void *data) |
9213 | 451 { |
9597 | 452 GList *l, *text; |
9213 | 453 GString *s; |
9597 | 454 |
455 if (args[0] != NULL) { | |
456 s = g_string_new(""); | |
457 text = gaim_cmd_help(conv, args[0]); | |
458 | |
459 if (text) { | |
460 for (l = text; l; l = l->next) | |
461 if (l->next) | |
9816 | 462 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 463 else |
9816 | 464 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 465 } else { |
466 g_string_append(s, _("No such command (in this context).")); | |
467 } | |
468 } else { | |
469 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
470 "The following commands are available in this context:\n")); | |
471 | |
472 text = gaim_cmd_list(conv); | |
473 for (l = text; l; l = l->next) | |
9213 | 474 if (l->next) |
9597 | 475 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 476 else |
9597 | 477 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 478 } |
479 | |
480 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
481 g_string_free(s, TRUE); | |
482 | |
483 return GAIM_CMD_STATUS_OK; | |
484 } | |
485 | |
4359 | 486 static void |
9374 | 487 send_history_add(GaimConversation *conv, const char *message) |
488 { | |
489 GList *first; | |
490 | |
491 first = g_list_first(conv->send_history); | |
492 | |
493 if (first->data) | |
494 g_free(first->data); | |
495 | |
496 first->data = g_strdup(message); | |
497 | |
498 conv->send_history = g_list_prepend(first, NULL); | |
499 } | |
500 | |
9832 | 501 static gboolean |
502 check_for_and_do_command(GaimConversation *conv) | |
503 { | |
504 GaimGtkConversation *gtkconv; | |
505 char *cmd; | |
506 const char *prefix; | |
507 GaimAccount *account; | |
508 GtkTextIter start; | |
509 | |
510 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
511 account = gaim_conversation_get_account(conv); | |
512 prefix = gaim_gtk_get_cmd_prefix(); | |
513 | |
514 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
515 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
516 | |
517 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
518 && !gtk_text_iter_get_child_anchor(&start)) { | |
519 GaimCmdStatus status; | |
520 char *error, *cmdline, *markup, *send_history; | |
521 GtkTextIter end; | |
522 | |
523 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
524 send_history_add(conv, send_history); | |
525 g_free(send_history); | |
526 | |
527 cmdline = cmd + strlen(prefix); | |
528 | |
529 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
530 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
531 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
532 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
533 g_free(cmd); | |
534 g_free(markup); | |
535 | |
536 switch (status) { | |
537 case GAIM_CMD_STATUS_OK: | |
538 return TRUE; | |
539 case GAIM_CMD_STATUS_NOT_FOUND: | |
540 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
541 gaim_conversation_write(conv, "", _("No such command."), | |
542 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
543 | |
544 return TRUE; | |
545 } | |
546 return FALSE; | |
547 case GAIM_CMD_STATUS_WRONG_ARGS: | |
548 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
549 "to that command."), | |
550 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
551 return TRUE; | |
552 case GAIM_CMD_STATUS_FAILED: | |
553 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
554 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
555 if(error) | |
556 g_free(error); | |
557 return TRUE; | |
558 case GAIM_CMD_STATUS_WRONG_TYPE: | |
559 if(gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
10843 | 560 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 561 GAIM_MESSAGE_NO_LOG, time(NULL)); |
562 else | |
10843 | 563 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 564 GAIM_MESSAGE_NO_LOG, time(NULL)); |
565 return TRUE; | |
566 case GAIM_CMD_STATUS_WRONG_PRPL: | |
567 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
568 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
569 return TRUE; | |
570 } | |
571 } | |
572 | |
573 g_free(cmd); | |
574 return FALSE; | |
575 } | |
576 | |
9374 | 577 static void |
10810 | 578 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 579 { |
10810 | 580 GaimConversation *conv = gtkconv->active_conv; |
8655 | 581 GaimAccount *account; |
8677 | 582 GaimConnection *gc; |
8448 | 583 char *buf, *clean; |
4359 | 584 |
8655 | 585 account = gaim_conversation_get_account(conv); |
9130 | 586 |
9471 | 587 if (!gaim_account_is_connected(account)) |
588 return; | |
589 | |
9474 | 590 if ((gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) && |
591 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) | |
9471 | 592 return; |
593 | |
9832 | 594 if (check_for_and_do_command(conv)) { |
595 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
10810 | 596 default_formatize(gtkconv); |
9832 | 597 return; |
9130 | 598 } |
599 | |
8442 | 600 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 601 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 602 |
4359 | 603 gtk_widget_grab_focus(gtkconv->entry); |
604 | |
8448 | 605 if (strlen(clean) == 0) { |
606 g_free(clean); | |
4359 | 607 return; |
608 } | |
609 | |
8677 | 610 gc = gaim_account_get_connection(account); |
10665 | 611 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 612 char **bufs; |
613 int i; | |
614 | |
615 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
616 for (i = 0; bufs[i]; i++) { | |
9374 | 617 send_history_add(conv, bufs[i]); |
8677 | 618 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
619 gaim_conv_im_send(GAIM_CONV_IM(conv), bufs[i]); | |
620 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
621 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), bufs[i]); | |
622 } | |
623 | |
624 g_strfreev(bufs); | |
625 | |
626 } else { | |
9374 | 627 send_history_add(conv, buf); |
8677 | 628 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
629 gaim_conv_im_send(GAIM_CONV_IM(conv), buf); | |
630 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
631 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), buf); | |
632 } | |
4359 | 633 |
8677 | 634 g_free(clean); |
4359 | 635 g_free(buf); |
636 | |
8061 | 637 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
10810 | 638 default_formatize(gtkconv); |
4359 | 639 } |
640 | |
641 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
642 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 643 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
644 GaimAccount *account; |
4359 | 645 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
646 GaimConversation *conv = gtkconv->active_conv; |
4359 | 647 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
648 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
649 name = gaim_conversation_get_name(conv); |
7879 | 650 |
651 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
7859 | 652 GaimBuddy *b; |
653 | |
654 b = gaim_find_buddy(account, name); | |
655 if (b != NULL) | |
9730 | 656 gaim_gtkdialogs_remove_buddy(b); |
7859 | 657 else if (account != NULL && gaim_account_is_connected(account)) |
658 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
7879 | 659 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
7859 | 660 GaimChat *c; |
661 | |
662 c = gaim_blist_find_chat(account, name); | |
663 if (c != NULL) | |
9730 | 664 gaim_gtkdialogs_remove_chat(c); |
7859 | 665 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 666 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 667 } |
4359 | 668 |
669 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
670 } | |
671 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
672 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 673 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
674 GaimConversation *conv = gtkconv->active_conv; |
7975 | 675 GaimPluginProtocolInfo *prpl_info = NULL; |
676 GaimConnection *gc; | |
677 | |
678 if ((gc = gaim_conversation_get_gc(conv))) { | |
679 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
680 | |
681 /* | |
682 * If there are special needs for getting info on users in | |
683 * buddy chat "rooms"... | |
684 */ | |
685 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
686 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
687 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
688 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
689 } |
7975 | 690 else |
691 prpl_info->get_info(gc, who); | |
692 } | |
693 } | |
694 | |
695 | |
4359 | 696 static void |
10810 | 697 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 698 { |
10810 | 699 GaimConversation *conv = gtkconv->active_conv; |
4359 | 700 |
7879 | 701 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
702 serv_get_info(gaim_conversation_get_gc(conv), | |
703 gaim_conversation_get_name(conv)); | |
704 | |
705 gtk_widget_grab_focus(gtkconv->entry); | |
706 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
707 /* Get info of the person currently selected in the GtkTreeView */ | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
708 GaimGtkChatPane *gtkchat; |
4359 | 709 GtkTreeIter iter; |
710 GtkTreeModel *model; | |
711 GtkTreeSelection *sel; | |
9554 | 712 char *name; |
4359 | 713 |
714 gtkchat = gtkconv->u.chat; | |
715 | |
716 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
717 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
718 | |
719 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 720 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 721 else |
722 return; | |
723 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
724 chat_do_info(gtkconv, name); |
9554 | 725 g_free(name); |
4359 | 726 } |
727 } | |
728 | |
729 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
730 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 731 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
732 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
733 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
734 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
735 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
736 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
737 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
738 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 739 |
740 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
741 } | |
742 | |
743 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
744 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 745 { |
746 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
747 GaimGtkConversation *gtkconv; |
4359 | 748 |
749 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
750 | |
751 if (resp == GTK_RESPONSE_OK) { | |
752 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
753 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
754 | |
10113 | 755 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 756 return; |
757 | |
758 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
759 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 760 message, buddy); |
761 } | |
762 | |
763 gtk_widget_destroy(invite_dialog); | |
764 invite_dialog = NULL; | |
765 | |
766 g_free(info); | |
767 } | |
768 | |
769 static void | |
9909 | 770 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
771 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
772 { | |
773 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
774 const char *convprotocol; | |
775 | |
776 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
777 | |
778 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
779 { | |
780 GaimBlistNode *node = NULL; | |
781 GaimBuddy *buddy; | |
782 | |
783 memcpy(&node, sd->data, sizeof(node)); | |
784 | |
785 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
786 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
787 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
788 buddy = (GaimBuddy *)node; | |
789 else | |
790 return; | |
791 | |
792 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
793 { | |
794 gaim_notify_error(NULL, NULL, | |
795 _("That buddy is not on the same protocol as this " | |
10843 | 796 "chat."), NULL); |
9909 | 797 } |
798 else | |
799 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
800 | |
801 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
802 } | |
803 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
804 { | |
805 char *protocol = NULL; | |
806 char *username = NULL; | |
807 GaimAccount *account; | |
808 | |
11137 | 809 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 810 &protocol, &username, NULL)) |
811 { | |
812 if (account == NULL) | |
813 { | |
814 gaim_notify_error(NULL, NULL, | |
815 _("You are not currently signed on with an account that " | |
816 "can invite that buddy."), NULL); | |
817 } | |
818 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
819 { | |
820 gaim_notify_error(NULL, NULL, | |
821 _("That buddy is not on the same protocol as this " | |
10843 | 822 "chat."), NULL); |
9909 | 823 } |
824 else | |
825 { | |
826 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
827 } | |
828 } | |
829 | |
830 if (username != NULL) g_free(username); | |
831 if (protocol != NULL) g_free(protocol); | |
832 | |
833 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
834 } | |
835 } | |
836 | |
837 static const GtkTargetEntry dnd_targets[] = | |
838 { | |
839 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
840 {"application/x-im-contact", 0, 1} | |
841 }; | |
842 | |
843 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
844 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 845 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
846 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
847 InviteBuddyInfo *info = NULL; |
4359 | 848 |
849 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
850 GaimConnection *gc; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
851 GaimConvWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
852 GaimGtkWindow *gtkwin; |
4359 | 853 GtkWidget *label; |
854 GtkWidget *vbox, *hbox; | |
855 GtkWidget *table; | |
856 GtkWidget *img; | |
857 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
858 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
859 GTK_ICON_SIZE_DIALOG); |
4359 | 860 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
861 info = g_new0(InviteBuddyInfo, 1); |
4359 | 862 info->conv = conv; |
863 | |
864 gc = gaim_conversation_get_gc(conv); | |
865 win = gaim_conversation_get_window(conv); | |
866 gtkwin = GAIM_GTK_WINDOW(win); | |
867 | |
868 /* Create the new dialog. */ | |
869 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 870 _("Invite Buddy Into Chat Room"), |
7879 | 871 GTK_WINDOW(gtkwin->window), 0, |
872 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
873 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 874 |
875 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
876 GTK_RESPONSE_OK); | |
877 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), 6); | |
878 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); | |
879 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
880 | |
9909 | 881 info->window = GTK_WIDGET(invite_dialog); |
882 | |
4359 | 883 /* Setup the outside spacing. */ |
884 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
885 | |
886 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
887 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
888 | |
889 /* Setup the inner hbox and put the dialog's icon in it. */ | |
890 hbox = gtk_hbox_new(FALSE, 12); | |
891 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
892 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
893 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
894 | |
895 /* Setup the right vbox. */ | |
896 vbox = gtk_vbox_new(FALSE, 0); | |
897 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
898 | |
899 /* Put our happy label in it. */ | |
900 label = gtk_label_new(_("Please enter the name of the user you wish " | |
901 "to invite, along with an optional invite " | |
902 "message.")); | |
903 gtk_widget_set_size_request(label, 350, -1); | |
904 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
905 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
906 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
907 | |
908 /* hbox for the table, and to give it some spacing on the left. */ | |
909 hbox = gtk_hbox_new(FALSE, 6); | |
910 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
911 | |
912 /* Setup the table we're going to use to lay stuff out. */ | |
913 table = gtk_table_new(2, 2, FALSE); | |
914 gtk_table_set_row_spacings(GTK_TABLE(table), 6); | |
915 gtk_table_set_col_spacings(GTK_TABLE(table), 6); | |
916 gtk_container_set_border_width(GTK_CONTAINER(table), 12); | |
917 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | |
918 | |
919 /* Now the Buddy label */ | |
920 label = gtk_label_new(NULL); | |
921 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
922 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
923 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
924 | |
925 /* Now the Buddy drop-down entry field. */ | |
926 info->entry = gtk_combo_new(); | |
927 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
928 gtk_entry_set_activates_default( | |
929 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
930 | |
931 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
932 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
933 | |
934 /* Fill in the names. */ | |
935 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
936 generate_invite_user_names(gc)); | |
937 | |
938 | |
939 /* Now the label for "Message" */ | |
940 label = gtk_label_new(NULL); | |
941 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
942 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
943 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
944 | |
945 | |
946 /* And finally, the Message entry field. */ | |
947 info->message = gtk_entry_new(); | |
948 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
949 | |
950 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
951 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
952 | |
953 /* Connect the signals. */ | |
954 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
955 G_CALLBACK(do_invite), info); | |
9909 | 956 /* Setup drag-and-drop */ |
957 gtk_drag_dest_set(info->window, | |
958 GTK_DEST_DEFAULT_MOTION | | |
959 GTK_DEST_DEFAULT_DROP, | |
960 dnd_targets, | |
961 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
962 GDK_ACTION_COPY); | |
963 gtk_drag_dest_set(info->entry, | |
964 GTK_DEST_DEFAULT_MOTION | | |
965 GTK_DEST_DEFAULT_DROP, | |
966 dnd_targets, | |
967 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
968 GDK_ACTION_COPY); | |
969 | |
970 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
971 G_CALLBACK(invite_dnd_recv), info); | |
972 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
973 G_CALLBACK(invite_dnd_recv), info); | |
974 | |
4359 | 975 } |
976 | |
977 gtk_widget_show_all(invite_dialog); | |
978 | |
979 if (info != NULL) | |
980 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
981 } | |
982 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
983 static void |
7748 | 984 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
985 { | |
9714 | 986 gaim_gtkdialogs_im(); |
7748 | 987 } |
988 | |
989 static void | |
9504 | 990 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 991 { |
9504 | 992 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 993 FILE *fp; |
994 const char *name; | |
10849 | 995 gchar *text; |
9489 | 996 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
997 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9504 | 998 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 999 return; |
1000 } | |
1001 | |
1002 name = gaim_conversation_get_name(conv); | |
10849 | 1003 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 1004 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 1005 |
1006 text = gtk_imhtml_get_markup( | |
1007 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
1008 fprintf(fp, "%s", text); | |
1009 g_free(text); | |
1010 | |
1011 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 1012 fclose(fp); |
1013 } | |
1014 | |
10849 | 1015 /* |
1016 * It would be kinda cool if this gave the option of saving a | |
1017 * plaintext v. HTML file. | |
1018 */ | |
9489 | 1019 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1020 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1021 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1022 GaimConvWindow *win = (GaimConvWindow *)data; |
9489 | 1023 GaimConversation *conv = gaim_conv_window_get_active_conversation(win); |
1024 gchar *buf; | |
1025 | |
1026 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 1027 |
10849 | 1028 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
1029 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 1030 |
1031 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1032 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1033 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1034 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1035 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1036 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1037 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1038 GaimConversation *conv; |
9917 | 1039 GaimLogType type; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1040 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1041 GaimAccount *account; |
10845 | 1042 GSList *buddies, *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1043 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1044 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1045 |
9917 | 1046 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
1047 type = GAIM_LOG_IM; | |
1048 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
1049 type = GAIM_LOG_CHAT; | |
1050 else | |
1051 return; | |
1052 | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1053 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1054 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1055 |
10845 | 1056 buddies = gaim_find_buddies(account, name); |
1057 for (cur = buddies; cur != NULL; cur = cur->next) | |
1058 { | |
1059 GaimBlistNode *node = cur->data; | |
10846 | 1060 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 1061 { |
1062 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
1063 g_slist_free(buddies); | |
1064 return; | |
1065 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1066 } |
10845 | 1067 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1068 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1069 gaim_gtk_log_show(type, name, account); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1070 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1071 |
8974 | 1072 static void |
1073 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
1074 { | |
1075 GaimConvWindow *win = (GaimConvWindow *)data; | |
1076 GaimConversation *conv; | |
1077 GaimGtkConversation *gtkconv; | |
1078 | |
1079 conv = gaim_conv_window_get_active_conversation(win); | |
1080 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1081 | |
1082 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1083 } | |
1084 | |
7295 | 1085 struct _search { |
1086 GaimGtkConversation *gtkconv; | |
1087 GtkWidget *entry; | |
1088 }; | |
1089 | |
7929 | 1090 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 1091 { |
7929 | 1092 switch (resp) { |
1093 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1094 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1095 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1096 break; |
1097 | |
1098 case GTK_RESPONSE_DELETE_EVENT: | |
1099 case GTK_RESPONSE_CLOSE: | |
1100 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1101 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1102 s->gtkconv->dialogs.search = NULL; | |
1103 g_free(s); | |
1104 break; | |
1105 } | |
7295 | 1106 } |
1107 | |
1108 static void | |
7751 | 1109 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1110 { |
1111 GaimConvWindow *win = (GaimConvWindow *)data; | |
1112 GaimConversation *conv = gaim_conv_window_get_active_conversation(win); | |
1113 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); | |
1114 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7929 | 1115 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1116 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1117 GTK_ICON_SIZE_DIALOG); |
7929 | 1118 GtkWidget *label; |
7295 | 1119 struct _search *s; |
1120 | |
7798 | 1121 if (gtkconv->dialogs.search) { |
1122 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1123 return; |
7798 | 1124 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1125 |
7295 | 1126 s = g_malloc(sizeof(struct _search)); |
1127 s->gtkconv = gtkconv; | |
7929 | 1128 |
1129 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1130 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1131 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1132 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1133 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1134 GTK_RESPONSE_OK); |
7929 | 1135 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1136 G_CALLBACK(do_search_cb), s); | |
1137 | |
1138 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), 6); | |
1139 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); | |
1140 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
1141 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(gtkconv->dialogs.search)->vbox), 12); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1142 gtk_container_set_border_width( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1143 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), 6); |
7929 | 1144 |
1145 hbox = gtk_hbox_new(FALSE, 12); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1146 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1147 hbox); |
7929 | 1148 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1149 | |
1150 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1151 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1152 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1153 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1154 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1155 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1156 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1157 | |
1158 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1159 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1160 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1161 g_signal_connect(G_OBJECT(s->entry), "changed", |
1162 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1163 gtkconv->dialogs.search); | |
1164 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
|
1165 |
7295 | 1166 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1167 gtk_widget_grab_focus(s->entry); |
7295 | 1168 } |
1169 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1170 static void |
9468 | 1171 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1172 { | |
1173 GaimConvWindow *win = (GaimConvWindow *)data; | |
1174 GaimConversation *conv = gaim_conv_window_get_active_conversation(win); | |
1175 | |
1176 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
1177 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); | |
1178 } | |
1179 | |
1180 } | |
1181 | |
1182 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1183 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1184 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1185 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1186 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1187 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1188 conv = gaim_conv_window_get_active_conversation(win); |
5908
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 gaim_gtkpounce_dialog_show(gaim_conversation_get_account(conv), |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1191 gaim_conversation_get_name(conv), NULL); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1192 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1193 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1194 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1195 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1196 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1197 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1198 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1199 GaimGtkConversation *gtkconv; |
8756 | 1200 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1201 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1202 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1203 gtkconv = GAIM_GTK_CONVERSATION(conv); |
8756 | 1204 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1205 | |
1206 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1207 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
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 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1210 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1212 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1213 GaimConvWindow *win = (GaimConvWindow *)data; |
8756 | 1214 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 GaimGtkConversation *gtkconv; |
8756 | 1216 GtkIMHtmlToolbar *toolbar; |
1217 | |
1218 conv = gaim_conv_window_get_active_conversation(win); | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1219 gtkconv = GAIM_GTK_CONVERSATION(gaim_conv_window_get_active_conversation(win)); |
8756 | 1220 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1221 | |
1222 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1223 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1224 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1225 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1226 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1227 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1228 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1229 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1230 GaimConversation *conv; |
7879 | 1231 GaimAccount *account; |
1232 const char *name; | |
1233 | |
1234 conv = gaim_conv_window_get_active_conversation(win); | |
1235 account = gaim_conversation_get_account(conv); | |
1236 name = gaim_conversation_get_name(conv); | |
1237 | |
1238 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
1239 GaimBuddy *b; | |
1240 | |
1241 b = gaim_find_buddy(account, name); | |
1242 if (b != NULL) | |
9730 | 1243 gaim_gtkdialogs_alias_buddy(b); |
7879 | 1244 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
1245 GaimChat *c; | |
1246 | |
1247 c = gaim_blist_find_chat(account, name); | |
1248 if (c != NULL) | |
9730 | 1249 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1250 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1251 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1252 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1253 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1254 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1255 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1256 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1257 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1258 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1259 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1260 |
10810 | 1261 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1262 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1263 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1264 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1265 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1266 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1267 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1268 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1269 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1270 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1271 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1272 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1273 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1274 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1275 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1276 menu_warn_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1277 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1278 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1279 GaimConversation *conv; |
10025 | 1280 GaimConnection *gc; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1281 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1282 conv = gaim_conv_window_get_active_conversation(win); |
10025 | 1283 gc = gaim_conversation_get_gc(conv); |
1284 | |
1285 gaim_gtkdialogs_warn(gc, gaim_conversation_get_name(conv)); | |
1286 | |
1287 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1288 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1289 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1290 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1291 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1292 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1293 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1294 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1295 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1296 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1297 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1298 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1299 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1300 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1301 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1302 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1303 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1304 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1305 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1306 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1307 conv = gaim_conv_window_get_active_conversation(win); |
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 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1310 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1311 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1312 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1313 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1314 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1315 GaimConvWindow *win = (GaimConvWindow *)data; |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1316 |
10810 | 1317 close_conv_cb(NULL, GAIM_GTK_CONVERSATION(gaim_conv_window_get_active_conversation(win))); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1318 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1319 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1320 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1321 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1322 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1323 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1324 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1325 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1326 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1327 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1328 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1329 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1330 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1331 gaim_conversation_set_logging(conv, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1332 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1333 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1334 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1335 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1336 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1337 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1338 GaimConvWindow *win = (GaimConvWindow *)data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1339 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1340 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1341 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1342 conv = gaim_conv_window_get_active_conversation(win); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1343 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1344 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1345 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1346 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1347 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1348 |
10377 | 1349 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
1350 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
|
1351 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1352 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1353 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1354 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1355 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1356 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1357 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1358 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1359 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1360 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1361 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1362 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1363 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1364 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1365 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1366 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1367 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1368 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1369 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1370 |
7961 | 1371 static void |
9188 | 1372 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1373 { | |
1374 GaimConvWindow *win = (GaimConvWindow *)data; | |
1375 GaimConversation *conv; | |
1376 GaimGtkConversation *gtkconv; | |
1377 | |
1378 conv = gaim_conv_window_get_active_conversation(win); | |
1379 | |
1380 if (!conv) | |
1381 return; | |
1382 | |
1383 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1384 | |
1385 gtkconv->show_timestamps = | |
1386 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
1387 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
1388 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); | |
1389 } | |
1390 | |
1391 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1392 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1393 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1394 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1395 GaimAccount *account; |
1396 GaimConnection *gc; | |
7961 | 1397 GaimPluginProtocolInfo *prpl_info = NULL; |
1398 char *real_who; | |
1399 | |
1400 account = gaim_conversation_get_account(conv); | |
10431 | 1401 g_return_if_fail(account != NULL); |
1402 | |
1403 gc = gaim_account_get_connection(account); | |
1404 g_return_if_fail(gc != NULL); | |
1405 | |
1406 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1407 | |
1408 if (prpl_info && prpl_info->get_cb_real_name) | |
1409 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1410 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1411 else | |
1412 real_who = g_strdup(who); | |
1413 | |
1414 if(!real_who) | |
1415 return; | |
1416 | |
10431 | 1417 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1418 |
1419 g_free(real_who); | |
1420 } | |
1421 | |
1422 static void | |
10810 | 1423 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1424 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1425 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1426 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1427 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1428 GtkTreeSelection *sel; |
9554 | 1429 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1430 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1431 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1432 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1433 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1434 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
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 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1437 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
|
1438 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1439 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1440 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1441 chat_do_im(gtkconv, name); |
9554 | 1442 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1443 } |
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 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1446 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1447 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1448 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1449 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1450 GaimConvChat *chat; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1451 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1452 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1453 GtkTreeSelection *sel; |
10504 | 1454 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1455 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1456 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1457 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1458 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1459 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1460 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1461 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1462 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
9498 | 1463 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
|
1464 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
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 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1467 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1468 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1469 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1470 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1471 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1472 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1473 |
9554 | 1474 add_chat_buddy_common(conv, name); |
10504 | 1475 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1476 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1477 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1478 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1479 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1480 { |
1481 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1482 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1483 chat_do_im(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1484 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1485 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1486 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1487 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1488 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1489 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1490 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1491 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1492 | |
1493 serv_send_file(gc, who, NULL); | |
1494 } | |
1495 | |
1496 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1497 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1498 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1499 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1500 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1501 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1502 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1503 chat_do_info(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1504 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1505 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1506 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1507 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1508 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1509 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1510 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1511 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1512 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1513 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1514 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1515 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1516 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1517 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1518 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1519 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1520 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1521 * 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
|
1522 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1523 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1524 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1525 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1526 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1527 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1528 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1529 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1530 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1531 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1532 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1533 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1534 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1535 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1536 GaimAccount *account; |
6695 | 1537 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1538 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1539 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1540 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1541 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1542 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1543 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1544 if (b != NULL) |
9730 | 1545 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1546 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1547 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1548 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1549 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1550 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1551 |
8143 | 1552 static GtkWidget * |
10504 | 1553 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1554 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1555 { | |
1556 static GtkWidget *menu = NULL; | |
1557 GtkWidget *button; | |
1558 | |
1559 /* | |
1560 * If a menu already exists, destroy it before creating a new one, | |
1561 * thus freeing-up the memory it occupied. | |
1562 */ | |
1563 if (menu) | |
1564 gtk_widget_destroy(menu); | |
1565 | |
1566 menu = gtk_menu_new(); | |
1567 | |
10221 | 1568 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1569 G_CALLBACK(menu_chat_im_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1570 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1571 |
9468 | 1572 if (gc && prpl_info && prpl_info->send_file |
1573 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { | |
10223 | 1574 button = gaim_new_item_from_stock(menu, _("Send File"), |
10221 | 1575 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1576 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1577 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1578 } |
9498 | 1579 |
8143 | 1580 if (gaim_conv_chat_is_user_ignored(GAIM_CONV_CHAT(conv), who)) |
10221 | 1581 button = gaim_new_item_from_stock(menu, _("Un-Ignore"), GAIM_STOCK_IGNORE, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1582 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1583 else |
10221 | 1584 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1585 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1586 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1587 |
8170 | 1588 if (gc && (prpl_info->get_info || prpl_info->get_cb_info)) { |
10221 | 1589 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
|
1590 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1591 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1592 } |
1593 | |
1594 if (gc && prpl_info->get_cb_away) { | |
10221 | 1595 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
|
1596 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1597 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1598 } |
1599 | |
8170 | 1600 /* XXX: jabber can only add buddies from here in certain circumstances */ |
8143 | 1601 /* Added by Jonas <jonas@birme.se> */ |
1602 if (gc) { | |
1603 if (gaim_find_buddy(gc->account, who)) | |
10221 | 1604 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
|
1605 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1606 else |
10221 | 1607 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
|
1608 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1609 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1610 } |
1611 /* End Jonas */ | |
1612 | |
1613 return menu; | |
1614 } | |
1615 | |
1616 | |
1617 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1618 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1619 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1620 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1621 GaimPluginProtocolInfo *prpl_info = NULL; |
1622 GaimGtkChatPane *gtkchat; | |
1623 GaimConnection *gc; | |
1624 GaimAccount *account; | |
1625 GtkTreeSelection *sel; | |
1626 GtkTreeIter iter; | |
1627 GtkTreeModel *model; | |
1628 GtkWidget *menu; | |
1629 gchar *who; | |
1630 | |
1631 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1632 gtkchat = gtkconv->u.chat; | |
1633 account = gaim_conversation_get_account(conv); | |
1634 gc = account->gc; | |
1635 | |
1636 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1637 | |
1638 if (gc != NULL) | |
1639 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1640 | |
1641 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1642 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1643 return FALSE; | |
1644 | |
9498 | 1645 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1646 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1647 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1648 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1649 0, GDK_CURRENT_TIME); |
10504 | 1650 g_free(who); |
8143 | 1651 |
1652 return TRUE; | |
1653 } | |
1654 | |
1655 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1656 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1657 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1658 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1659 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1660 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1661 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1662 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1663 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1664 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1665 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1666 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1667 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1668 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1669 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1670 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1671 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1672 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1673 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1674 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1675 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1676 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1677 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1678 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
|
1679 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1680 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1681 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1682 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1683 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1684 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1685 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1686 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1687 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1688 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1689 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1690 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1691 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
|
1692 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1693 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1694 chat_do_im(gtkconv, who); |
7398 | 1695 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1696 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1697 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1698 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1699 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1700 |
10504 | 1701 g_free(who); |
1702 gtk_tree_path_free(path); | |
1703 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1704 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1705 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1706 |
8133 | 1707 static void |
10827 | 1708 move_to_next_unread_tab(GaimGtkConversation *gtkconv) |
8133 | 1709 { |
10827 | 1710 GaimGtkConversation *next_gtkconv = NULL; |
8133 | 1711 GaimConvWindow *win; |
1712 GList *l; | |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1713 int index, i, found = 0; |
8133 | 1714 |
10827 | 1715 win = gaim_conversation_get_window(gtkconv->active_conv); |
1716 index = gtk_notebook_page_num(GTK_NOTEBOOK(GAIM_GTK_WINDOW(win)->notebook), gtkconv->tab_cont); | |
8133 | 1717 |
1718 /* First check the tabs after this position. */ | |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1719 for (i = index; !found && (next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, i)); i++) { |
10827 | 1720 for (l = next_gtkconv->convs; l; l = l->next) { |
1721 GaimConversation *c = l->data; | |
1722 if (gaim_conversation_get_unseen(c) > 0) | |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1723 { |
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1724 found = 1; |
10827 | 1725 break; |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1726 } |
10827 | 1727 } |
8133 | 1728 } |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1729 |
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1730 if (!found) { |
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1731 /* Now check from the beginning up to this position. */ |
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1732 for (i = 0; !found && i < index && (next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, i)); i++) { |
10827 | 1733 for (l = next_gtkconv->convs; l; l = l->next) { |
1734 GaimConversation *c = l->data; | |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1735 if (gaim_conversation_get_unseen(c) > 0) { |
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1736 found = 1; |
10827 | 1737 break; |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1738 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1739 } |
8133 | 1740 } |
10827 | 1741 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1742 if (!found) { |
10827 | 1743 /* Okay, just grab the next conversation tab. */ |
1744 if (!(next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, index + 1))) | |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1745 next_gtkconv = gaim_gtk_get_gtkconv_at_index(win, 0); |
10827 | 1746 |
1747 } | |
8133 | 1748 } |
1749 | |
10827 | 1750 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
1751 gaim_conv_window_switch_conversation(win,next_gtkconv->active_conv); | |
8133 | 1752 } |
1753 | |
4359 | 1754 static gboolean |
8105 | 1755 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1756 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1757 GaimConvWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1758 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1759 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1760 GaimGtkWindow *gtkwin; |
8105 | 1761 int curconv; |
1762 | |
10810 | 1763 gtkconv = (GaimGtkConversation *)data; |
10849 | 1764 conv = gtkconv->active_conv; |
8105 | 1765 win = gaim_conversation_get_window(conv); |
1766 gtkwin = GAIM_GTK_WINDOW(win); | |
10827 | 1767 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook)); |
10839 | 1768 |
8105 | 1769 /* If CTRL was held down... */ |
1770 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1771 switch (event->keyval) { |
1772 case GDK_Up: | |
1773 if (!conv->send_history) | |
1774 break; | |
1775 | |
1776 if (!conv->send_history->prev) { | |
1777 GtkTextIter start, end; | |
1778 | |
1779 if (conv->send_history->data) | |
1780 g_free(conv->send_history->data); | |
1781 | |
1782 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1783 &start); | |
1784 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1785 | |
1786 conv->send_history->data = | |
8506 | 1787 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1788 } |
8677 | 1789 |
4359 | 1790 if (conv->send_history->next && |
1791 conv->send_history->next->data) { | |
8677 | 1792 GtkTextIter iter; |
1793 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1794 |
1795 conv->send_history = conv->send_history->next; | |
8061 | 1796 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1797 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1798 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1799 0, NULL); |
8677 | 1800 /* this is mainly just a hack so the formatting at the |
1801 * cursor gets picked up. */ | |
1802 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1803 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1804 } |
1805 | |
8105 | 1806 return TRUE; |
4359 | 1807 break; |
1808 | |
1809 case GDK_Down: | |
1810 if (!conv->send_history) | |
1811 break; | |
1812 | |
8105 | 1813 if (conv->send_history->prev && |
1814 conv->send_history->prev->data) { | |
8677 | 1815 GtkTextIter iter; |
1816 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1817 |
4359 | 1818 conv->send_history = conv->send_history->prev; |
8105 | 1819 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1820 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1821 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1822 0, NULL); |
8677 | 1823 /* this is mainly just a hack so the formatting at the |
1824 * cursor gets picked up. */ | |
1825 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1826 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1827 } |
1828 | |
8105 | 1829 return TRUE; |
4359 | 1830 break; |
8105 | 1831 |
8108 | 1832 case GDK_Page_Down: |
8143 | 1833 case ']': |
10827 | 1834 if (!gaim_gtk_get_gtkconv_at_index(win, curconv + 1)) |
1835 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
1836 else | |
1837 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), curconv + 1); | |
8105 | 1838 return TRUE; |
1839 break; | |
1840 | |
8108 | 1841 case GDK_Page_Up: |
8143 | 1842 case '[': |
10827 | 1843 if (!gaim_gtk_get_gtkconv_at_index(win, curconv - 1)) |
1844 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), -1); | |
1845 else | |
1846 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), curconv - 1); | |
8133 | 1847 return TRUE; |
1848 break; | |
1849 | |
8108 | 1850 case GDK_Tab: |
10827 | 1851 move_to_next_unread_tab(gtkconv); |
8108 | 1852 |
1853 return TRUE; | |
1854 break; | |
1855 | |
8105 | 1856 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1857 } |
8758 | 1858 |
8105 | 1859 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1860 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1861 { |
10864 | 1862 if (event->keyval > '0' && event->keyval <= '9') |
1863 { | |
8105 | 1864 int switchto = event->keyval - '1'; |
10864 | 1865 if (switchto < gaim_conv_window_get_conversation_count(win)) |
1866 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), switchto); | |
4359 | 1867 |
1868 return TRUE; | |
1869 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1870 } |
8758 | 1871 |
8105 | 1872 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1873 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1874 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1875 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1876 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1877 case GDK_Tab: |
9605 | 1878 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1879 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1880 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1881 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1882 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1883 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1884 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1885 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1886 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1887 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1888 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1889 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1890 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1891 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1892 } |
4359 | 1893 return FALSE; |
1894 } | |
1895 | |
1896 /* | |
1897 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1898 * 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
|
1899 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1900 * 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
|
1901 * going all the way down to the notebook. I suspect a bug in |
4359 | 1902 * GtkTextView, but I'm not ready to point any fingers yet. |
1903 */ | |
1904 static gboolean | |
1905 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1906 { | |
1907 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1908 /* Right single click */ | |
1909 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1910 | |
1911 return TRUE; | |
1912 } | |
1913 | |
1914 return FALSE; | |
1915 } | |
1916 | |
8173 | 1917 /* |
1918 * If someone tries to type into the conversation backlog of a | |
1919 * conversation window then we yank focus from the conversation backlog | |
1920 * and give it to the text entry box so that people can type | |
1921 * all the live long day and it will get entered into the entry box. | |
1922 */ | |
6057 | 1923 static gboolean |
8105 | 1924 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1925 { |
1926 GaimGtkConversation *gtkconv = data; | |
1927 | |
8237 | 1928 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1929 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1930 (event->keyval == GDK_F10) || |
1931 (event->keyval == GDK_Shift_L) || | |
1932 (event->keyval == GDK_Shift_R) || | |
1933 (event->keyval == GDK_Escape) || | |
8177 | 1934 (event->keyval == GDK_Up) || |
1935 (event->keyval == GDK_Down) || | |
1936 (event->keyval == GDK_Left) || | |
8191 | 1937 (event->keyval == GDK_Right) || |
1938 (event->keyval == GDK_Home) || | |
9297 | 1939 (event->keyval == GDK_End) || |
1940 (event->keyval == GDK_Tab) || | |
1941 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1942 return FALSE; |
1943 | |
1944 if (event->type == GDK_KEY_RELEASE) | |
1945 gtk_widget_grab_focus(gtkconv->entry); | |
1946 | |
1947 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1948 | |
1949 return TRUE; | |
6057 | 1950 } |
1951 | |
4359 | 1952 static void |
4673 | 1953 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1954 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1955 GaimConvWindow *win = g_object_get_data(m, "user_data"); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
1956 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1957 GaimConversation *conv; |
8456 | 1958 GaimGtkConversation *gtkconv; |
4359 | 1959 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1960 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1961 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1962 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1963 conv = gaim_conv_window_get_active_conversation(win); |
4359 | 1964 |
4491 | 1965 gaim_conversation_set_account(conv, account); |
8456 | 1966 |
1967 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1968 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), | |
10810 | 1969 gaim_account_get_protocol_name(conv->account)); |
4359 | 1970 } |
1971 | |
1972 static void | |
1973 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
1974 gchar *new_text, gint new_text_length, gpointer user_data) | |
1975 { | |
10810 | 1976 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
1977 GaimConversation *conv; | |
1978 | |
1979 g_return_if_fail(gtkconv != NULL); | |
1980 | |
1981 conv = gtkconv->active_conv; | |
4359 | 1982 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
1983 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 1984 return; |
1985 | |
10810 | 1986 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
1987 gtk_text_iter_is_end(position))); | |
4359 | 1988 } |
1989 | |
1990 static void | |
1991 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
1992 GtkTextIter *end_pos, gpointer user_data) | |
1993 { | |
10810 | 1994 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
1995 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1996 GaimConvIm *im; |
4359 | 1997 |
10810 | 1998 g_return_if_fail(gtkconv != NULL); |
1999 | |
2000 conv = gtkconv->active_conv; | |
4359 | 2001 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2002 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2003 return; |
2004 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2005 im = GAIM_CONV_IM(conv); |
4359 | 2006 |
2007 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2008 | |
2009 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2010 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2011 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2012 |
2013 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2014 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2015 GAIM_NOT_TYPING); |
4359 | 2016 } |
2017 else { | |
2018 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2019 got_typing_keypress(gtkconv, FALSE); |
4359 | 2020 } |
2021 } | |
2022 | |
2023 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2024 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) |
4359 | 2025 { |
2026 static GdkCursor *cursor = NULL; | |
2027 | |
2028 gtkwin->in_drag = TRUE; | |
2029 | |
2030 if (gtkwin->drag_leave_signal) { | |
2031 g_signal_handler_disconnect(G_OBJECT(widget), | |
2032 gtkwin->drag_leave_signal); | |
2033 | |
2034 gtkwin->drag_leave_signal = 0; | |
2035 } | |
2036 | |
2037 if (cursor == NULL) | |
2038 cursor = gdk_cursor_new(GDK_FLEUR); | |
2039 | |
2040 /* Grab the pointer */ | |
2041 gtk_grab_add(gtkwin->notebook); | |
5114
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
2042 #ifndef _WIN32 |
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
2043 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will |
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
2044 always be true after a button press. */ |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2045 if (!gdk_pointer_is_grabbed()) |
5114
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
2046 #endif |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2047 gdk_pointer_grab(gtkwin->notebook->window, FALSE, |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2048 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2049 NULL, cursor, GDK_CURRENT_TIME); |
4359 | 2050 } |
2051 | |
2052 static gboolean | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2053 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimConvWindow *win) |
4359 | 2054 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2055 GaimGtkWindow *gtkwin; |
4359 | 2056 |
2057 gtkwin = GAIM_GTK_WINDOW(win); | |
2058 | |
2059 /* | |
2060 * Make sure the user moved the mouse far enough for the | |
2061 * drag to be initiated. | |
2062 */ | |
2063 if (gtkwin->in_predrag) { | |
2064 if (e->x_root < gtkwin->drag_min_x || | |
2065 e->x_root >= gtkwin->drag_max_x || | |
2066 e->y_root < gtkwin->drag_min_y || | |
2067 e->y_root >= gtkwin->drag_max_y) { | |
2068 | |
2069 gtkwin->in_predrag = FALSE; | |
2070 notebook_init_grab(gtkwin, widget); | |
2071 } | |
2072 } | |
2073 else { /* Otherwise, draw the arrows. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2074 GaimConvWindow *dest_win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2075 GaimGtkWindow *dest_gtkwin; |
4359 | 2076 GtkNotebook *dest_notebook; |
2077 GtkWidget *tab, *last_vis_tab = NULL; | |
2078 gint nb_x, nb_y, page_num, i, last_vis_tab_loc = -1; | |
2079 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
2080 gboolean horiz_tabs = FALSE, tab_found = FALSE; | |
2081 GList *l; | |
2082 | |
2083 /* Get the window that the cursor is over. */ | |
2084 dest_win = gaim_gtkwin_get_at_xy(e->x_root, e->y_root); | |
2085 | |
2086 if (dest_win == NULL) { | |
2087 dnd_hints_hide_all(); | |
2088 | |
2089 return TRUE; | |
2090 } | |
2091 | |
2092 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); | |
2093 | |
2094 dest_notebook = GTK_NOTEBOOK(dest_gtkwin->notebook); | |
2095 | |
2096 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
2097 | |
2098 arrow1_x = arrow2_x = nb_x; | |
2099 arrow1_y = arrow2_y = nb_y; | |
2100 | |
2101 page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, | |
2102 e->x_root, e->y_root); | |
2103 | |
2104 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
2105 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
2106 | |
2107 horiz_tabs = TRUE; | |
2108 } | |
2109 | |
2110 /* Find out where to put the arrows. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2111 for (l = gaim_conv_window_get_conversations(dest_win), i = 0; |
4359 | 2112 l != NULL; |
2113 l = l->next, i++) { | |
2114 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2115 GaimConversation *conv = l->data; |
4359 | 2116 |
2117 tab = GAIM_GTK_CONVERSATION(conv)->tabby; | |
2118 | |
2119 /* | |
2120 * If this is the correct tab, record the positions | |
2121 * for the arrows. | |
2122 */ | |
2123 if (i == page_num) { | |
2124 if (horiz_tabs) { | |
2125 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
2126 arrow1_y = nb_y + tab->allocation.y; | |
2127 arrow2_y = nb_y + tab->allocation.y + | |
2128 tab->allocation.height; | |
2129 } | |
2130 else { | |
2131 arrow1_x = nb_x + tab->allocation.x; | |
2132 arrow2_x = nb_x + tab->allocation.x + | |
2133 tab->allocation.width; | |
2134 arrow1_y = arrow2_y = nb_y + tab->allocation.y; | |
2135 } | |
2136 | |
2137 tab_found = TRUE; | |
2138 break; | |
2139 } | |
2140 else { /* Keep track of the right-most tab that we see. */ | |
2141 if (horiz_tabs && tab->allocation.x > last_vis_tab_loc) { | |
2142 last_vis_tab = tab; | |
2143 last_vis_tab_loc = tab->allocation.x; | |
2144 } | |
2145 else if (!horiz_tabs && tab->allocation.y > last_vis_tab_loc) { | |
2146 last_vis_tab = tab; | |
2147 last_vis_tab_loc = tab->allocation.y; | |
2148 } | |
2149 } | |
2150 } | |
2151 | |
2152 /* | |
2153 * If we didn't find the tab, then we'll just place the | |
2154 * arrows to the right/bottom of the last visible tab. | |
2155 */ | |
2156 if (!tab_found && last_vis_tab) { | |
2157 if (horiz_tabs) { | |
2158 arrow1_x = arrow2_x = nb_x + last_vis_tab->allocation.x + | |
2159 last_vis_tab->allocation.width; | |
2160 arrow1_y = nb_y + last_vis_tab->allocation.y; | |
2161 arrow2_y = nb_y + last_vis_tab->allocation.y + | |
2162 last_vis_tab->allocation.height; | |
2163 } | |
2164 else { | |
2165 arrow1_x = nb_x + last_vis_tab->allocation.x; | |
2166 arrow2_x = nb_x + last_vis_tab->allocation.x + | |
2167 last_vis_tab->allocation.width; | |
2168 arrow1_y = arrow2_y = nb_y + last_vis_tab->allocation.y + | |
2169 last_vis_tab->allocation.height; | |
2170 } | |
2171 } | |
2172 | |
2173 if (horiz_tabs) { | |
2174 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
2175 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
2176 } | |
2177 else { | |
2178 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
2179 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
2180 } | |
2181 } | |
2182 | |
2183 return TRUE; | |
2184 } | |
2185 | |
2186 static gboolean | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2187 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimConvWindow *win) |
4359 | 2188 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2189 GaimGtkWindow *gtkwin; |
4359 | 2190 |
2191 gtkwin = GAIM_GTK_WINDOW(win); | |
2192 | |
2193 if (gtkwin->in_drag) | |
2194 return FALSE; | |
2195 | |
2196 if (e->x_root < gtkwin->drag_min_x || | |
2197 e->x_root >= gtkwin->drag_max_x || | |
2198 e->y_root < gtkwin->drag_min_y || | |
2199 e->y_root >= gtkwin->drag_max_y) { | |
2200 | |
2201 gtkwin->in_predrag = FALSE; | |
2202 notebook_init_grab(gtkwin, widget); | |
2203 } | |
2204 | |
2205 return TRUE; | |
2206 } | |
2207 | |
2208 /* | |
2209 * THANK YOU GALEON! | |
2210 */ | |
2211 static gboolean | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2212 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimConvWindow *win) |
4359 | 2213 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2214 GaimGtkWindow *gtkwin; |
4359 | 2215 gint nb_x, nb_y, x_rel, y_rel; |
2216 GList *l; | |
2217 int tab_clicked; | |
2218 | |
2219 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
2220 return FALSE; | |
2221 | |
2222 gtkwin = GAIM_GTK_WINDOW(win); | |
2223 | |
2224 if (gtkwin->in_drag) { | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2225 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2226 "Already in the middle of a window drag at tab_press_cb\n"); |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2227 return TRUE; |
4359 | 2228 } |
2229 | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2230 /* |
4359 | 2231 * Make sure a tab was actually clicked. The arrow buttons |
2232 * mess things up. | |
2233 */ | |
2234 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root); | |
2235 | |
2236 if (tab_clicked == -1) | |
2237 return FALSE; | |
2238 | |
2239 /* | |
2240 * Get the relative position of the press event, with regards to | |
2241 * the position of the notebook. | |
2242 */ | |
2243 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
2244 | |
2245 x_rel = e->x_root - nb_x; | |
2246 y_rel = e->y_root - nb_y; | |
2247 | |
2248 /* Reset the min/max x/y */ | |
2249 gtkwin->drag_min_x = 0; | |
2250 gtkwin->drag_min_y = 0; | |
2251 gtkwin->drag_max_x = 0; | |
2252 gtkwin->drag_max_y = 0; | |
2253 | |
2254 /* Find out which tab was dragged. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2255 for (l = gaim_conv_window_get_conversations(win); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2256 GaimConversation *conv = l->data; |
4359 | 2257 GtkWidget *tab = GAIM_GTK_CONVERSATION(conv)->tabby; |
2258 | |
2259 if (!GTK_WIDGET_VISIBLE(tab)) | |
2260 continue; | |
2261 | |
2262 if (tab->allocation.x > x_rel || tab->allocation.y > y_rel) | |
2263 break; | |
2264 | |
2265 /* Save the borders of the tab. */ | |
2266 gtkwin->drag_min_x = tab->allocation.x + nb_x; | |
2267 gtkwin->drag_min_y = tab->allocation.y + nb_y; | |
2268 gtkwin->drag_max_x = tab->allocation.width + gtkwin->drag_min_x; | |
2269 gtkwin->drag_max_y = tab->allocation.height + gtkwin->drag_min_y; | |
2270 } | |
2271 | |
2272 /* Make sure the click occurred in the tab. */ | |
2273 if (e->x_root < gtkwin->drag_min_x || | |
2274 e->x_root >= gtkwin->drag_max_x || | |
2275 e->y_root < gtkwin->drag_min_y || | |
2276 e->y_root >= gtkwin->drag_max_y) { | |
2277 | |
2278 return FALSE; | |
2279 } | |
2280 | |
2281 gtkwin->in_predrag = TRUE; | |
2282 | |
2283 /* Connect the new motion signals. */ | |
2284 gtkwin->drag_motion_signal = | |
2285 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
2286 G_CALLBACK(notebook_motion_cb), win); | |
2287 | |
2288 gtkwin->drag_leave_signal = | |
2289 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
2290 G_CALLBACK(notebook_leave_cb), win); | |
2291 | |
2292 return FALSE; | |
2293 } | |
2294 | |
2295 static gboolean | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2296 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimConvWindow *win) |
4359 | 2297 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2298 GaimConvWindow *dest_win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2299 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2300 GaimGtkWindow *dest_gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2301 GaimConversation *conv; |
4359 | 2302 GtkNotebook *dest_notebook; |
2303 gint dest_page_num; | |
2304 | |
2305 /* | |
2306 * Don't check to make sure that the event's window matches the | |
2307 * widget's, because we may be getting an event passed on from the | |
2308 * close button. | |
2309 */ | |
2310 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
2311 return FALSE; | |
2312 | |
2313 if (gdk_pointer_is_grabbed()) { | |
2314 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
2315 gtk_grab_remove(widget); | |
2316 } | |
2317 | |
2318 gtkwin = GAIM_GTK_WINDOW(win); | |
2319 | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2320 if (!gtkwin->in_predrag && !gtkwin->in_drag) |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2321 return FALSE; |
4359 | 2322 |
2323 /* Disconnect the motion signal. */ | |
2324 if (gtkwin->drag_motion_signal) { | |
2325 g_signal_handler_disconnect(G_OBJECT(widget), | |
2326 gtkwin->drag_motion_signal); | |
2327 | |
2328 gtkwin->drag_motion_signal = 0; | |
2329 } | |
2330 | |
2331 /* | |
2332 * If we're in a pre-drag, we'll also need to disconnect the leave | |
2333 * signal. | |
2334 */ | |
2335 if (gtkwin->in_predrag) { | |
2336 gtkwin->in_predrag = FALSE; | |
2337 | |
2338 if (gtkwin->drag_leave_signal) { | |
2339 g_signal_handler_disconnect(G_OBJECT(widget), | |
2340 gtkwin->drag_leave_signal); | |
2341 | |
2342 gtkwin->drag_leave_signal = 0; | |
2343 } | |
2344 } | |
2345 | |
2346 /* If we're not in drag... */ | |
2347 /* We're perfectly normal people! */ | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2348 if (!gtkwin->in_drag) |
4359 | 2349 return FALSE; |
2350 | |
2351 gtkwin->in_drag = FALSE; | |
2352 | |
2353 dnd_hints_hide_all(); | |
2354 | |
4369
7e1fb422e5fd
[gaim-migrate @ 4635]
Christian Hammond <chipx86@chipx86.com>
parents:
4368
diff
changeset
|
2355 dest_win = gaim_gtkwin_get_at_xy(e->x_root, e->y_root); |
4359 | 2356 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2357 conv = gaim_conv_window_get_active_conversation(win); |
4359 | 2358 |
2359 if (dest_win == NULL) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2360 if (gaim_conv_window_get_conversation_count(win) < 2) |
4359 | 2361 return FALSE; |
2362 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2363 if (gaim_conv_window_get_conversation_count(win) > 1) { |
4359 | 2364 /* Make a new window to stick this to. */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2365 GaimGtkConversation *gtkconv; |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2366 gint win_width, win_height; |
5121 | 2367 |
2368 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4359 | 2369 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2370 dest_win = gaim_conv_window_new(); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2371 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2372 gaim_conv_window_add_conversation(dest_win, |
10824 | 2373 gaim_conv_window_remove_conversation(win, |
2374 conv)); | |
5121 | 2375 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2376 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2377 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2378 gtk_window_get_size(GTK_WINDOW(dest_gtkwin->window), |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2379 &win_width, &win_height); |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2380 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2381 gtk_window_move(GTK_WINDOW(dest_gtkwin->window), |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2382 e->x_root - (win_width / 2), |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2383 e->y_root - (win_height / 2)); |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2384 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2385 gaim_conv_window_show(dest_win); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2386 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2387 } else { |
10827 | 2388 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2389 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2390 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2391 /* Get the destination notebook. */ |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2392 dest_notebook = GTK_NOTEBOOK(gtkwin->notebook); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2393 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2394 /* Get the destination page number. */ |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2395 dest_page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2396 e->x_root, e->y_root); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2397 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2398 if (win == dest_win) { |
10827 | 2399 gtk_notebook_reorder_child(GTK_NOTEBOOK(gtkwin->notebook), gtkconv->tab_cont, dest_page_num); |
4359 | 2400 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2401 else { |
10827 | 2402 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2403 |
10824 | 2404 gaim_conv_window_remove_conversation(win, conv); |
10827 | 2405 gaim_conv_window_add_conversation(dest_win, conv); |
2406 gtk_notebook_reorder_child(GTK_NOTEBOOK(GAIM_GTK_WINDOW(dest_win)->notebook), gtkconv->tab_cont, dest_page_num); | |
2407 gaim_conv_window_switch_conversation(dest_win, gtkconv->active_conv); | |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2408 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2409 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2410 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
4359 | 2411 } |
2412 | |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2413 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-drag-ended", |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2414 win, dest_win); |
4359 | 2415 |
2416 return TRUE; | |
2417 } | |
2418 | |
8189 | 2419 /************************************************************************** |
2420 * A bunch of buddy icon functions | |
2421 **************************************************************************/ | |
2422 static GdkPixbuf * | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2423 get_tab_icon(GaimConversation *conv, gboolean small_icon) |
7143 | 2424 { |
10116 | 2425 GaimAccount *account = NULL; |
2426 const char *name = NULL; | |
7143 | 2427 GdkPixbuf *status = NULL; |
2428 | |
10116 | 2429 g_return_val_if_fail(conv != NULL, NULL); |
2430 | |
2431 account = gaim_conversation_get_account(conv); | |
2432 name = gaim_conversation_get_name(conv); | |
2433 | |
2434 g_return_val_if_fail(account != NULL, NULL); | |
2435 g_return_val_if_fail(name != NULL, NULL); | |
2436 | |
7143 | 2437 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
2438 GaimBuddy *b = gaim_find_buddy(account, name); | |
2439 if (b != NULL) { | |
2440 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2441 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2442 } |
2443 } | |
2444 | |
2445 if (!status) { | |
2446 GdkPixbuf *pixbuf; | |
10884 | 2447 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2448 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2449 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2450 { |
7143 | 2451 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2452 GDK_INTERP_BILINEAR); | |
2453 g_object_unref(pixbuf); | |
2454 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2455 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2456 status = pixbuf; |
7143 | 2457 } |
2458 return status; | |
2459 } | |
2460 | |
8189 | 2461 static void |
2462 update_tab_icon(GaimConversation *conv) | |
2463 { | |
2464 GaimGtkConversation *gtkconv; | |
2465 GaimConvWindow *win = gaim_conversation_get_window(conv); | |
2466 GaimAccount *account; | |
2467 const char *name; | |
2468 GdkPixbuf *status = NULL; | |
2469 | |
10116 | 2470 g_return_if_fail(conv != NULL); |
2471 | |
8189 | 2472 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2473 name = gaim_conversation_get_name(conv); | |
2474 account = gaim_conversation_get_account(conv); | |
2475 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2476 status = get_tab_icon(conv, TRUE); |
8189 | 2477 |
10116 | 2478 g_return_if_fail(status != NULL); |
2479 | |
8189 | 2480 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2481 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2482 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2483 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2484 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2485 |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2486 if (gaim_conv_window_get_active_conversation(win) == conv && |
10504 | 2487 (gaim_conversation_get_type(conv) != GAIM_CONV_IM || |
2488 gtkconv->u.im->anim == NULL)) | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2489 { |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2490 status = get_tab_icon(conv, FALSE); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2491 |
8189 | 2492 gtk_window_set_icon(GTK_WINDOW(GAIM_GTK_WINDOW(win)->window), status); |
2493 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2494 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2495 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2496 } |
8189 | 2497 } |
2498 | |
2499 static gboolean | |
2500 redraw_icon(gpointer data) | |
2501 { | |
10810 | 2502 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2503 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2504 GaimAccount *account; |
2505 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2506 |
2507 GdkPixbuf *buf; | |
2508 GdkPixbuf *scale; | |
2509 GdkPixmap *pm; | |
2510 GdkBitmap *bm; | |
2511 gint delay; | |
9318 | 2512 int scale_width, scale_height; |
8189 | 2513 |
2514 if (!g_list_find(gaim_get_ims(), conv)) { | |
2515 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
2516 "Conversation not found in redraw_icon. I think this " | |
2517 "is a bug.\n"); | |
2518 return FALSE; | |
2519 } | |
2520 | |
2521 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2522 account = gaim_conversation_get_account(conv); |
2523 if(account && account->gc) | |
2524 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2525 |
2526 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2527 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2528 | |
10483 | 2529 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2530 NULL, &scale_width, &scale_height); |
2531 | |
2532 /* this code is ugly, and scares me */ | |
8189 | 2533 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2534 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2535 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2536 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2537 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
2538 GDK_INTERP_NEAREST); | |
2539 | |
2540 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2541 g_object_unref(G_OBJECT(scale)); | |
2542 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2543 g_object_unref(G_OBJECT(pm)); | |
2544 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2545 | |
2546 if (bm) | |
2547 g_object_unref(G_OBJECT(bm)); | |
2548 | |
9131 | 2549 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2550 |
2551 if (delay < 100) | |
9131 | 2552 delay = 100; |
2553 | |
2554 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, conv); | |
8189 | 2555 |
2556 return FALSE; | |
2557 } | |
2558 | |
2559 static void | |
10810 | 2560 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2561 { |
10810 | 2562 GaimConversation *conv = gtkconv->active_conv; |
8189 | 2563 int delay; |
2564 | |
8228 | 2565 if (gtkconv->u.im->anim == NULL) |
2566 return; | |
2567 | |
8202 | 2568 if (gtkconv->u.im->icon_timer != 0) |
2569 return; | |
2570 | |
8189 | 2571 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2572 return; | |
2573 | |
10639 | 2574 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2575 | |
2576 if (delay < 100) | |
2577 delay = 100; | |
2578 | |
10810 | 2579 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, conv); |
8189 | 2580 } |
2581 | |
2582 static void | |
10810 | 2583 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2584 { |
2585 if (gtkconv->u.im->icon_timer != 0) | |
2586 g_source_remove(gtkconv->u.im->icon_timer); | |
2587 | |
2588 gtkconv->u.im->icon_timer = 0; | |
2589 } | |
2590 | |
2591 static void | |
10810 | 2592 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
8189 | 2593 { |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2594 gtkconv->u.im->animate = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2595 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); |
8189 | 2596 |
2597 if (gtkconv->u.im->animate) | |
10810 | 2598 start_anim(NULL, gtkconv); |
8189 | 2599 else |
10810 | 2600 stop_anim(NULL, gtkconv); |
8189 | 2601 } |
9845 | 2602 |
8189 | 2603 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2604 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2605 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2606 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2607 GaimGtkWindow *gtkwin; |
2608 | |
2609 g_return_if_fail(conv != NULL); | |
2610 | |
9887 | 2611 if (gtkconv->u.im->icon_container != NULL) |
2612 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2613 |
2614 if (gtkconv->u.im->anim != NULL) | |
2615 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2616 | |
2617 if (gtkconv->u.im->icon_timer != 0) | |
2618 g_source_remove(gtkconv->u.im->icon_timer); | |
2619 | |
2620 if (gtkconv->u.im->iter != NULL) | |
2621 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2622 | |
2623 gtkconv->u.im->icon_timer = 0; | |
2624 gtkconv->u.im->icon = NULL; | |
2625 gtkconv->u.im->anim = NULL; | |
2626 gtkconv->u.im->iter = NULL; | |
10456 | 2627 gtkconv->u.im->icon_container = NULL; |
9687 | 2628 gtkconv->u.im->show_icon = FALSE; |
10456 | 2629 |
2630 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
2631 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); | |
8189 | 2632 } |
2633 | |
9497 | 2634 static void |
9504 | 2635 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2636 { |
10810 | 2637 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2638 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2639 FILE *fp; |
2640 GaimBuddyIcon *icon; | |
2641 const void *data; | |
2642 size_t len; | |
2643 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2644 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2645 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2646 return; |
2647 } | |
2648 | |
2649 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2650 data = gaim_buddy_icon_get_data(icon, &len); | |
2651 | |
2652 if ((len <= 0) || (data == NULL)) { | |
9504 | 2653 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2654 return; |
2655 } | |
2656 | |
2657 fwrite(data, 1, len, fp); | |
2658 fclose(fp); | |
2659 } | |
2660 | |
2661 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2662 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2663 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2664 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2665 const gchar *ext; |
9497 | 2666 gchar *buf; |
2667 | |
2668 g_return_if_fail(conv != NULL); | |
9504 | 2669 |
10953 | 2670 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2671 if (ext == NULL) | |
2672 ext = "icon"; | |
2673 | |
2674 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2675 |
2676 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
2677 G_CALLBACK(saveicon_writefile_cb), NULL, conv); | |
9497 | 2678 |
2679 g_free(buf); | |
2680 } | |
2681 | |
8189 | 2682 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2683 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2684 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2685 GaimConversation *conv = gtkconv->active_conv; |
8189 | 2686 static GtkWidget *menu = NULL; |
2687 GtkWidget *button; | |
2688 | |
2689 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2690 return FALSE; | |
2691 | |
2692 /* | |
2693 * If a menu already exists, destroy it before creating a new one, | |
2694 * thus freeing-up the memory it occupied. | |
2695 */ | |
2696 if (menu != NULL) | |
2697 gtk_widget_destroy(menu); | |
2698 | |
2699 menu = gtk_menu_new(); | |
2700 | |
2701 if (gtkconv->u.im->anim && | |
2702 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2703 { | |
2704 gaim_new_check_item(menu, _("Animate"), | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2705 G_CALLBACK(toggle_icon_animate_cb), conv, |
8189 | 2706 gtkconv->u.im->icon_timer); |
2707 } | |
2708 | |
2709 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2710 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2711 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2712 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2713 gtk_widget_show(button); | |
2714 | |
2715 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
|
2716 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2717 0, 0, NULL); |
2718 | |
2719 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2720 | |
2721 return TRUE; | |
2722 } | |
10456 | 2723 |
2724 static void | |
2725 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2726 { | |
2727 GaimConvWindow *win = (GaimConvWindow *)data; | |
2728 GaimConversation *conv; | |
2729 GaimGtkConversation *gtkconv; | |
2730 gboolean active; | |
2731 | |
2732 conv = gaim_conv_window_get_active_conversation(win); | |
2733 | |
2734 if (!conv) | |
2735 return; | |
2736 | |
2737 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_IM); | |
2738 | |
2739 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2740 | |
2741 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2742 gtkconv->u.im->show_icon = active; | |
2743 if (active) | |
2744 gaim_gtkconv_update_buddy_icon(conv); | |
2745 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2746 remove_icon(gtkconv); |
10456 | 2747 } |
2748 | |
8189 | 2749 /************************************************************************** |
2750 * End of the bunch of buddy icon functions | |
2751 **************************************************************************/ | |
2752 | |
10665 | 2753 |
7887 | 2754 /* |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2755 * Makes sure all the menu items and all the buttons are hidden/shown and |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8730
diff
changeset
|
2756 * sensitive/insensitive. This is called after changing tabs and when an |
7887 | 2757 * account signs on or off. |
2758 */ | |
4359 | 2759 static void |
10810 | 2760 gray_stuff_out(GaimGtkConversation *gtkconv) |
4359 | 2761 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2762 GaimConvWindow *win; |
7887 | 2763 GaimGtkWindow *gtkwin; |
10810 | 2764 GaimConversation *conv = gtkconv->active_conv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2765 GaimConnection *gc; |
7887 | 2766 GaimPluginProtocolInfo *prpl_info = NULL; |
7222 | 2767 GdkPixbuf *window_icon = NULL; |
8439 | 2768 GtkIMHtmlButtons buttons; |
9812 | 2769 GaimAccount *account; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2770 |
7887 | 2771 win = gaim_conversation_get_window(conv); |
4359 | 2772 gtkwin = GAIM_GTK_WINDOW(win); |
2773 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7887 | 2774 gc = gaim_conversation_get_gc(conv); |
9909 | 2775 account = gaim_conversation_get_account(conv); |
8439 | 2776 |
7879 | 2777 if (gc != NULL) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
2778 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2779 |
7887 | 2780 if (gtkwin->menu.send_as != NULL) |
2781 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); | |
2782 | |
2783 /* | |
2784 * Handle hiding and showing stuff based on what type of conv this is. | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2785 * Stuff that Gaim IMs support in general should be shown for IM |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8730
diff
changeset
|
2786 * conversations. Stuff that Gaim chats support in general should be |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2787 * shown for chat conversations. It doesn't matter whether the PRPL |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2788 * supports it or not--that only affects if the button or menu item |
7929 | 2789 * is sensitive or not. |
7887 | 2790 */ |
4359 | 2791 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
7887 | 2792 /* Show stuff that applies to IMs, hide stuff that applies to chats */ |
2793 | |
2794 /* Deal with menu items */ | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2795 gtk_widget_show(gtkwin->menu.view_log); |
9468 | 2796 gtk_widget_show(gtkwin->menu.send_file); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2797 gtk_widget_show(gtkwin->menu.add_pounce); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2798 gtk_widget_show(gtkwin->menu.get_info); |
7887 | 2799 gtk_widget_show(gtkwin->menu.warn); |
7859 | 2800 gtk_widget_hide(gtkwin->menu.invite); |
7887 | 2801 gtk_widget_show(gtkwin->menu.alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2802 gtk_widget_show(gtkwin->menu.block); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2803 |
9812 | 2804 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2805 gtk_widget_show(gtkwin->menu.add); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2806 gtk_widget_hide(gtkwin->menu.remove); |
7859 | 2807 } else { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2808 gtk_widget_show(gtkwin->menu.remove); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2809 gtk_widget_hide(gtkwin->menu.add); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2810 } |
7887 | 2811 |
2812 gtk_widget_show(gtkwin->menu.insert_link); | |
9287 | 2813 gtk_widget_show(gtkwin->menu.insert_image); |
10456 | 2814 gtk_widget_show(gtkwin->menu.show_icon); |
7887 | 2815 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
9470 | 2816 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ |
7887 | 2817 |
2818 /* Deal with menu items */ | |
9917 | 2819 gtk_widget_show(gtkwin->menu.view_log); |
9468 | 2820 gtk_widget_hide(gtkwin->menu.send_file); |
7859 | 2821 gtk_widget_hide(gtkwin->menu.add_pounce); |
2822 gtk_widget_hide(gtkwin->menu.get_info); | |
7887 | 2823 gtk_widget_hide(gtkwin->menu.warn); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2824 gtk_widget_show(gtkwin->menu.invite); |
7887 | 2825 gtk_widget_show(gtkwin->menu.alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2826 gtk_widget_hide(gtkwin->menu.block); |
10456 | 2827 gtk_widget_hide(gtkwin->menu.show_icon); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2828 |
9812 | 2829 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { |
2830 /* If the chat is NOT in the buddy list */ | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2831 gtk_widget_show(gtkwin->menu.add); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2832 gtk_widget_hide(gtkwin->menu.remove); |
7859 | 2833 } else { |
9812 | 2834 /* If the chat IS in the buddy list */ |
2835 gtk_widget_hide(gtkwin->menu.add); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2836 gtk_widget_show(gtkwin->menu.remove); |
7887 | 2837 } |
2838 | |
2839 gtk_widget_show(gtkwin->menu.insert_link); | |
2840 gtk_widget_hide(gtkwin->menu.insert_image); | |
2841 } | |
2842 | |
2843 /* | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2844 * Handle graying stuff out based on whether an account is connected |
7887 | 2845 * and what features that account supports. |
2846 */ | |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
2847 if ((gc != NULL) && |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
2848 ( (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT) || |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
2849 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) { |
7887 | 2850 /* Account is online */ |
2851 /* Deal with the toolbar */ | |
10665 | 2852 if (conv->features & GAIM_CONNECTION_HTML) { |
8677 | 2853 buttons = GTK_IMHTML_ALL; /* Everything on */ |
10698 | 2854 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || |
2855 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
8422 | 2856 buttons &= ~GTK_IMHTML_IMAGE; |
10665 | 2857 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) |
8422 | 2858 buttons &= ~GTK_IMHTML_BACKCOLOR; |
10665 | 2859 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) { |
8691
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8690
diff
changeset
|
2860 buttons &= ~GTK_IMHTML_GROW; |
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8690
diff
changeset
|
2861 buttons &= ~GTK_IMHTML_SHRINK; |
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8690
diff
changeset
|
2862 } |
10665 | 2863 if (conv->features & GAIM_CONNECTION_NO_URLDESC) |
9041 | 2864 buttons &= ~GTK_IMHTML_LINKDESC; |
8420 | 2865 } else { |
8422 | 2866 buttons = GTK_IMHTML_SMILEY; |
8420 | 2867 } |
2868 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); | |
9812 | 2869 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); |
8422 | 2870 |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
2871 /* Deal with menu items */ |
7887 | 2872 gtk_widget_set_sensitive(gtkwin->menu.view_log, TRUE); |
2873 gtk_widget_set_sensitive(gtkwin->menu.add_pounce, TRUE); | |
2874 gtk_widget_set_sensitive(gtkwin->menu.get_info, (prpl_info->get_info != NULL)); | |
2875 gtk_widget_set_sensitive(gtkwin->menu.warn, (prpl_info->warn != NULL)); | |
9812 | 2876 gtk_widget_set_sensitive(gtkwin->menu.invite, (prpl_info->chat_invite != NULL)); |
2877 gtk_widget_set_sensitive(gtkwin->menu.block, (prpl_info->add_deny != NULL)); | |
10665 | 2878 gtk_widget_set_sensitive(gtkwin->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); |
9812 | 2879 gtk_widget_set_sensitive(gtkwin->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE)); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
2880 |
7887 | 2881 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
9812 | 2882 gtk_widget_set_sensitive(gtkwin->menu.add, (prpl_info->add_buddy != NULL)); |
2883 gtk_widget_set_sensitive(gtkwin->menu.remove, (prpl_info->remove_buddy != NULL)); | |
9468 | 2884 gtk_widget_set_sensitive(gtkwin->menu.send_file, |
9812 | 2885 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || |
2886 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
2887 gtk_widget_set_sensitive(gtkwin->menu.alias, | |
2888 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
7887 | 2889 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
9812 | 2890 gtk_widget_set_sensitive(gtkwin->menu.add, (prpl_info->join_chat != NULL)); |
2891 gtk_widget_set_sensitive(gtkwin->menu.remove, (prpl_info->join_chat != NULL)); | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
2892 gtk_widget_set_sensitive(gtkwin->menu.alias, |
9812 | 2893 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); |
7887 | 2894 } |
10500 | 2895 |
2896 /* Deal with chat userlist buttons */ | |
2897 if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
2898 { | |
2899 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
2900 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
2901 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
2902 } | |
7887 | 2903 } else { |
2904 /* Account is offline */ | |
9812 | 2905 /* Or it's a chat that we've left. */ |
10471 | 2906 |
7887 | 2907 /* Then deal with menu items */ |
2908 gtk_widget_set_sensitive(gtkwin->menu.view_log, TRUE); | |
9468 | 2909 gtk_widget_set_sensitive(gtkwin->menu.send_file, FALSE); |
7887 | 2910 gtk_widget_set_sensitive(gtkwin->menu.add_pounce, TRUE); |
2911 gtk_widget_set_sensitive(gtkwin->menu.get_info, FALSE); | |
2912 gtk_widget_set_sensitive(gtkwin->menu.warn, FALSE); | |
2913 gtk_widget_set_sensitive(gtkwin->menu.invite, FALSE); | |
2914 gtk_widget_set_sensitive(gtkwin->menu.alias, FALSE); | |
2915 gtk_widget_set_sensitive(gtkwin->menu.block, FALSE); | |
2916 gtk_widget_set_sensitive(gtkwin->menu.add, FALSE); | |
2917 gtk_widget_set_sensitive(gtkwin->menu.remove, FALSE); | |
7929 | 2918 gtk_widget_set_sensitive(gtkwin->menu.insert_link, TRUE); |
7887 | 2919 gtk_widget_set_sensitive(gtkwin->menu.insert_image, FALSE); |
10500 | 2920 |
2921 /* Deal with chat userlist buttons */ | |
2922 if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
2923 { | |
2924 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
2925 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
2926 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
2927 } | |
7887 | 2928 } |
2929 | |
2930 /* | |
2931 * Update the window's icon | |
2932 */ | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2933 if ((gaim_conversation_get_type(conv) == GAIM_CONV_IM) && |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2934 (gtkconv->u.im->anim)) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2935 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2936 window_icon = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2937 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); |
7887 | 2938 g_object_ref(window_icon); |
2939 } else { | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2940 window_icon = get_tab_icon(conv, FALSE); |
4359 | 2941 } |
7887 | 2942 gtk_window_set_icon(GTK_WINDOW(gtkwin->window), window_icon); |
10471 | 2943 if (window_icon != NULL) |
2944 g_object_unref(G_OBJECT(window_icon)); | |
7887 | 2945 } |
2946 | |
2947 static void | |
8189 | 2948 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, |
2949 gpointer user_data) | |
2950 { | |
2951 GaimConvWindow *win; | |
2952 GaimConversation *conv; | |
2953 GaimGtkConversation *gtkconv; | |
2954 | |
2955 win = (GaimConvWindow *)user_data; | |
2956 conv = gaim_conv_window_get_active_conversation(win); | |
2957 | |
2958 g_return_if_fail(conv != NULL); | |
2959 | |
8192 | 2960 if (gaim_conversation_get_type(conv) != GAIM_CONV_IM) |
2961 return; | |
2962 | |
8189 | 2963 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2964 | |
10810 | 2965 stop_anim(NULL, gtkconv); |
8189 | 2966 } |
2967 | |
2968 static void | |
7887 | 2969 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, |
2970 gpointer user_data) | |
2971 { | |
2972 GaimConvWindow *win; | |
2973 GaimConversation *conv; | |
2974 GaimGtkConversation *gtkconv; | |
2975 GaimGtkWindow *gtkwin; | |
2976 | |
2977 win = (GaimConvWindow *)user_data; | |
10827 | 2978 gtkconv = gaim_gtk_get_gtkconv_at_index(win, page_num); |
2979 conv = gtkconv->active_conv; | |
7887 | 2980 |
2981 g_return_if_fail(conv != NULL); | |
2982 | |
2983 gtkwin = GAIM_GTK_WINDOW(win); | |
2984 | |
10971 | 2985 /* |
2986 * Only set "unseen" to "none" if the window has focus | |
2987 */ | |
2988 if (gaim_conv_window_has_focus(win)) | |
2989 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE); | |
7887 | 2990 |
2991 /* Update the menubar */ | |
10810 | 2992 gray_stuff_out(gtkconv); |
2993 | |
2994 update_typing_icon(gtkconv); | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2995 |
4359 | 2996 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.logging), |
7143 | 2997 gaim_conversation_is_logging(conv)); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2998 |
4359 | 2999 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.sounds), |
7143 | 3000 gtkconv->make_sound); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3001 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3002 gtk_check_menu_item_set_active( |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3003 GTK_CHECK_MENU_ITEM(gtkwin->menu.show_formatting_toolbar), |
10377 | 3004 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3005 |
9188 | 3006 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_timestamps), |
3007 gtkconv->show_timestamps); | |
3008 | |
10456 | 3009 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
3010 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), | |
3011 gtkconv->u.im->show_icon); | |
8189 | 3012 /* |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3013 * We pause icons when they are not visible. If this icon should |
9297 | 3014 * be animated then start it back up again. |
8189 | 3015 */ |
8192 | 3016 if ((gaim_conversation_get_type(conv) == GAIM_CONV_IM) && |
3017 (gtkconv->u.im->animate)) | |
10810 | 3018 start_anim(NULL, gtkconv); |
8189 | 3019 |
4965 | 3020 gtk_window_set_title(GTK_WINDOW(gtkwin->window), |
7143 | 3021 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); |
4359 | 3022 } |
3023 | |
3024 /************************************************************************** | |
3025 * Utility functions | |
3026 **************************************************************************/ | |
3027 | |
3028 static void | |
10810 | 3029 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 3030 { |
10810 | 3031 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3032 GaimConvIm *im; |
4685 | 3033 |
4359 | 3034 /* |
3035 * 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
|
3036 * send GAIM_TYPED any time soon. |
4359 | 3037 */ |
3038 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3039 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3040 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3041 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3042 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3043 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3044 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3045 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3046 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3047 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 3048 |
3049 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
3050 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
3051 GAIM_TYPING); |
4359 | 3052 |
3053 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3054 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 3055 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3056 gaim_conv_im_set_type_again(im, 0); |
4359 | 3057 } |
3058 } | |
3059 | |
4736 | 3060 static void |
10810 | 3061 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 3062 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3063 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3064 GaimConvIm *im = NULL; |
10810 | 3065 GaimConversation *conv = gtkconv->active_conv; |
3066 | |
4736 | 3067 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); |
3068 | |
3069 if(gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3070 im = GAIM_CONV_IM(conv); |
4736 | 3071 |
3072 if(gtkwin->menu.typing_icon) { | |
3073 gtk_widget_destroy(gtkwin->menu.typing_icon); | |
3074 gtkwin->menu.typing_icon = NULL; | |
3075 } | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3076 if(im && gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { |
10359 | 3077 gtkwin->menu.typing_icon = gtk_image_new_from_stock(GAIM_STOCK_TYPING, |
3078 GTK_ICON_SIZE_MENU); | |
4757 | 3079 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
4736 | 3080 _("User is typing..."), NULL); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3081 } else if(im && gaim_conv_im_get_typing_state(im) == GAIM_TYPED) { |
10359 | 3082 gtkwin->menu.typing_icon = gtk_image_new_from_stock(GAIM_STOCK_TYPED, |
3083 GTK_ICON_SIZE_MENU); | |
4757 | 3084 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
4736 | 3085 _("User has typed something and paused"), NULL); |
3086 } | |
3087 | |
3088 if(gtkwin->menu.typing_icon) { | |
10359 | 3089 gtk_widget_show(gtkwin->menu.typing_icon); |
3090 gtk_box_pack_end(GTK_BOX(gtkwin->menu.menubox), gtkwin->menu.typing_icon, | |
3091 FALSE, FALSE, 0); | |
4736 | 3092 } |
3093 } | |
3094 | |
4685 | 3095 static gboolean |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3096 update_send_as_selection(GaimConvWindow *win) |
4359 | 3097 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3098 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3099 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3100 GaimGtkWindow *gtkwin; |
4359 | 3101 GtkWidget *menu; |
3102 GList *child; | |
3103 | |
7090
04f9f7440bc3
[gaim-migrate @ 7655]
Christian Hammond <chipx86@chipx86.com>
parents:
7089
diff
changeset
|
3104 if (g_list_find(gaim_get_windows(), win) == NULL) |
04f9f7440bc3
[gaim-migrate @ 7655]
Christian Hammond <chipx86@chipx86.com>
parents:
7089
diff
changeset
|
3105 return FALSE; |
4849 | 3106 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3107 conv = gaim_conv_window_get_active_conversation(win); |
4359 | 3108 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
3109 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
3110 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3111 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3112 account = gaim_conversation_get_account(conv); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3113 gtkwin = GAIM_GTK_WINDOW(win); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3114 |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
3115 if (gtkwin->menu.send_as == NULL) |
4685 | 3116 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
3117 |
4359 | 3118 gtk_widget_show(gtkwin->menu.send_as); |
3119 | |
3120 menu = gtk_menu_item_get_submenu( | |
3121 GTK_MENU_ITEM(gtkwin->menu.send_as)); | |
3122 | |
3123 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
3124 child != NULL; | |
3125 child = child->next) { | |
3126 | |
3127 GtkWidget *item = child->data; | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3128 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), |
4673 | 3129 "gaim_account"); |
3130 | |
3131 if (account == item_account) { | |
4359 | 3132 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
3133 break; | |
3134 } | |
3135 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
3136 |
4685 | 3137 return FALSE; |
4359 | 3138 } |
3139 | |
3140 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3141 generate_send_as_items(GaimConvWindow *win, GaimConversation *deleted_conv) |
4359 | 3142 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3143 GaimGtkWindow *gtkwin; |
4359 | 3144 GtkWidget *menu; |
3145 GtkWidget *menuitem; | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3146 GList *gcs; |
4359 | 3147 GList *convs; |
3148 GSList *group = NULL; | |
3149 gboolean first_offline = TRUE; | |
3150 gboolean found_online = FALSE; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3151 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4359 | 3152 |
3153 gtkwin = GAIM_GTK_WINDOW(win); | |
3154 | |
3155 if (gtkwin->menu.send_as != NULL) | |
3156 gtk_widget_destroy(gtkwin->menu.send_as); | |
3157 | |
3158 /* See if we have > 1 connection active. */ | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3159 if (g_list_length(gaim_connections_get_all()) < 2) { |
4359 | 3160 /* Now make sure we don't have any Offline entries. */ |
3161 gboolean found_offline = FALSE; | |
3162 | |
3163 for (convs = gaim_get_conversations(); | |
3164 convs != NULL; | |
3165 convs = convs->next) { | |
3166 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3167 GaimConversation *conv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3168 GaimAccount *account; |
4491 | 3169 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3170 conv = (GaimConversation *)convs->data; |
4491 | 3171 account = gaim_conversation_get_account(conv); |
3172 | |
6495
8ce66049ce68
[gaim-migrate @ 7010]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
3173 if (account != NULL && account->gc == NULL) { |
4359 | 3174 found_offline = TRUE; |
3175 break; | |
3176 } | |
3177 } | |
3178 | |
3179 if (!found_offline) { | |
3180 gtkwin->menu.send_as = NULL; | |
3181 return; | |
3182 } | |
3183 } | |
3184 | |
3185 /* Build the Send As menu */ | |
3186 gtkwin->menu.send_as = gtk_menu_item_new_with_mnemonic(_("_Send As")); | |
3187 gtk_widget_show(gtkwin->menu.send_as); | |
3188 | |
3189 menu = gtk_menu_new(); | |
7857
43f63ff8a6d8
[gaim-migrate @ 8511]
Christian Hammond <chipx86@chipx86.com>
parents:
7855
diff
changeset
|
3190 gtk_menu_shell_insert(GTK_MENU_SHELL(gtkwin->menu.menubar), |
43f63ff8a6d8
[gaim-migrate @ 8511]
Christian Hammond <chipx86@chipx86.com>
parents:
7855
diff
changeset
|
3191 gtkwin->menu.send_as, 2); |
4359 | 3192 gtk_menu_item_set_submenu(GTK_MENU_ITEM(gtkwin->menu.send_as), menu); |
3193 | |
3194 gtk_widget_show(menu); | |
3195 | |
3196 /* Fill it with entries. */ | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3197 for (gcs = gaim_connections_get_all(); gcs != NULL; gcs = gcs->next) { |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3198 |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3199 GaimConnection *gc; |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3200 GaimAccount *account; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3201 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3202 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3203 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3204 GdkPixbuf *pixbuf, *scale; |
4359 | 3205 |
3206 found_online = TRUE; | |
3207 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3208 gc = (GaimConnection *)gcs->data; |
4359 | 3209 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3210 /* Create a pixmap for the protocol icon. */ |
10884 | 3211 pixbuf = gaim_gtk_create_prpl_icon(gc->account); |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3212 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3213 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3214 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3215 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3216 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3217 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3218 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3219 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3220 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3221 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3222 g_object_unref(G_OBJECT(scale)); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3223 g_object_unref(G_OBJECT(pixbuf)); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3224 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3225 account = gaim_connection_get_account(gc); |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3226 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3227 /* Make our menu item */ |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3228 menuitem = gtk_radio_menu_item_new_with_label(group, |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3229 gaim_account_get_username(account)); |
4793 | 3230 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
4359 | 3231 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3232 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3233 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3234 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3235 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3236 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3237 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3238 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3239 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3240 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3241 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3242 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3243 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3244 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3245 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3246 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3247 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3248 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3249 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3250 /* Set our data and callbacks. */ |
4359 | 3251 g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
4673 | 3252 g_object_set_data(G_OBJECT(menuitem), "gaim_account", gc->account); |
4359 | 3253 |
4786 | 3254 g_signal_connect(G_OBJECT(menuitem), "activate", |
4673 | 3255 G_CALLBACK(menu_conv_sel_send_cb), NULL); |
4359 | 3256 |
3257 gtk_widget_show(menuitem); | |
3258 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3259 } | |
3260 | |
3261 /* | |
3262 * Fill it with any accounts that still has an open (yet disabled) window | |
3263 * (signed off accounts with a window open). | |
3264 */ | |
3265 for (convs = gaim_get_conversations(); | |
3266 convs != NULL; | |
3267 convs = convs->next) { | |
3268 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3269 GaimConversation *conv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3270 GaimAccount *account; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3271 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3272 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3273 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3274 GdkPixbuf *pixbuf, *scale; |
4359 | 3275 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3276 conv = (GaimConversation *)convs->data; |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3277 |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3278 if (conv == deleted_conv) |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3279 continue; |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3280 |
4491 | 3281 account = gaim_conversation_get_account(conv); |
3282 | |
6495
8ce66049ce68
[gaim-migrate @ 7010]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
3283 if (account != NULL && account->gc == NULL) { |
4359 | 3284 if (first_offline && found_online) { |
3285 menuitem = gtk_separator_menu_item_new(); | |
3286 gtk_widget_show(menuitem); | |
3287 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3288 | |
3289 first_offline = FALSE; | |
3290 } | |
3291 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3292 /* Create a pixmap for the protocol icon. */ |
10884 | 3293 pixbuf = gaim_gtk_create_prpl_icon(account); |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3294 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3295 GDK_INTERP_BILINEAR); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3296 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3297 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3298 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3299 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3300 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3301 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3302 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3303 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3304 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3305 if (scale != NULL) g_object_unref(scale); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3306 if (pixbuf != NULL) g_object_unref(pixbuf); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3307 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3308 /* Make our menu item */ |
4359 | 3309 menuitem = gtk_radio_menu_item_new_with_label(group, |
4491 | 3310 account->username); |
4793 | 3311 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
4359 | 3312 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3313 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3314 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3315 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3316 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3317 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3318 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3319 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3320 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3321 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3322 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3323 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3324 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3325 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3326 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3327 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3328 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3329 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3330 |
4359 | 3331 gtk_widget_set_sensitive(menuitem, FALSE); |
4786 | 3332 g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
4674 | 3333 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); |
4359 | 3334 |
4786 | 3335 g_signal_connect(G_OBJECT(menuitem), "activate", |
5902
6889b89cab90
[gaim-migrate @ 6334]
Christian Hammond <chipx86@chipx86.com>
parents:
5901
diff
changeset
|
3336 G_CALLBACK(menu_conv_sel_send_cb), NULL); |
4786 | 3337 |
4359 | 3338 gtk_widget_show(menuitem); |
3339 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3340 } | |
3341 } | |
3342 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3343 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3344 |
4359 | 3345 gtk_widget_show(gtkwin->menu.send_as); |
3346 update_send_as_selection(win); | |
3347 } | |
3348 | |
3349 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3350 generate_invite_user_names(GaimConnection *gc) |
4359 | 3351 { |
6695 | 3352 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 3353 static GList *tmp = NULL; |
3354 | |
3355 if (tmp) | |
3356 g_list_free(tmp); | |
3357 | |
3358 tmp = g_list_append(NULL, ""); | |
3359 | |
3360 if (gc != NULL) { | |
4785 | 3361 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
3362 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
3363 continue; | |
6695 | 3364 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3365 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 3366 continue; |
6695 | 3367 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
3368 GaimBuddy *buddy; | |
3369 | |
3370 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
3371 continue; | |
3372 | |
3373 buddy = (GaimBuddy *)bnode; | |
3374 | |
3375 if (buddy->account == gc->account && | |
3376 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 3377 tmp = g_list_insert_sorted(tmp, buddy->name, |
3378 (GCompareFunc)g_utf8_collate); | |
6695 | 3379 } |
4359 | 3380 } |
3381 } | |
3382 } | |
3383 | |
3384 return tmp; | |
3385 } | |
3386 | |
9498 | 3387 static GdkPixbuf * |
9554 | 3388 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 3389 { |
9554 | 3390 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 3391 char *filename; |
10274 | 3392 const char *image = NULL; |
9554 | 3393 |
3394 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 3395 image = "founder.png"; |
9554 | 3396 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 3397 image = "op.png"; |
9554 | 3398 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 3399 image = "halfop.png"; |
9554 | 3400 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 3401 image = "voice.png"; |
9554 | 3402 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 3403 image = "ignored.png"; |
3404 } else { | |
3405 return NULL; | |
9554 | 3406 } |
10274 | 3407 |
3408 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
3409 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
3410 g_free(filename); | |
3411 | |
3412 if (!pixbuf) | |
3413 return NULL; | |
3414 | |
3415 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
3416 g_object_unref(pixbuf); | |
3417 | |
3418 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
3419 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 3420 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
3421 g_free(filename); | |
10274 | 3422 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 3423 g_object_unref(pixbuf); |
10274 | 3424 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
3425 g_object_unref(scale2); | |
9498 | 3426 } |
3427 | |
10274 | 3428 return scale; |
9498 | 3429 } |
3430 | |
4359 | 3431 static void |
9554 | 3432 add_chat_buddy_common(GaimConversation *conv, const char *name) |
4359 | 3433 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3434 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3435 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3436 GaimConvChat *chat; |
9554 | 3437 GaimConvChatBuddyFlags flags; |
4359 | 3438 GtkTreeIter iter; |
3439 GtkListStore *ls; | |
9498 | 3440 GdkPixbuf *pixbuf; |
4359 | 3441 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3442 chat = GAIM_CONV_CHAT(conv); |
4359 | 3443 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3444 gtkchat = gtkconv->u.chat; | |
3445 | |
3446 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3447 | |
9554 | 3448 flags = gaim_conv_chat_user_get_flags(chat, name); |
3449 pixbuf = get_chat_buddy_status_icon(chat, name, flags); | |
9498 | 3450 |
4359 | 3451 gtk_list_store_append(ls, &iter); |
9498 | 3452 gtk_list_store_set(ls, &iter, CHAT_USERS_ICON_COLUMN, pixbuf, |
9554 | 3453 CHAT_USERS_NAME_COLUMN, name, CHAT_USERS_FLAGS_COLUMN, flags, -1); |
9498 | 3454 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_NAME_COLUMN, |
4359 | 3455 GTK_SORT_ASCENDING); |
9554 | 3456 if (pixbuf) |
3457 g_object_unref(pixbuf); | |
4359 | 3458 } |
3459 | |
9605 | 3460 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3461 tab_complete(GaimConversation *conv) |
4359 | 3462 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3463 GaimGtkConversation *gtkconv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3464 GaimConvChat *chat; |
4359 | 3465 GtkTextIter cursor, word_start, start_buffer; |
3466 int start; | |
3467 int most_matched = -1; | |
3468 char *entered, *partial = NULL; | |
3469 char *text; | |
8021 | 3470 char *nick_partial; |
9605 | 3471 const char *prefix; |
4359 | 3472 GList *matches = NULL; |
9605 | 3473 GList *list = NULL; |
3474 GList *l = NULL; | |
3475 gboolean command = FALSE; | |
4359 | 3476 |
3477 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3478 | |
3479 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3480 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3481 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3482 | |
3483 word_start = cursor; | |
3484 | |
3485 /* if there's nothing there just return */ | |
3486 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
9605 | 3487 return (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) ? TRUE : FALSE; |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
3488 |
4359 | 3489 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3490 &cursor, FALSE); | |
3491 | |
3492 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3493 start = strlen(text) - 1; | |
3494 | |
8021 | 3495 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3496 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3497 start-=2; |
3498 } | |
4359 | 3499 |
3500 /* find the start of the word that we're tabbing */ | |
3501 while (start >= 0 && text[start] != ' ') { | |
3502 gtk_text_iter_backward_char(&word_start); | |
3503 start--; | |
3504 } | |
3505 | |
9605 | 3506 prefix = gaim_gtk_get_cmd_prefix(); |
3507 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3508 command = TRUE; | |
3509 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3510 } | |
3511 | |
4359 | 3512 g_free(text); |
3513 | |
3514 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3515 &cursor, FALSE); | |
3516 | |
8021 | 3517 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3518 g_free(entered); |
9605 | 3519 return (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) ? TRUE : FALSE; |
4359 | 3520 } |
3521 | |
8021 | 3522 nick_partial = g_malloc(strlen(entered)+1); |
3523 | |
9605 | 3524 if (command) { |
3525 list = gaim_cmd_list(conv); | |
3526 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
3527 chat = GAIM_CONV_CHAT(conv); | |
3528 list = gaim_conv_chat_get_users(chat); | |
3529 } else { | |
3530 g_free(nick_partial); | |
3531 g_free(entered); | |
3532 return FALSE; | |
3533 } | |
3534 | |
3535 for (l = list; l; l = l->next) { | |
3536 char *name; | |
3537 | |
3538 if (command) | |
3539 name = l->data; | |
3540 else { | |
3541 GaimConvChatBuddy *cb = l->data; | |
3542 name = cb->name; | |
3543 } | |
3544 | |
3545 strncpy(nick_partial, name, strlen(entered)); | |
8172 | 3546 nick_partial[strlen(entered)] = '\0'; |
8021 | 3547 if(gaim_utf8_strcasecmp(nick_partial, entered)) |
3548 continue; | |
4359 | 3549 |
3550 /* if we're here, it's a possible completion */ | |
3551 | |
3552 if (most_matched == -1) { | |
3553 /* | |
3554 * this will only get called once, since from now | |
3555 * on most_matched is >= 0 | |
3556 */ | |
9605 | 3557 most_matched = strlen(name); |
3558 partial = g_strdup(name); | |
4359 | 3559 } |
3560 else if (most_matched) { | |
9605 | 3561 char *tmp = g_strdup(name); |
8021 | 3562 |
3563 while (gaim_utf8_strcasecmp(tmp, partial)) { | |
3564 partial[most_matched] = '\0'; | |
3565 if(most_matched < strlen(tmp)) | |
3566 tmp[most_matched] = '\0'; | |
4359 | 3567 most_matched--; |
8021 | 3568 } |
8079 | 3569 most_matched++; |
8021 | 3570 |
3571 g_free(tmp); | |
4359 | 3572 } |
3573 | |
10904 | 3574 matches = g_list_insert_sorted(matches, name, |
3575 (GCompareFunc)gaim_utf8_strcasecmp); | |
4359 | 3576 } |
3577 | |
8021 | 3578 g_free(nick_partial); |
3579 | |
4359 | 3580 /* we're only here if we're doing new style */ |
3581 | |
3582 /* if there weren't any matches, return */ | |
3583 if (!matches) { | |
3584 /* if matches isn't set partials won't be either */ | |
3585 g_free(entered); | |
9605 | 3586 if (command) |
3587 g_list_free(list); | |
3588 return (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) ? TRUE : FALSE; | |
4359 | 3589 } |
3590 | |
3591 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3592 | |
3593 if (!matches->next) { | |
3594 /* there was only one match. fill it in. */ | |
3595 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3596 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3597 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3598 | |
3599 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3600 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3601 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3602 g_free(tmp); | |
3603 } | |
3604 else | |
3605 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3606 matches->data, -1); | |
3607 | |
3608 matches = g_list_remove(matches, matches->data); | |
3609 } | |
3610 else { | |
3611 /* | |
3612 * there were lots of matches, fill in as much as possible | |
3613 * and display all of them | |
3614 */ | |
3615 char *addthis = g_malloc0(1); | |
3616 | |
3617 while (matches) { | |
3618 char *tmp = addthis; | |
3619 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3620 g_free(tmp); | |
3621 matches = g_list_remove(matches, matches->data); | |
3622 } | |
3623 | |
6982 | 3624 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3625 time(NULL)); |
3626 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3627 g_free(addthis); | |
3628 } | |
3629 | |
9605 | 3630 if (command) |
3631 g_list_free(list); | |
4359 | 3632 g_free(entered); |
3633 g_free(partial); | |
9605 | 3634 |
3635 return TRUE; | |
4359 | 3636 } |
3637 | |
3638 static GtkItemFactoryEntry menu_items[] = | |
3639 { | |
3640 /* Conversation menu */ | |
4596 | 3641 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3642 |
7887 | 3643 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, |
7859 | 3644 0, "<StockItem>", GAIM_STOCK_IM }, |
3645 | |
3646 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
3647 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3648 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3649 "<StockItem>", GTK_STOCK_FIND }, |
7859 | 3650 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, NULL }, |
4596 | 3651 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
4359 | 3652 "<StockItem>", GTK_STOCK_SAVE_AS }, |
8974 | 3653 { N_("/Conversation/Clear"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3654 |
4359 | 3655 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3656 |
9468 | 3657 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
3658 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, |
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
3659 0, NULL }, |
11114
2ace374369d1
[gaim-migrate @ 13167]
Richard Laager <rlaager@wiktel.com>
parents:
11112
diff
changeset
|
3660 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3661 "<StockItem>", GAIM_STOCK_INFO }, |
7859 | 3662 { N_("/Conversation/_Warn..."), NULL, menu_warn_cb, 0, |
3663 "<StockItem>", GAIM_STOCK_WARN }, | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3664 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3665 "<StockItem>", GAIM_STOCK_INVITE }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3666 |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
3667 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3668 |
11115
e099f00b2f93
[gaim-migrate @ 13169]
Richard Laager <rlaager@wiktel.com>
parents:
11114
diff
changeset
|
3669 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, |
7859 | 3670 "<StockItem>", GAIM_STOCK_EDIT }, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3671 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3672 "<StockItem>", GAIM_STOCK_BLOCK }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3673 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3674 "<StockItem>", GTK_STOCK_ADD }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3675 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3676 "<StockItem>", GTK_STOCK_REMOVE }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3677 |
7859 | 3678 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, |
3679 | |
8756 | 3680 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, |
7859 | 3681 "<StockItem>", GAIM_STOCK_LINK }, |
9287 | 3682 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, |
7859 | 3683 "<StockItem>", GAIM_STOCK_IMAGE }, |
3684 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3685 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3686 |
4596 | 3687 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, |
4359 | 3688 "<StockItem>", GTK_STOCK_CLOSE }, |
3689 | |
3690 /* Options */ | |
4596 | 3691 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, |
3692 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
3693 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
10377 | 3694 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, |
11115
e099f00b2f93
[gaim-migrate @ 13169]
Richard Laager <rlaager@wiktel.com>
parents:
11114
diff
changeset
|
3695 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, |
10456 | 3696 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>" }, |
4359 | 3697 }; |
3698 | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
3699 static const int menu_item_count = |
4359 | 3700 sizeof(menu_items) / sizeof(*menu_items); |
3701 | |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3702 static char * |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3703 item_factory_translate_func (const char *path, gpointer func_data) |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3704 { |
7386 | 3705 return _((char *)path); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3706 } |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3707 |
4359 | 3708 static GtkWidget * |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3709 setup_menubar(GaimConvWindow *win) |
4359 | 3710 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3711 GaimGtkWindow *gtkwin; |
5116 | 3712 GtkAccelGroup *accel_group; |
10359 | 3713 GtkWidget *box_item; |
3714 | |
4359 | 3715 gtkwin = GAIM_GTK_WINDOW(win); |
3716 | |
6398
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
3717 accel_group = gtk_accel_group_new (); |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
3718 gtk_window_add_accel_group (GTK_WINDOW (gtkwin->window), accel_group); |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
3719 g_object_unref (accel_group); |
5116 | 3720 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3721 gtkwin->menu.item_factory = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3722 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3723 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3724 gtk_item_factory_set_translate_func(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3725 item_factory_translate_func, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3726 NULL, NULL); |
4630 | 3727 |
3728 gtk_item_factory_create_items(gtkwin->menu.item_factory, menu_item_count, | |
4359 | 3729 menu_items, win); |
7420 | 3730 g_signal_connect(G_OBJECT(accel_group), "accel-changed", |
3731 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
4359 | 3732 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3733 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3734 gtkwin->menu.menubar = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3735 gtk_item_factory_get_widget(gtkwin->menu.item_factory, "<main>"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3736 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3737 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3738 gtkwin->menu.view_log = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3739 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
7295 | 3740 N_("/Conversation/View Log")); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
3741 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3742 /* --- */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3743 |
9468 | 3744 gtkwin->menu.send_file = |
3745 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3746 N_("/Conversation/Send File...")); | |
9498 | 3747 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3748 gtkwin->menu.add_pounce = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3749 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3750 N_("/Conversation/Add Buddy Pounce...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3751 |
7879 | 3752 /* --- */ |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3753 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3754 gtkwin->menu.get_info = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3755 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
7859 | 3756 N_("/Conversation/Get Info")); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3757 |
7879 | 3758 gtkwin->menu.warn = |
3759 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3760 N_("/Conversation/Warn...")); | |
3761 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3762 gtkwin->menu.invite = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3763 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3764 N_("/Conversation/Invite...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3765 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3766 /* --- */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3767 |
7879 | 3768 gtkwin->menu.alias = |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3769 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
7879 | 3770 N_("/Conversation/Alias...")); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3771 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3772 gtkwin->menu.block = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3773 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3774 N_("/Conversation/Block...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3775 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3776 gtkwin->menu.add = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3777 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3778 N_("/Conversation/Add...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3779 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3780 gtkwin->menu.remove = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3781 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3782 N_("/Conversation/Remove...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3783 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3784 /* --- */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3785 |
7879 | 3786 gtkwin->menu.insert_link = |
3787 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3788 N_("/Conversation/Insert Link...")); | |
3789 | |
3790 gtkwin->menu.insert_image = | |
3791 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3792 N_("/Conversation/Insert Image...")); | |
3793 | |
3794 /* --- */ | |
3795 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3796 gtkwin->menu.logging = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3797 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3798 N_("/Options/Enable Logging")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3799 gtkwin->menu.sounds = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3800 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3801 N_("/Options/Enable Sounds")); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3802 gtkwin->menu.show_formatting_toolbar = |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3803 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
10377 | 3804 N_("/Options/Show Formatting Toolbars")); |
9188 | 3805 gtkwin->menu.show_timestamps = |
3806 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3807 N_("/Options/Show Timestamps")); | |
10456 | 3808 gtkwin->menu.show_icon = |
3809 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3810 N_("/Options/Show Buddy Icon")); | |
4359 | 3811 |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3812 generate_send_as_items(win, NULL); |
4359 | 3813 |
10359 | 3814 box_item = gtk_menu_item_new(); |
3815 gtk_menu_item_set_right_justified(GTK_MENU_ITEM(box_item), TRUE); | |
3816 gtk_menu_shell_append(GTK_MENU_SHELL(gtkwin->menu.menubar), box_item); | |
3817 gtk_widget_show(box_item); | |
10397
566177590bd5
[gaim-migrate @ 11627]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10389
diff
changeset
|
3818 gtk_widget_set_size_request(box_item, -1, 16); |
10359 | 3819 |
3820 gtkwin->menu.menubox = gtk_hbox_new(FALSE, 0); | |
3821 gtk_container_add(GTK_CONTAINER(box_item), gtkwin->menu.menubox); | |
3822 gtk_widget_show(gtkwin->menu.menubox); | |
3823 | |
4359 | 3824 gtk_widget_show(gtkwin->menu.menubar); |
4931 | 3825 |
3826 return gtkwin->menu.menubar; | |
4359 | 3827 } |
3828 | |
10810 | 3829 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3830 { |
3831 GaimPluginProtocolInfo *prpl_info = NULL; | |
3832 GaimConnection *gc; | |
10810 | 3833 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3834 GaimGtkChatPane *gtkchat; |
8858 | 3835 const char *new_topic; |
3836 const char *current_topic; | |
7971 | 3837 |
3838 gc = gaim_conversation_get_gc(conv); | |
3839 | |
3840 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3841 return; | |
3842 | |
3843 if(prpl_info->set_chat_topic == NULL) | |
3844 return; | |
3845 | |
3846 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3847 gtkchat = gtkconv->u.chat; | |
8858 | 3848 new_topic = gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text)); |
3849 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); | |
3850 | |
3851 if(current_topic && !g_utf8_collate(new_topic, current_topic)) | |
7971 | 3852 return; |
3853 | |
8858 | 3854 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3855 new_topic); | |
7971 | 3856 } |
3857 | |
9554 | 3858 static gint |
3859 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3860 { | |
3861 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3862 char *user1 = NULL, *user2 = NULL; | |
3863 gint ret = 0; | |
3864 | |
3865 gtk_tree_model_get(model, a, CHAT_USERS_NAME_COLUMN, &user1, CHAT_USERS_FLAGS_COLUMN, &f1, -1); | |
3866 gtk_tree_model_get(model, b, CHAT_USERS_NAME_COLUMN, &user2, CHAT_USERS_FLAGS_COLUMN, &f2, -1); | |
3867 | |
3868 if (user1 == NULL || user2 == NULL) { | |
3869 if (!(user1 == NULL && user2 == NULL)) | |
3870 ret = (user1 == NULL) ? -1: 1; | |
3871 } else if (f1 != f2) { | |
3872 /* sort more important users first */ | |
3873 ret = (f1 > f2) ? -1 : 1; | |
3874 } else { | |
10904 | 3875 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3876 } |
3877 | |
3878 g_free(user1); | |
3879 g_free(user2); | |
3880 | |
3881 return ret; | |
3882 } | |
3883 | |
4359 | 3884 static GtkWidget * |
10810 | 3885 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3886 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3887 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3888 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3889 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3890 GaimConnection *gc; |
4359 | 3891 GtkWidget *vpaned, *hpaned; |
10175 | 3892 GtkWidget *vbox, *hbox, *frame; |
4359 | 3893 GtkWidget *lbox, *bbox; |
3894 GtkWidget *label; | |
3895 GtkWidget *list; | |
3896 GtkWidget *button; | |
7949 | 3897 GtkWidget *sw; |
4359 | 3898 GtkListStore *ls; |
3899 GtkCellRenderer *rend; | |
3900 GtkTreeViewColumn *col; | |
9080 | 3901 GList *focus_chain = NULL; |
4359 | 3902 |
3903 gtkchat = gtkconv->u.chat; | |
3904 gc = gaim_conversation_get_gc(conv); | |
3905 | |
3906 /* Setup the outer pane. */ | |
3907 vpaned = gtk_vpaned_new(); | |
3908 gtk_widget_show(vpaned); | |
3909 | |
3910 /* Setup the top part of the pane. */ | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3911 vbox = gtk_vbox_new(FALSE, 6); |
8914 | 3912 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3913 gtk_widget_show(vbox); |
3914 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3915 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3916 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3917 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3918 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3919 { |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3920 hbox = gtk_hbox_new(FALSE, 6); |
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3921 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3922 gtk_widget_show(hbox); |
3923 | |
3924 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3925 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3926 gtk_widget_show(label); |
3927 | |
3928 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3929 |
7971 | 3930 if(prpl_info->set_chat_topic == NULL) { |
3931 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3932 } else { | |
3933 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3934 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3935 } |
3936 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3937 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3938 gtk_widget_show(gtkchat->topic_text); |
3939 } | |
3940 | |
3941 /* Setup the horizontal pane. */ | |
3942 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3943 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3944 gtk_widget_show(hpaned); |
3945 | |
10175 | 3946 /* Setup gtkihmtml. */ |
3947 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3948 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3949 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3950 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3951 gtk_widget_show(frame); | |
3952 | |
3953 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3954 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3955 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3956 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3957 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3958 |
4359 | 3959 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3960 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3961 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3962 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3963 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3964 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3965 |
3966 /* Build the right pane. */ | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3967 lbox = gtk_vbox_new(FALSE, 6); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3968 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3969 gtk_widget_show(lbox); |
3970 | |
3971 /* Setup the label telling how many people are in the room. */ | |
3972 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3973 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3974 gtk_widget_show(gtkchat->count); | |
3975 | |
3976 /* Setup the list of users. */ | |
7949 | 3977 sw = gtk_scrolled_window_new(NULL, NULL); |
3978 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3979 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3980 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3981 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3982 gtk_widget_show(sw); | |
4359 | 3983 |
9554 | 3984 ls = gtk_list_store_new(CHAT_USERS_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, |
3985 G_TYPE_INT); | |
3986 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_NAME_COLUMN, | |
3987 sort_chat_users, NULL, NULL); | |
9498 | 3988 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_NAME_COLUMN, |
4359 | 3989 GTK_SORT_ASCENDING); |
3990 | |
3991 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3992 | |
9498 | 3993 rend = gtk_cell_renderer_pixbuf_new(); |
3994 | |
4359 | 3995 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3996 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
9554 | 3997 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); |
3998 | |
9498 | 3999 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 4000 |
4001 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
4002 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 4003 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
4004 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 4005 |
9498 | 4006 rend = gtk_cell_renderer_text_new(); |
4007 | |
4359 | 4008 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 4009 "text", CHAT_USERS_NAME_COLUMN, NULL); |
4359 | 4010 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); |
4011 | |
4012 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
4013 | |
4014 gtk_widget_set_size_request(list, 150, -1); | |
4015 | |
4016 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
4017 gtk_widget_show(list); | |
4018 | |
4019 gtkchat->list = list; | |
4020 | |
7949 | 4021 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 4022 |
4023 /* Setup the user list toolbar. */ | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4024 bbox = gtk_hbox_new(TRUE, 6); |
4359 | 4025 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
4026 gtk_widget_show(bbox); | |
4027 | |
4028 /* IM */ | |
10221 | 4029 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 4030 GAIM_BUTTON_VERTICAL); |
10500 | 4031 gtkchat->userlist_im = button; |
4359 | 4032 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
4033 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
|
4034 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 4035 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 4036 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 4037 |
4038 gtk_widget_show(button); | |
4039 | |
4040 /* Ignore */ | |
4041 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
4042 GAIM_BUTTON_VERTICAL); | |
10500 | 4043 gtkchat->userlist_ignore = button; |
4359 | 4044 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
4045 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
|
4046 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
4047 _("Ignore the user"), NULL); |
4359 | 4048 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
4049 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 4050 gtk_widget_show(button); |
4051 | |
4052 /* Info */ | |
4053 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
4054 GAIM_BUTTON_VERTICAL); | |
10500 | 4055 gtkchat->userlist_info = button; |
4359 | 4056 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
4057 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4058 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
4059 _("Get the user's information"), NULL); |
4359 | 4060 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 4061 G_CALLBACK(info_cb), gtkconv); |
4359 | 4062 |
4063 gtk_widget_show(button); | |
4064 | |
10175 | 4065 /* Setup the bottom half of the conversation window */ |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4066 vbox = gtk_vbox_new(FALSE, 6); |
8914 | 4067 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4068 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4069 |
9332 | 4070 gtkconv->lower_hbox = gtk_hbox_new(FALSE, 6); |
4071 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); | |
4072 gtk_widget_show(gtkconv->lower_hbox); | |
4073 | |
4074 vbox = gtk_vbox_new(FALSE, 6); | |
4075 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); | |
4076 gtk_widget_show(vbox); | |
4077 | |
10175 | 4078 /* Setup the toolbar, entry widget and all signals */ |
4079 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 4080 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 4081 gtk_widget_show(frame); |
4082 | |
9005 | 4083 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 4084 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 4085 gaim_account_get_protocol_name(conv->account)); |
10175 | 4086 gtk_widget_set_size_request(gtkconv->entry, -1, |
4087 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4088 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4089 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 4090 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 4091 |
4092 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 4093 G_CALLBACK(entry_key_press_cb), gtkconv); |
10115 | 4094 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
10810 | 4095 G_CALLBACK(send_cb), gtkconv); |
4359 | 4096 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 4097 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 4098 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 4099 G_CALLBACK(size_allocate_cb), gtkconv); |
4100 | |
4101 default_formatize(gtkconv); | |
4359 | 4102 |
9080 | 4103 /* |
4104 * Focus for chat windows should be as follows: | |
4105 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
4106 * user list buttons -> entry -> buttons at bottom | |
4107 */ | |
9332 | 4108 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4109 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
4110 | |
4359 | 4111 return vpaned; |
4112 } | |
4113 | |
4114 static GtkWidget * | |
10810 | 4115 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 4116 { |
10810 | 4117 GaimConversation *conv = gtkconv->active_conv; |
10175 | 4118 GtkWidget *frame; |
4359 | 4119 GtkWidget *paned; |
10175 | 4120 GtkWidget *vbox; |
4121 GtkWidget *vbox2; | |
9080 | 4122 GList *focus_chain = NULL; |
4359 | 4123 |
10175 | 4124 /* Setup the outer pane */ |
4359 | 4125 paned = gtk_vpaned_new(); |
4126 gtk_widget_show(paned); | |
4127 | |
10175 | 4128 /* Setup the top part of the pane */ |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4129 vbox = gtk_vbox_new(FALSE, 6); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
4130 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 4131 gtk_widget_show(vbox); |
4132 | |
10175 | 4133 /* Setup the gtkimhtml widget */ |
4134 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
4135 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 4136 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 4137 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
4138 gtk_widget_show(frame); | |
4139 | |
4140 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4141 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4142 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 4143 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 4144 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 4145 |
4146 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 4147 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 4148 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 4149 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 4150 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 4151 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 4152 |
10175 | 4153 /* Setup the bottom half of the conversation window */ |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4154 vbox2 = gtk_vbox_new(FALSE, 6); |
8914 | 4155 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4156 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4157 |
9332 | 4158 gtkconv->lower_hbox = gtk_hbox_new(FALSE, 6); |
4159 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); | |
4160 gtk_widget_show(gtkconv->lower_hbox); | |
4161 | |
4162 vbox2 = gtk_vbox_new(FALSE, 6); | |
4163 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); | |
4164 gtk_widget_show(vbox2); | |
8821 | 4165 |
10175 | 4166 /* Setup the toolbar, entry widget and all signals */ |
4167 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 4168 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 4169 gtk_widget_show(frame); |
4170 | |
9005 | 4171 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 4172 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 4173 gaim_account_get_protocol_name(conv->account)); |
10175 | 4174 gtk_widget_set_size_request(gtkconv->entry, -1, |
4175 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4176 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4177 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 4178 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
|
4179 |
4359 | 4180 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 4181 G_CALLBACK(entry_key_press_cb), gtkconv); |
4182 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), gtkconv); | |
4359 | 4183 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 4184 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 4185 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 4186 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 4187 |
4188 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 4189 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 4190 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 4191 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 4192 |
8481 | 4193 /* had to move this after the imtoolbar is attached so that the |
4194 * signals get fired to toggle the buttons on the toolbar as well. | |
4195 */ | |
10810 | 4196 default_formatize(gtkconv); |
4359 | 4197 |
8758 | 4198 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 4199 gtkconv->u.im->show_icon = TRUE; |
4359 | 4200 |
9080 | 4201 /* |
4202 * Focus for IM windows should be as follows: | |
10356 | 4203 * Tab title -> conversation scrollback -> entry |
9080 | 4204 */ |
9332 | 4205 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4206 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 4207 |
4359 | 4208 return paned; |
4209 } | |
4210 | |
4211 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4212 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 4213 GtkSelectionData *sd, guint info, guint t, |
4214 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4215 { |
10810 | 4216 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4217 GaimConvWindow *win = conv->window; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4218 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4219 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4220 { |
4781 | 4221 GaimBlistNode *n = NULL; |
6695 | 4222 GaimBuddy *b; |
9622 | 4223 |
4781 | 4224 memcpy(&n, sd->data, sizeof(n)); |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4225 |
6695 | 4226 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
4227 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
4228 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
4229 b = (GaimBuddy*)n; | |
4230 else | |
4781 | 4231 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4232 |
9622 | 4233 /* |
4234 * If we already have an open conversation with this buddy, then | |
4235 * just move the conv to this window. Otherwise, create a new | |
4236 * conv and add it to this window. | |
4237 */ | |
10807 | 4238 c = gaim_find_conversation_with_account(GAIM_CONV_IM, b->name, b->account); |
9622 | 4239 if (c != NULL) { |
4240 GaimConvWindow *oldwin; | |
4241 oldwin = gaim_conversation_get_window(c); | |
4242 if (oldwin != win) { | |
10824 | 4243 gaim_conv_window_remove_conversation(oldwin, c); |
9622 | 4244 gaim_conv_window_add_conversation(win, c); |
4245 } | |
4246 } else { | |
4247 c = gaim_conversation_new(GAIM_CONV_IM, b->account, b->name); | |
4248 gaim_conv_window_add_conversation(win, c); | |
4249 } | |
4250 | |
4251 /* Make this conversation the active conversation */ | |
10827 | 4252 gaim_conv_window_switch_conversation(win, c); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4253 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4254 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 4255 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4256 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
|
4257 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4258 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4259 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4260 GaimAccount *account; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4261 |
11137 | 4262 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 4263 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4264 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4265 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4266 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4267 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4268 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4269 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4270 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4271 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4272 { |
7718 | 4273 c = gaim_conversation_new(GAIM_CONV_IM, account, username); |
4274 gaim_conv_window_add_conversation(win, c); | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4275 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4276 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4277 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4278 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4279 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4280 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4281 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4282 } |
9525 | 4283 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
10229 | 4284 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
4285 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); | |
10145 | 4286 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 4287 } |
10145 | 4288 else |
4289 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4290 } |
4359 | 4291 |
4292 /************************************************************************** | |
4293 * GTK+ window ops | |
4294 **************************************************************************/ | |
4295 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4296 gaim_gtk_new_window(GaimConvWindow *win) |
4359 | 4297 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4298 GaimGtkWindow *gtkwin; |
4359 | 4299 GtkPositionType pos; |
4300 GtkWidget *testidea; | |
4301 GtkWidget *menubar; | |
4302 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4303 gtkwin = g_malloc0(sizeof(GaimGtkWindow)); |
4359 | 4304 |
4305 win->ui_data = gtkwin; | |
4306 | |
4307 /* Create the window. */ | |
4308 gtkwin->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
4309 gtk_window_set_role(GTK_WINDOW(gtkwin->window), "conversation"); | |
9614 | 4310 gtk_window_set_resizable(GTK_WINDOW(gtkwin->window), TRUE); |
4510
4c394222c732
[gaim-migrate @ 4786]
Christian Hammond <chipx86@chipx86.com>
parents:
4505
diff
changeset
|
4311 gtk_container_set_border_width(GTK_CONTAINER(gtkwin->window), 0); |
9614 | 4312 GTK_WINDOW(gtkwin->window)->allow_shrink = TRUE; |
4359 | 4313 |
4314 g_signal_connect(G_OBJECT(gtkwin->window), "delete_event", | |
4315 G_CALLBACK(close_win_cb), win); | |
4316 | |
10971 | 4317 g_signal_connect(G_OBJECT(gtkwin->window), "focus_in_event", |
4318 G_CALLBACK(focus_win_cb), win); | |
4319 | |
4359 | 4320 /* Create the notebook. */ |
4321 gtkwin->notebook = gtk_notebook_new(); | |
4322 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4323 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); |
4359 | 4324 |
4325 #if 0 | |
4326 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
4327 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
4328 #endif | |
4329 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos); | |
4330 gtk_notebook_set_scrollable(GTK_NOTEBOOK(gtkwin->notebook), TRUE); | |
4331 gtk_notebook_popup_enable(GTK_NOTEBOOK(gtkwin->notebook)); | |
4818 | 4332 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), FALSE); |
10935 | 4333 gtk_notebook_set_show_border(GTK_NOTEBOOK(gtkwin->notebook), FALSE); |
4818 | 4334 |
4359 | 4335 gtk_widget_show(gtkwin->notebook); |
4336 | |
8189 | 4337 g_signal_connect(G_OBJECT(gtkwin->notebook), "switch_page", |
4338 G_CALLBACK(before_switch_conv_cb), win); | |
4359 | 4339 g_signal_connect_after(G_OBJECT(gtkwin->notebook), "switch_page", |
4340 G_CALLBACK(switch_conv_cb), win); | |
4341 | |
4342 /* Setup the tab drag and drop signals. */ | |
4486 | 4343 gtk_widget_add_events(gtkwin->notebook, |
4344 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
4345 g_signal_connect(G_OBJECT(gtkwin->notebook), "button_press_event", | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4346 G_CALLBACK(notebook_press_cb), win); |
4486 | 4347 g_signal_connect(G_OBJECT(gtkwin->notebook), "button_release_event", |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4348 G_CALLBACK(notebook_release_cb), win); |
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4349 |
4359 | 4350 testidea = gtk_vbox_new(FALSE, 0); |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4351 |
4359 | 4352 /* Setup the menubar. */ |
4353 menubar = setup_menubar(win); | |
4354 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
4355 | |
4356 gtk_box_pack_start(GTK_BOX(testidea), gtkwin->notebook, TRUE, TRUE, 0); | |
4357 | |
4358 gtk_container_add(GTK_CONTAINER(gtkwin->window), testidea); | |
4359 | |
4360 gtk_widget_show(testidea); | |
4361 } | |
4362 | |
4363 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4364 gaim_gtk_destroy_window(GaimConvWindow *win) |
4359 | 4365 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4366 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4367 |
4368 gtk_widget_destroy(gtkwin->window); | |
4369 | |
4630 | 4370 g_object_unref(G_OBJECT(gtkwin->menu.item_factory)); |
4371 | |
4359 | 4372 g_free(gtkwin); |
4373 win->ui_data = NULL; | |
4374 } | |
4375 | |
4376 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4377 gaim_gtk_show(GaimConvWindow *win) |
4359 | 4378 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4379 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4380 |
4381 gtk_widget_show(gtkwin->window); | |
4382 } | |
4383 | |
4384 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4385 gaim_gtk_hide(GaimConvWindow *win) |
4359 | 4386 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4387 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4388 |
4389 gtk_widget_hide(gtkwin->window); | |
4390 } | |
4391 | |
4392 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4393 gaim_gtk_raise(GaimConvWindow *win) |
4359 | 4394 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4395 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4396 |
9728 | 4397 gtk_widget_show(gtkwin->window); |
4398 gtk_window_deiconify(GTK_WINDOW(gtkwin->window)); | |
4399 gdk_window_raise(gtkwin->window->window); | |
4359 | 4400 } |
4401 | |
4402 static void | |
10827 | 4403 gaim_gtk_switch_conversation(GaimConvWindow *win, GaimConversation *conv) |
4359 | 4404 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4405 GaimGtkWindow *gtkwin; |
10827 | 4406 GaimGtkConversation *gtkconv = conv->ui_data; |
4359 | 4407 |
4408 gtkwin = GAIM_GTK_WINDOW(win); | |
4409 | |
10827 | 4410 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), gtk_notebook_page_num(GTK_NOTEBOOK(gtkwin->notebook), gtkconv->tab_cont)); |
4359 | 4411 } |
4412 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4413 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4414 { |
10145 | 4415 GTK_IMHTML_DND_TARGETS, |
4416 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
4417 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4418 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4419 |
10810 | 4420 static GaimGtkConversation * |
4421 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
4422 { | |
4423 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
4424 GaimContact *c; | |
4425 GaimBlistNode *cn; | |
10935 | 4426 |
10810 | 4427 if (!bud) |
4428 return NULL; | |
10935 | 4429 |
10810 | 4430 if (!(c = gaim_buddy_get_contact(bud))) |
4431 return NULL; | |
10935 | 4432 |
10810 | 4433 cn = (GaimBlistNode *)c; |
4434 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
4435 GaimConversation *conv; | |
4436 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_IM, b->name, b->account))) { | |
4437 if (conv->ui_data) | |
4438 return conv->ui_data; | |
4439 } | |
4440 } | |
10935 | 4441 |
10810 | 4442 return NULL; |
4443 } | |
4444 | |
4359 | 4445 static void |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4446 gaim_gtk_add_conversation(GaimConvWindow *win, GaimConversation *conv) |
4359 | 4447 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4448 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4449 GaimGtkConversation *gtkconv, *focus_gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4450 GaimConversation *focus_conv; |
4359 | 4451 GtkWidget *pane = NULL; |
4452 GtkWidget *tab_cont; | |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4453 GtkWidget *tabby, *menu_tabby; |
10053
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4454 GtkWidget *close_image; |
4359 | 4455 gboolean new_ui; |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4456 GaimConversationType conv_type; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4457 const char *name; |
10449 | 4458 gint close_button_width, close_button_height, focus_width, focus_pad; |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4459 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4460 name = gaim_conversation_get_name(conv); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4461 conv_type = gaim_conversation_get_type(conv); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4462 gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4463 |
4464 if (conv->ui_data != NULL) { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4465 gtkconv = (GaimGtkConversation *)conv->ui_data; |
4359 | 4466 |
4467 tab_cont = gtkconv->tab_cont; | |
4468 | |
4469 new_ui = FALSE; | |
10810 | 4470 } else if (conv_type == GAIM_CONV_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { |
4471 conv->ui_data = gtkconv; | |
4472 gtkconv->active_conv = conv; | |
4473 if (!g_list_find(gtkconv->convs, conv)) | |
4474 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
4475 return; | |
4476 } else { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4477 gtkconv = g_malloc0(sizeof(GaimGtkConversation)); |
4359 | 4478 conv->ui_data = gtkconv; |
10810 | 4479 gtkconv->active_conv = conv; |
4480 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
4359 | 4481 |
4482 /* Setup some initial variables. */ | |
9749 | 4483 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); |
4359 | 4484 gtkconv->tooltips = gtk_tooltips_new(); |
4485 | |
7879 | 4486 if (conv_type == GAIM_CONV_IM) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4487 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); |
4359 | 4488 gtkconv->u.im->a_virgin = TRUE; |
4489 | |
10810 | 4490 pane = setup_im_pane(gtkconv); |
4359 | 4491 } |
7879 | 4492 else if (conv_type == GAIM_CONV_CHAT) { |
4493 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
4494 | |
10810 | 4495 pane = setup_chat_pane(gtkconv); |
7879 | 4496 } |
4359 | 4497 |
4498 if (pane == NULL) { | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4499 if (conv_type == GAIM_CONV_CHAT) g_free(gtkconv->u.chat); |
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4500 else if (conv_type == GAIM_CONV_IM) g_free(gtkconv->u.im); |
4359 | 4501 |
4502 g_free(gtkconv); | |
4503 conv->ui_data = NULL; | |
4504 | |
4505 return; | |
4506 } | |
4507 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4508 /* Setup drag-and-drop */ |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4509 gtk_drag_dest_set(pane, |
9300 | 4510 GTK_DEST_DEFAULT_MOTION | |
4511 GTK_DEST_DEFAULT_DROP, | |
4512 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4513 GDK_ACTION_COPY); | |
4514 gtk_drag_dest_set(pane, | |
4515 GTK_DEST_DEFAULT_MOTION | | |
4516 GTK_DEST_DEFAULT_DROP, | |
4517 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4518 GDK_ACTION_COPY); | |
4519 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4520 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4521 GDK_ACTION_COPY); | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
4522 |
9300 | 4523 gtk_drag_dest_set(gtkconv->entry, 0, |
4524 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4525 GDK_ACTION_COPY); | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
4526 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4527 g_signal_connect(G_OBJECT(pane), "drag_data_received", |
10810 | 4528 G_CALLBACK(conv_dnd_recv), gtkconv); |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4529 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", |
10810 | 4530 G_CALLBACK(conv_dnd_recv), gtkconv); |
8105 | 4531 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", |
10810 | 4532 G_CALLBACK(conv_dnd_recv), gtkconv); |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
4533 |
4359 | 4534 /* Setup the container for the tab. */ |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4535 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, 6); |
10827 | 4536 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4537 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), 6); |
4359 | 4538 gtk_container_add(GTK_CONTAINER(tab_cont), pane); |
4539 gtk_widget_show(pane); | |
4540 | |
4541 new_ui = TRUE; | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
4542 |
4359 | 4543 gtkconv->make_sound = TRUE; |
5902
6889b89cab90
[gaim-migrate @ 6334]
Christian Hammond <chipx86@chipx86.com>
parents:
5901
diff
changeset
|
4544 |
10377 | 4545 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) |
8329
9dd7c75ed433
[gaim-migrate @ 9053]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
4546 gtk_widget_show(gtkconv->toolbar); |
10190 | 4547 else |
4548 gtk_widget_hide(gtkconv->toolbar); | |
8329
9dd7c75ed433
[gaim-migrate @ 9053]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
4549 |
10389 | 4550 gtkconv->show_timestamps = TRUE; |
4551 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); | |
9188 | 4552 |
8176 | 4553 g_signal_connect_swapped(G_OBJECT(pane), "focus", |
10810 | 4554 G_CALLBACK(gtk_widget_grab_focus), |
4555 gtkconv->entry); | |
4359 | 4556 } |
4557 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4558 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, 6); |
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4559 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, 6); |
4359 | 4560 |
4561 /* Close button. */ | |
4562 gtkconv->close = gtk_button_new(); | |
10449 | 4563 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); |
4564 if (gtk_check_version(2, 4, 2) == NULL) | |
4565 { | |
4566 /* Need to account for extra padding around the gtkbutton */ | |
4567 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
4568 "focus-line-width", &focus_width, | |
4569 "focus-padding", &focus_pad, | |
4570 NULL); | |
4571 close_button_width += (focus_width + focus_pad) * 2; | |
4572 close_button_height += (focus_width + focus_pad) * 2; | |
4573 } | |
4574 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
4575 close_button_width, close_button_height); | |
4576 | |
7446
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4577 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); |
10053
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4578 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); |
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4579 gtk_widget_show(close_image); |
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4580 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); |
4359 | 4581 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4582 _("Close conversation"), NULL); |
4359 | 4583 |
4584 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
10810 | 4585 G_CALLBACK(close_conv_cb), gtkconv); |
4359 | 4586 |
7446
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4587 /* |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4588 * I love Galeon. They have a fix for that stupid annoying visible |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4589 * border bug. I love you guys! -- ChipX86 |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4590 */ |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4591 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
10810 | 4592 G_CALLBACK(tab_close_button_state_changed_cb), NULL); |
7446
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4593 |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4594 /* Status icon. */ |
6440 | 4595 gtkconv->icon = gtk_image_new(); |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4596 gtkconv->menu_icon = gtk_image_new(); |
6440 | 4597 update_tab_icon(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4598 |
4359 | 4599 /* Tab label. */ |
4600 gtkconv->tab_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
10556 | 4601 #if GTK_CHECK_VERSION(2,6,0) |
4602 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
4603 #endif | |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4604 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); |
4359 | 4605 #if 0 |
4606 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
4607 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
4608 #endif | |
4609 | |
4610 /* Pack it all together. */ | |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4611 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4612 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4613 FALSE, FALSE, 0); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4614 |
8946 | 4615 gtk_widget_show_all(gtkconv->icon); |
4616 gtk_widget_show_all(gtkconv->menu_icon); | |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4617 |
4359 | 4618 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4619 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); |
4445 | 4620 gtk_widget_show(gtkconv->tab_label); |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4621 gtk_widget_show(gtkconv->menu_label); |
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4622 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4623 |
4445 | 4624 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4625 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
10053
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4626 gtk_widget_show(gtkconv->close); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4627 |
4445 | 4628 gtk_widget_show(tabby); |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4629 gtk_widget_show(menu_tabby); |
4359 | 4630 |
7143 | 4631 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
4632 gaim_gtkconv_update_buddy_icon(conv); | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
4633 |
9297 | 4634 /* Add this pane to the conversation's notebook. */ |
9606 | 4635 gtk_notebook_append_page_menu(GTK_NOTEBOOK(gtkwin->notebook), tab_cont, tabby, menu_tabby); |
10559
c354b70d8502
[gaim-migrate @ 11937]
Luke Schierer <lschiere@pidgin.im>
parents:
10556
diff
changeset
|
4636 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(gtkwin->notebook), tab_cont, TRUE, TRUE, GTK_PACK_START); |
10556 | 4637 |
4359 | 4638 |
4639 gtk_widget_show(tab_cont); | |
4640 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4641 if (gaim_conv_window_get_conversation_count(win) == 1) { |
4818 | 4642 /* Er, bug in notebooks? Switch to the page manually. */ |
4359 | 4643 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), 0); |
4851 | 4644 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4645 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4646 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4647 } |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4648 else |
4818 | 4649 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), TRUE); |
4359 | 4650 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4651 focus_conv = g_list_nth_data(gaim_conv_window_get_conversations(win), |
5204 | 4652 gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook))); |
4653 focus_gtkconv = GAIM_GTK_CONVERSATION(focus_conv); | |
4654 gtk_widget_grab_focus(focus_gtkconv->entry); | |
4359 | 4655 |
4656 if (!new_ui) | |
4657 g_object_unref(gtkconv->tab_cont); | |
4658 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4659 if (gaim_conv_window_get_conversation_count(win) == 1) |
4685 | 4660 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 4661 } |
4662 | |
4663 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4664 gaim_gtk_remove_conversation(GaimConvWindow *win, GaimConversation *conv) |
4359 | 4665 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4666 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4667 GaimGtkConversation *gtkconv; |
4359 | 4668 unsigned int index; |
4818 | 4669 GaimConversationType conv_type; |
4670 | |
4671 conv_type = gaim_conversation_get_type(conv); | |
4359 | 4672 gtkwin = GAIM_GTK_WINDOW(win); |
4673 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10827 | 4674 index = gtk_notebook_page_num(GTK_NOTEBOOK(gtkwin->notebook), gtkconv->tab_cont); |
4359 | 4675 |
4676 g_object_ref(gtkconv->tab_cont); | |
4677 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
4678 | |
4679 gtk_notebook_remove_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
4680 | |
4818 | 4681 /* go back to tabless if need be */ |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4682 if (gaim_conv_window_get_conversation_count(win) <= 2) { |
4818 | 4683 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4684 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); |
4818 | 4685 } |
4686 | |
4687 | |
4359 | 4688 /* If this window is setup with an inactive gc, regenerate the menu. */ |
4818 | 4689 if (conv_type == GAIM_CONV_IM && |
4359 | 4690 gaim_conversation_get_gc(conv) == NULL) { |
4691 | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
4692 generate_send_as_items(win, conv); |
4359 | 4693 } |
4694 } | |
4695 | |
10827 | 4696 GaimGtkConversation * |
4697 gaim_gtk_get_gtkconv_at_index(const GaimConvWindow *win, int index) | |
4698 { | |
4699 GaimGtkWindow *gtkwin; | |
4700 GtkWidget *tab_cont; | |
4701 | |
4702 gtkwin = GAIM_GTK_WINDOW(win); | |
4703 | |
4704 if (index == -1) | |
4705 index = 0; | |
4706 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
4707 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
4708 } | |
4709 | |
4710 static GaimConversation * | |
4711 gaim_gtk_get_active_conversation(const GaimConvWindow *win) | |
4712 { | |
4713 GaimGtkWindow *gtkwin; | |
4714 GaimGtkConversation *gtkconv; | |
4715 int index; | |
4716 GtkWidget *tab_cont; | |
4717 | |
4718 gtkwin = GAIM_GTK_WINDOW(win); | |
4719 | |
4720 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook)); | |
4721 if (index == -1) | |
4722 index = 0; | |
4723 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
4724 if (!tab_cont) | |
4725 return NULL; | |
4726 gtkconv = g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
4727 return gtkconv->active_conv; | |
4728 } | |
4729 | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4730 static gboolean |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4731 gaim_gtk_has_focus(GaimConvWindow *win) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4732 { |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4733 GaimGtkWindow *gtkwin; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4734 gboolean has_focus = FALSE; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4735 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4736 gtkwin = GAIM_GTK_WINDOW(win); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4737 g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4738 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4739 return has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4740 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4741 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4742 static GaimConvWindowUiOps window_ui_ops = |
4359 | 4743 { |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
4744 gaim_gtk_conversations_get_conv_ui_ops, |
4359 | 4745 gaim_gtk_new_window, |
4746 gaim_gtk_destroy_window, | |
4747 gaim_gtk_show, | |
4748 gaim_gtk_hide, | |
4749 gaim_gtk_raise, | |
4750 gaim_gtk_switch_conversation, | |
4751 gaim_gtk_add_conversation, | |
4752 gaim_gtk_remove_conversation, | |
10827 | 4753 gaim_gtk_get_active_conversation, |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4754 gaim_gtk_has_focus |
4359 | 4755 }; |
4756 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4757 GaimConvWindowUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
4758 gaim_gtk_conversations_get_win_ui_ops(void) |
4359 | 4759 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4760 return &window_ui_ops; |
4359 | 4761 } |
4762 | |
4763 /************************************************************************** | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4764 * Conversation UI operations |
4359 | 4765 **************************************************************************/ |
4766 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4767 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4768 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4769 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4770 |
10810 | 4771 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4772 /* Don't destroy ourselves until all our convos are gone */ | |
4773 if (gtkconv->convs) | |
4774 return; | |
4775 | |
9504 | 4776 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4777 gaim_request_close_with_handle(conv); | |
4359 | 4778 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4779 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4780 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4781 |
4359 | 4782 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
4755 | 4783 if (gtkconv->u.im->icon_timer != 0) |
4784 g_source_remove(gtkconv->u.im->icon_timer); | |
4785 | |
4359 | 4786 if (gtkconv->u.im->anim != NULL) |
4793 | 4787 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4788 |
4789 g_free(gtkconv->u.im); | |
4790 } | |
4791 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
4792 g_free(gtkconv->u.chat); | |
4793 } | |
4794 | |
4633 | 4795 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4796 | |
4359 | 4797 g_free(gtkconv); |
4798 } | |
4799 | |
4800 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4801 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4802 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4803 time_t mtime) |
4359 | 4804 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4805 GaimGtkConversation *gtkconv; |
8630 | 4806 GaimConvWindow *gaimwin; |
4807 GaimGtkWindow *gtkwin; | |
4808 gboolean has_focus; | |
4359 | 4809 |
4810 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10810 | 4811 gtkconv->active_conv = conv; |
8630 | 4812 gaimwin = gaim_conversation_get_window(conv); |
4813 gtkwin = GAIM_GTK_WINDOW(gaimwin); | |
4814 | |
4815 g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); | |
4359 | 4816 |
4382
76223649765b
[gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents:
4378
diff
changeset
|
4817 /* Play a sound, if specified in prefs. */ |
8630 | 4818 if (gtkconv->make_sound && !((gaim_conv_window_get_active_conversation(gaimwin) == conv) && |
8633 | 4819 !gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus)) { |
6621 | 4820 if (flags & GAIM_MESSAGE_RECV) { |
4359 | 4821 if (gtkconv->u.im->a_virgin && |
5820 | 4822 gaim_prefs_get_bool("/gaim/gtk/sound/enabled/first_im_recv")) { |
4359 | 4823 |
4561 | 4824 gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE); |
4359 | 4825 } |
4826 else | |
4561 | 4827 gaim_sound_play_event(GAIM_SOUND_RECEIVE); |
4359 | 4828 } |
4829 else { | |
4561 | 4830 gaim_sound_play_event(GAIM_SOUND_SEND); |
4359 | 4831 } |
4832 } | |
4833 | |
4834 gtkconv->u.im->a_virgin = FALSE; | |
4835 | |
6982 | 4836 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4837 } |
4838 | |
4839 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4840 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4841 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4842 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4843 GaimGtkConversation *gtkconv; |
8630 | 4844 GaimConvWindow *gaimwin; |
4845 GaimGtkWindow *gtkwin; | |
4846 gboolean has_focus; | |
4359 | 4847 |
4848 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10810 | 4849 gtkconv->active_conv = conv; |
8630 | 4850 gaimwin = gaim_conversation_get_window(conv); |
4851 gtkwin = GAIM_GTK_WINDOW(gaimwin); | |
4852 | |
4853 g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); | |
4359 | 4854 |
4382
76223649765b
[gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents:
4378
diff
changeset
|
4855 /* Play a sound, if specified in prefs. */ |
8630 | 4856 if (gtkconv->make_sound && !((gaim_conv_window_get_active_conversation(gaimwin) == conv) && |
9704 | 4857 !gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus) && |
4858 !(flags & GAIM_MESSAGE_DELAYED) && | |
4859 !(flags & GAIM_MESSAGE_SYSTEM)) { | |
4860 | |
6621 | 4861 if (!(flags & GAIM_MESSAGE_WHISPER) && (flags & GAIM_MESSAGE_SEND)) |
4561 | 4862 gaim_sound_play_event(GAIM_SOUND_CHAT_YOU_SAY); |
9704 | 4863 else if (flags & GAIM_MESSAGE_RECV) { |
6621 | 4864 if ((flags & GAIM_MESSAGE_NICK) && |
9584 | 4865 gaim_prefs_get_bool("/gaim/gtk/sound/enabled/nick_said")) { |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4866 |
4561 | 4867 gaim_sound_play_event(GAIM_SOUND_CHAT_NICK); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4868 } |
4359 | 4869 else |
4561 | 4870 gaim_sound_play_event(GAIM_SOUND_CHAT_SAY); |
4359 | 4871 } |
4872 } | |
4873 | |
10398 | 4874 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4875 |
6982 | 4876 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4877 } |
4878 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4879 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4880 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4881 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4882 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4883 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4884 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4885 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4886 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4887 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4888 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4889 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4890 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4891 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4892 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4893 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4894 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4895 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4896 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4897 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4898 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4899 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4900 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4901 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4902 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4903 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4904 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4905 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4906 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4907 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4908 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4909 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4910 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4911 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4912 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4913 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4914 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4915 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4916 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4917 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4918 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4919 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4920 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4921 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4922 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4923 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4924 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4925 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4926 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4927 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4928 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4929 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4930 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4931 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4932 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4933 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4934 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4935 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4936 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4937 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4938 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4939 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4940 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4941 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4942 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4943 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4944 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4945 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4946 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4947 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4948 buddytag = gtk_text_buffer_create_tag( |
11096 | 4949 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4950 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4951 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4952 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4953 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4954 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4955 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4956 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4957 |
4359 | 4958 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4959 gaim_gtkconv_write_conv(GaimConversation *conv, const char *who, |
6982 | 4960 const char *message, GaimMessageFlags flags, |
4359 | 4961 time_t mtime) |
4962 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4963 GaimGtkConversation *gtkconv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4964 GaimConvWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4965 GaimConnection *gc; |
4359 | 4966 int gtk_font_options = 0; |
4967 char buf2[BUF_LONG]; | |
4968 char mdate[64]; | |
4969 char color[10]; | |
4970 char *str; | |
4971 char *with_font_tag; | |
4896 | 4972 char *sml_attrib = NULL; |
6982 | 4973 size_t length = strlen(message) + 1; |
4895 | 4974 |
4359 | 4975 gtkconv = GAIM_GTK_CONVERSATION(conv); |
10810 | 4976 gtkconv->active_conv = conv; |
4359 | 4977 gc = gaim_conversation_get_gc(conv); |
4978 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4979 win = gaim_conversation_get_window(conv); |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4980 |
8677 | 4981 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
4982 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
4983 | |
5133 | 4984 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4985 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4986 else | |
4987 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4988 |
4896 | 4989 if(gc) |
9699 | 4990 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4991 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4992 |
10503 | 4993 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4994 |
10488 | 4995 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_formatting")) |
10503 | 4996 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES; |
4359 | 4997 |
7956 | 4998 /* this is gonna crash one day, I can feel it. */ |
4999 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 5000 OPT_PROTO_USE_POINTSIZE) { |
10503 | 5001 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5002 } |
4359 | 5003 |
10737 | 5004 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 5005 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 5006 g_snprintf(buf2, sizeof(buf2), |
8690 | 5007 "<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
|
5008 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 5009 |
8962 | 5010 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 5011 |
8722 | 5012 } else if (flags & GAIM_MESSAGE_ERROR) { |
5013 g_snprintf(buf2, sizeof(buf2), | |
9627 | 5014 "<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
|
5015 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 5016 |
8962 | 5017 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
5018 | |
7431 | 5019 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 5020 g_snprintf(buf2, BUF_LONG, |
8690 | 5021 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
5022 sml_attrib ? sml_attrib : "", message); |
7440 | 5023 |
10884 | 5024 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
10346 | 5025 } else if (flags & GAIM_MESSAGE_RAW) { |
10348 | 5026 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, 0); |
10346 | 5027 } else { |
4895 | 5028 char *new_message = g_memdup(message, length); |
9613 | 5029 char *who_escaped = (who ? g_markup_escape_text(who, strlen(who)) : g_strdup("")); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
5030 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
5031 * escaped entities making the string longer */ |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
5032 int tag_start_offset = (who ? (strlen(who_escaped) - strlen(who)) : 0); |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
5033 int tag_end_offset = 0; |
7440 | 5034 |
6621 | 5035 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 5036 str = g_malloc(1024); |
7440 | 5037 |
4359 | 5038 /* If we're whispering, it's not an autoresponse. */ |
10504 | 5039 if (gaim_message_meify(new_message, -1 )) { |
8908 | 5040 g_snprintf(str, 1024, "***%s", who_escaped); |
4359 | 5041 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
5042 tag_start_offset += 3; |
4359 | 5043 } |
5044 else { | |
8908 | 5045 g_snprintf(str, 1024, "*%s*:", who_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
5046 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5047 tag_end_offset = 2; |
4359 | 5048 strcpy(color, "#00FF00"); |
5049 } | |
7440 | 5050 } |
4359 | 5051 else { |
10504 | 5052 if (gaim_message_meify(new_message, -1)) { |
4359 | 5053 str = g_malloc(1024); |
7440 | 5054 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5055 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
8908 | 5056 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, who_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
5057 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5058 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5059 } else { |
8908 | 5060 g_snprintf(str, 1024, "***%s", who_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
5061 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5062 } |
7440 | 5063 |
6621 | 5064 if (flags & GAIM_MESSAGE_NICK) |
4359 | 5065 strcpy(color, "#AF7F00"); |
5066 else | |
5067 strcpy(color, "#062585"); | |
5068 } | |
5069 else { | |
5070 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5071 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
8908 | 5072 g_snprintf(str, 1024, "%s %s", who_escaped, AUTO_RESPONSE); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
5073 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5074 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5075 } else { |
8908 | 5076 g_snprintf(str, 1024, "%s:", who_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5077 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5078 } |
6621 | 5079 if (flags & GAIM_MESSAGE_NICK) |
4359 | 5080 strcpy(color, "#AF7F00"); |
6621 | 5081 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 5082 if (flags & GAIM_MESSAGE_COLORIZE) { |
5083 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); | |
5084 GdkColor col = nick_colors[g_str_hash(who) % NUM_NICK_COLORS]; | |
5085 float scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * | |
5086 (LUMINANCE(style->white)/MAX(MAX(col.red, col.blue), col.green))); | |
5087 if (scale > 1) { /* The colors are chosen to look fine on white; we should never have to darken */ | |
5088 col.red = col.red * scale; | |
5089 col.green = col.green * scale; | |
5090 col.blue = col.blue * scale; | |
5091 } | |
10346 | 5092 |
10108 | 5093 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
5094 col.red >> 8, col.green >> 8, col.blue >> 8); | |
5095 } else | |
7854 | 5096 strcpy(color, RECV_COLOR); |
4359 | 5097 } |
6621 | 5098 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 5099 strcpy(color, SEND_COLOR); |
10892 | 5100 else { |
5101 gaim_debug_error("gtkconv", "message missing flags\n"); | |
5102 strcpy(color, "#000000"); | |
5103 } | |
4359 | 5104 } |
5105 } | |
10892 | 5106 |
5107 if(who_escaped) | |
5108 g_free(who_escaped); | |
4359 | 5109 g_snprintf(buf2, BUF_LONG, |
8380 | 5110 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
7431 | 5111 "<B>%s</B></FONT> ", |
5112 color, sml_attrib ? sml_attrib : "", mdate, str); | |
7440 | 5113 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5114 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5115 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5116 if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5117 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5118 GtkTextTag *buddytag = get_buddy_tag(conv, who); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5119 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5120 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5121 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5122 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5123 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5124 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5125 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5126 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5127 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5128 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5129 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5130 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
5131 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5132 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5133 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5134 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5135 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
5136 |
4359 | 5137 g_free(str); |
5138 | |
4895 | 5139 if(gc){ |
4896 | 5140 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 5141 char *post = "</font>"; |
5142 int pre_len = strlen(pre); | |
5143 int post_len = strlen(post); | |
7440 | 5144 |
4895 | 5145 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 5146 |
4895 | 5147 strcpy(with_font_tag, pre); |
5148 memcpy(with_font_tag + pre_len, new_message, length); | |
5149 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 5150 |
4895 | 5151 length += pre_len + post_len; |
5152 g_free(pre); | |
5153 } | |
4608 | 5154 else |
4895 | 5155 with_font_tag = g_memdup(new_message, length); |
7440 | 5156 |
8962 | 5157 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
5158 with_font_tag, gtk_font_options); | |
7440 | 5159 |
5160 g_free(with_font_tag); | |
7447 | 5161 g_free(new_message); |
7440 | 5162 } |
5163 | |
5012 | 5164 if(sml_attrib) |
5165 g_free(sml_attrib); | |
4359 | 5166 } |
5167 | |
5168 static void | |
9846 | 5169 gaim_gtkconv_chat_add_user(GaimConversation *conv, const char *user, gboolean new_arrival) |
4359 | 5170 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5171 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5172 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5173 GaimGtkChatPane *gtkchat; |
4359 | 5174 char tmp[BUF_LONG]; |
5175 int num_users; | |
5176 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5177 chat = GAIM_CONV_CHAT(conv); |
4359 | 5178 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5179 gtkchat = gtkconv->u.chat; | |
5180 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5181 num_users = g_list_length(gaim_conv_chat_get_users(chat)); |
4359 | 5182 |
5183 g_snprintf(tmp, sizeof(tmp), | |
5184 ngettext("%d person in room", "%d people in room", | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
5185 num_users), num_users); |
4359 | 5186 |
5187 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
5188 | |
9846 | 5189 if (gtkconv->make_sound && new_arrival) |
4561 | 5190 gaim_sound_play_event(GAIM_SOUND_CHAT_JOIN); |
4359 | 5191 |
9554 | 5192 add_chat_buddy_common(conv, user); |
4359 | 5193 } |
5194 | |
5195 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5196 gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5197 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5198 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5199 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5200 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5201 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5202 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5203 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5204 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5205 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5206 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5207 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5208 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5209 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
|
5210 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5211 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5212 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5213 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5214 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5215 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5216 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5217 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5218 for (l = users; l != NULL; l = l->next) { |
9554 | 5219 add_chat_buddy_common(conv, (char *)l->data); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5220 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5221 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5222 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5223 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5224 gaim_gtkconv_chat_rename_user(GaimConversation *conv, const char *old_name, |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5225 const char *new_name) |
4359 | 5226 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5227 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5228 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5229 GaimGtkChatPane *gtkchat; |
4359 | 5230 GtkTreeIter iter; |
5231 GtkTreeModel *model; | |
5232 int f = 1; | |
5233 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5234 chat = GAIM_CONV_CHAT(conv); |
4359 | 5235 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5236 gtkchat = gtkconv->u.chat; | |
5237 | |
9554 | 5238 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5239 | |
5240 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5241 return; | |
5242 | |
5243 while (f != 0) { | |
5244 char *val; | |
5245 | |
5246 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5247 | |
5248 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
5249 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5250 g_free(val); | |
4359 | 5251 break; |
5252 } | |
9554 | 5253 |
5254 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5255 | |
5256 g_free(val); | |
4359 | 5257 } |
5258 | |
9554 | 5259 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 5260 return; |
5261 | |
9554 | 5262 add_chat_buddy_common(conv, new_name); |
4359 | 5263 } |
5264 | |
5265 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5266 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 5267 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5268 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5269 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5270 GaimGtkChatPane *gtkchat; |
4359 | 5271 GtkTreeIter iter; |
5272 GtkTreeModel *model; | |
5273 char tmp[BUF_LONG]; | |
5274 int num_users; | |
5275 int f = 1; | |
5276 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5277 chat = GAIM_CONV_CHAT(conv); |
4359 | 5278 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5279 gtkchat = gtkconv->u.chat; | |
5280 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5281 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
|
5282 |
9554 | 5283 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5284 | |
5285 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5286 return; | |
5287 | |
5288 while (f != 0) { | |
5289 char *val; | |
5290 | |
5291 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5292 | |
5293 if (!gaim_utf8_strcasecmp(user, val)) { | |
5294 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5295 g_free(val); | |
4359 | 5296 break; |
5297 } | |
9554 | 5298 |
5299 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5300 | |
5301 g_free(val); | |
4359 | 5302 } |
5303 | |
9554 | 5304 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 5305 return; |
5306 | |
5307 g_snprintf(tmp, sizeof(tmp), | |
9554 | 5308 ngettext("%d person in room", "%d people in room", |
5309 num_users), num_users); | |
4359 | 5310 |
5311 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
5312 | |
5313 if (gtkconv->make_sound) | |
4561 | 5314 gaim_sound_play_event(GAIM_SOUND_CHAT_LEAVE); |
4359 | 5315 } |
5316 | |
5317 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5318 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5319 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5320 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5321 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5322 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5323 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5324 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5325 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5326 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5327 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5328 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5329 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5330 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5331 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5332 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5333 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5334 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
|
5335 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5336 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5337 for (l = users; l != NULL; l = l->next) { |
9554 | 5338 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5339 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
5340 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 5341 continue; |
5342 | |
5343 do { | |
5344 char *val; | |
5345 | |
5346 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
5347 CHAT_USERS_NAME_COLUMN, &val, -1); | |
5348 | |
9696 | 5349 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
5350 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 5351 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 5352 #else |
5353 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5354 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5355 #endif | |
5356 } | |
9554 | 5357 else |
5358 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5359 | |
5360 g_free(val); | |
5361 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5362 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5363 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5364 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5365 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5366 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5367 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5368 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5369 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5370 |
9554 | 5371 static void |
5372 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
5373 { | |
5374 GaimConvChat *chat; | |
5375 GaimGtkConversation *gtkconv; | |
5376 GaimGtkChatPane *gtkchat; | |
5377 GtkTreeIter iter; | |
5378 GtkTreeModel *model; | |
5379 int f = 1; | |
5380 | |
5381 chat = GAIM_CONV_CHAT(conv); | |
5382 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5383 gtkchat = gtkconv->u.chat; | |
5384 | |
5385 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
5386 | |
5387 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5388 return; | |
5389 | |
5390 while (f != 0) { | |
5391 char *val; | |
5392 | |
5393 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5394 | |
5395 if (!gaim_utf8_strcasecmp(user, val)) { | |
5396 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5397 g_free(val); | |
5398 break; | |
5399 } | |
5400 | |
5401 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5402 | |
5403 g_free(val); | |
5404 } | |
5405 | |
5406 if (!gaim_conv_chat_find_user(chat, user)) | |
5407 return; | |
5408 | |
5409 add_chat_buddy_common(conv, user); | |
5410 } | |
5411 | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5412 static gboolean |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5413 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5414 { |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5415 GaimConvWindow *win; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5416 GaimGtkWindow *gtkwin; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5417 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5418 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5419 win = gaim_conversation_get_window(conv); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5420 gtkwin = GAIM_GTK_WINDOW(win); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5421 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5422 g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5423 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5424 return has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5425 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5426 |
10526 | 5427 static gboolean |
5428 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
5429 { | |
5430 GaimGtkConversation *gtkconv; | |
5431 GtkIMHtmlSmiley *smiley; | |
5432 GdkPixbufLoader *loader; | |
5433 const char *sml; | |
5434 | |
5435 if (conv == NULL || smile == NULL) { | |
5436 return FALSE; | |
5437 } | |
5438 | |
5439 sml = gaim_account_get_protocol_name(conv->account); /* XXX this sucks */ | |
5440 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5441 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5442 | |
5443 /* TODO: implement changing a custom smiley in the middle of a conversation */ | |
5444 | |
5445 if (smiley) { | |
5446 return FALSE; | |
5447 } | |
5448 | |
5449 | |
5450 loader = gdk_pixbuf_loader_new(); | |
5451 | |
5452 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
5453 /* 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
|
5454 GtkIMHtmlSmiley by opaque */ |
10526 | 5455 smiley = g_new0(GtkIMHtmlSmiley, 1); |
5456 smiley->file = NULL; | |
5457 smiley->smile = g_strdup(smile); | |
5458 smiley->loader = loader; | |
5459 | |
5460 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
5461 if (smiley->icon) | |
5462 g_object_ref(G_OBJECT(smiley->icon)); | |
5463 | |
5464 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); | |
10537 | 5465 |
10526 | 5466 return TRUE; |
5467 } | |
5468 | |
10537 | 5469 static void |
10526 | 5470 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 5471 const guchar *data, gsize size) |
10526 | 5472 { |
5473 GaimGtkConversation *gtkconv; | |
5474 GtkIMHtmlSmiley *smiley; | |
10537 | 5475 GdkPixbufLoader *loader; |
10526 | 5476 const char *sml; |
5477 | |
5478 sml = gaim_account_get_protocol_name(conv->account); | |
5479 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5480 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5481 | |
10537 | 5482 if (!smiley) |
10526 | 5483 return; |
10537 | 5484 |
10526 | 5485 loader = smiley->loader; |
10537 | 5486 if (!loader) |
10526 | 5487 return; |
5488 | |
5489 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
5490 } | |
5491 | |
5492 static void | |
5493 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
5494 { | |
5495 GaimGtkConversation *gtkconv; | |
5496 GtkIMHtmlSmiley *smiley; | |
5497 GdkPixbufLoader *loader; | |
5498 const char *sml; | |
5499 | |
5500 g_return_if_fail(conv != NULL); | |
5501 g_return_if_fail(smile != NULL); | |
5502 | |
5503 sml = gaim_account_get_protocol_name(conv->account); | |
5504 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5505 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5506 | |
10537 | 5507 if (!smiley) |
10526 | 5508 return; |
5509 | |
5510 loader = smiley->loader; | |
5511 | |
10537 | 5512 if (!loader) |
10526 | 5513 return; |
10537 | 5514 |
10526 | 5515 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
5516 | |
5517 gdk_pixbuf_loader_close(loader, NULL); | |
5518 g_object_unref(G_OBJECT(loader)); | |
5519 smiley->loader = NULL; | |
5520 } | |
5521 | |
5522 | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5523 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5524 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 5525 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5526 GaimConvWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5527 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5528 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5529 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5530 GaimConvChat *chat; |
4359 | 5531 |
10116 | 5532 g_return_if_fail(conv != NULL); |
5533 | |
4359 | 5534 win = gaim_conversation_get_window(conv); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5535 gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 5536 gtkconv = GAIM_GTK_CONVERSATION(conv); |
10810 | 5537 conv = gtkconv->active_conv; /* Gross hack */ |
4359 | 5538 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5539 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5540 { |
4359 | 5541 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5542 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5543 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5544 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5545 |
4359 | 5546 gaim_gtkconv_update_buttons_by_protocol(conv); |
5547 | |
4685 | 5548 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 5549 |
5550 smiley_themeize(gtkconv->imhtml); | |
6394 | 5551 |
6395 | 5552 update_tab_icon(conv); |
4359 | 5553 } |
5554 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5555 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5556 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5557 { |
9472 | 5558 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5559 GaimConvIm *im = NULL; |
9472 | 5560 GaimConnection *gc = gaim_conversation_get_gc(conv); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5561 char color[8]; |
4736 | 5562 |
4359 | 5563 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5564 im = GAIM_CONV_IM(conv); |
4359 | 5565 |
9472 | 5566 if (!gc || ((gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) |
5567 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) | |
5568 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5569 | |
5570 else | |
5571 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5572 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5573 *color = '\0'; |
4359 | 5574 |
5575 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5576 gtk_widget_realize(gtkconv->tab_label); | |
5577 | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5578 if (im != NULL && gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5579 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5580 strcpy(color, "#47A046"); |
4359 | 5581 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5582 else if (im != NULL && gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5583 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5584 strcpy(color, "#D1940C"); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5585 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5586 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_NICK) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5587 { |
10873 | 5588 strcpy(color, "#0D4E91"); |
4359 | 5589 } |
8252 | 5590 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_TEXT) |
5591 { | |
5592 strcpy(color, "#DF421E"); | |
5593 } | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5594 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_EVENT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5595 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5596 strcpy(color, "#868272"); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5597 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5598 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5599 if (*color != '\0') |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5600 { |
8536 | 5601 char *html_title,*label; |
5602 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5603 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5604 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5605 label = g_strdup_printf("<span color=\"%s\">%s</span>", |
8536 | 5606 color, html_title); |
5607 g_free(html_title); | |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5608 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5609 g_free(label); |
4359 | 5610 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5611 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5612 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5613 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5614 if (conv == gaim_conv_window_get_active_conversation(win)) |
10810 | 5615 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5616 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5617 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5618 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5619 if (conv == gaim_conv_window_get_active_conversation(win)) |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5620 gtk_window_set_title(GTK_WINDOW(gtkwin->window), title); |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5621 } |
9472 | 5622 |
5623 g_free(title); | |
4359 | 5624 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5625 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5626 { |
7154 | 5627 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5628 chat = GAIM_CONV_CHAT(conv); |
4359 | 5629 gtkchat = gtkconv->u.chat; |
5630 | |
7154 | 5631 topic = gaim_conv_chat_get_topic(chat); |
5632 | |
9554 | 5633 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5634 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5635 topic ? topic : "", NULL); |
4359 | 5636 } |
5637 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5638 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5639 { |
10810 | 5640 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_conv_window_get_active_conversation(win))); |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
5641 generate_send_as_items(win, NULL); |
8946 | 5642 update_tab_icon(conv); |
9472 | 5643 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5644 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5645 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5646 { |
8946 | 5647 update_tab_icon(conv); |
4359 | 5648 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5649 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
|
5650 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5651 { |
9472 | 5652 gaim_conversation_autoset_title(conv); |
10810 | 5653 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5654 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5655 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5656 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5657 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5658 } |
10665 | 5659 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5660 { | |
10810 | 5661 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5662 } |
4359 | 5663 } |
5664 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5665 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5666 { |
5667 gaim_gtkconv_destroy, /* destroy_conversation */ | |
5668 gaim_gtkconv_write_chat, /* write_chat */ | |
5669 gaim_gtkconv_write_im, /* write_im */ | |
5670 gaim_gtkconv_write_conv, /* write_conv */ | |
5671 gaim_gtkconv_chat_add_user, /* chat_add_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5672 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5673 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5674 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5675 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5676 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
4359 | 5677 NULL, /* update_progress */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5678 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5679 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5680 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5681 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5682 gaim_gtkconv_updated /* updated */ |
5683 }; | |
5684 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5685 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5686 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5687 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5688 return &conversation_ui_ops; |
4359 | 5689 } |
5690 | |
5691 /************************************************************************** | |
5692 * Public conversation utility functions | |
5693 **************************************************************************/ | |
5694 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5695 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5696 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5697 GaimGtkConversation *gtkconv; |
7143 | 5698 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); |
4359 | 5699 |
10381 | 5700 GdkPixbufLoader *loader; |
5701 GdkPixbufAnimation *anim; | |
4359 | 5702 GError *err = NULL; |
5703 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5704 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5705 size_t len; |
4359 | 5706 |
5707 GdkPixbuf *buf; | |
5708 | |
5709 GtkWidget *event; | |
5710 GtkWidget *frame; | |
5711 GdkPixbuf *scale; | |
5712 GdkPixmap *pm; | |
5713 GdkBitmap *bm; | |
9318 | 5714 int scale_width, scale_height; |
5715 | |
5716 GaimAccount *account; | |
5717 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5718 |
9324 | 5719 GaimBuddyIcon *icon; |
5720 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5721 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5722 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5723 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_IM); |
4359 | 5724 |
5725 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10175 | 5726 |
9687 | 5727 if (!gtkconv->u.im->show_icon) |
5728 return; | |
5729 | |
9318 | 5730 account = gaim_conversation_get_account(conv); |
5731 if(account && account->gc) | |
5732 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5733 |
9845 | 5734 /* Remove the current icon stuff */ |
9885 | 5735 if (gtkconv->u.im->icon_container != NULL) |
5736 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5737 gtkconv->u.im->icon_container = NULL; | |
9845 | 5738 |
5739 if (gtkconv->u.im->anim != NULL) | |
5740 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5741 | |
9887 | 5742 gtkconv->u.im->anim = NULL; |
5743 | |
9845 | 5744 if (gtkconv->u.im->icon_timer != 0) |
5745 g_source_remove(gtkconv->u.im->icon_timer); | |
5746 | |
5747 gtkconv->u.im->icon_timer = 0; | |
5748 | |
5749 if (gtkconv->u.im->iter != NULL) | |
5750 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5751 |
10116 | 5752 gtkconv->u.im->iter = NULL; |
5753 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5754 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5755 return; |
5756 | |
5757 if (gaim_conversation_get_gc(conv) == NULL) | |
5758 return; | |
5759 | |
9324 | 5760 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5761 | |
5762 if (icon == NULL) | |
5763 return; | |
5764 | |
5765 data = gaim_buddy_icon_get_data(icon, &len); | |
5766 | |
10381 | 5767 loader = gdk_pixbuf_loader_new(); |
5768 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5769 anim = gdk_pixbuf_loader_get_animation(loader); | |
5770 if (anim) | |
5771 g_object_ref(G_OBJECT(anim)); | |
5772 gdk_pixbuf_loader_close(loader, &err); | |
5773 g_object_unref(loader); | |
5774 | |
5775 if (!anim) | |
9324 | 5776 return; |
10381 | 5777 gtkconv->u.im->anim = anim; |
9324 | 5778 |
4359 | 5779 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5780 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5781 "Buddy icon error: %s\n", err->message); |
4359 | 5782 g_error_free(err); |
5783 } | |
5784 | |
5785 if (!gtkconv->u.im->anim) | |
5786 return; | |
5787 | |
5788 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5789 gtkconv->u.im->iter = NULL; | |
5790 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5791 } else { | |
5792 gtkconv->u.im->iter = | |
8496 | 5793 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5794 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5795 if (gtkconv->u.im->animate) |
10810 | 5796 start_anim(NULL, gtkconv); |
4359 | 5797 } |
5798 | |
10483 | 5799 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5800 NULL, &scale_width, &scale_height); |
4359 | 5801 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5802 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5803 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5804 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5805 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
5806 GDK_INTERP_NEAREST); | |
5807 | |
5808 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5809 g_object_unref(G_OBJECT(scale)); |
4359 | 5810 |
8821 | 5811 |
9885 | 5812 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5813 |
4359 | 5814 frame = gtk_frame_new(NULL); |
5815 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5816 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5817 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5818 FALSE, FALSE, 0); | |
8821 | 5819 |
4359 | 5820 event = gtk_event_box_new(); |
5821 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5822 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5823 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5824 gtk_widget_show(event); |
5825 | |
4635 | 5826 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5827 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5828 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5829 gtk_widget_show(gtkconv->u.im->icon); | |
5830 | |
4793 | 5831 g_object_unref(G_OBJECT(pm)); |
4359 | 5832 |
5833 if (bm) | |
4793 | 5834 g_object_unref(G_OBJECT(bm)); |
7143 | 5835 |
10356 | 5836 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5837 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5838 |
9885 | 5839 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5840 gtk_widget_show(frame); |
5841 | |
7143 | 5842 /* The buddy icon code needs badly to be fixed. */ |
5843 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
8068 | 5844 if(conv == gaim_conv_window_get_active_conversation(gaim_conversation_get_window(conv))) |
5845 gtk_window_set_icon(GTK_WINDOW(gtkwin->window), buf); | |
4359 | 5846 } |
5847 | |
5848 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5849 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5850 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5851 GaimConvWindow *win; |
4359 | 5852 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5853 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5854 return; |
5855 | |
7887 | 5856 win = gaim_conversation_get_window(conv); |
5857 | |
5858 if (win != NULL && gaim_conv_window_get_active_conversation(win) == conv) | |
10810 | 5859 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5860 } |
5861 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5862 GaimConvWindow * |
4359 | 5863 gaim_gtkwin_get_at_xy(int x, int y) |
5864 { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5865 GaimConvWindow *win = NULL; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5866 GaimGtkWindow *gtkwin; |
4359 | 5867 GdkWindow *gdkwin; |
5868 GList *l; | |
5869 | |
5870 gdkwin = gdk_window_at_pointer(&x, &y); | |
5871 | |
5872 if (gdkwin) | |
5873 gdkwin = gdk_window_get_toplevel(gdkwin); | |
5874 | |
5875 for (l = gaim_get_windows(); l != NULL; l = l->next) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5876 win = (GaimConvWindow *)l->data; |
4359 | 5877 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5878 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5879 continue; |
5880 | |
5881 gtkwin = GAIM_GTK_WINDOW(win); | |
5882 | |
5883 if (gdkwin == gtkwin->window->window) | |
5884 return win; | |
5885 } | |
5886 | |
5887 return NULL; | |
5888 } | |
5889 | |
5890 int | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5891 gaim_gtkconv_get_tab_at_xy(GaimConvWindow *win, int x, int y) |
4359 | 5892 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5893 GaimGtkWindow *gtkwin; |
4359 | 5894 GList *l; |
5895 gint nb_x, nb_y, x_rel, y_rel; | |
5896 GtkNotebook *notebook; | |
5897 GtkWidget *tab; | |
5898 gint i, page_num = 0; | |
5899 gboolean first_visible = TRUE; | |
5900 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5901 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5902 return -1; |
5903 | |
5904 gtkwin = GAIM_GTK_WINDOW(win); | |
5905 notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
5906 | |
5907 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
5908 x_rel = x - nb_x; | |
5909 y_rel = y - nb_y; | |
5910 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5911 for (l = gaim_conv_window_get_conversations(win), i = 0; |
4359 | 5912 l != NULL; |
5913 l = l->next, i++) { | |
5914 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5915 GaimConversation *conv = l->data; |
4359 | 5916 tab = GAIM_GTK_CONVERSATION(conv)->tab_label; |
5917 | |
5918 if (!GTK_WIDGET_MAPPED(tab)) | |
5919 continue; | |
5920 | |
5921 if (first_visible) { | |
5922 first_visible = FALSE; | |
5923 | |
5924 if (x_rel < tab->allocation.x) x_rel = tab->allocation.x; | |
5925 if (y_rel < tab->allocation.y) y_rel = tab->allocation.y; | |
5926 } | |
5927 | |
5928 if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || | |
5929 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM) { | |
5930 | |
5931 if (tab->allocation.x <= x_rel) { | |
5932 if (tab->allocation.x + tab->allocation.width <= x_rel) | |
5933 page_num = i + 1; | |
5934 else | |
5935 page_num = i; | |
5936 } | |
5937 else | |
5938 break; | |
5939 } | |
5940 else { | |
5941 if (tab->allocation.y <= y_rel) { | |
5942 if (tab->allocation.y + tab->allocation.height <= y_rel) | |
5943 page_num = i + 1; | |
5944 else | |
5945 page_num = i; | |
5946 } | |
5947 else | |
5948 break; | |
5949 } | |
5950 } | |
5951 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5952 if (i == gaim_conv_window_get_conversation_count(win) + 1) |
4359 | 5953 return -1; |
5954 | |
5955 return page_num; | |
5956 } | |
5957 | |
5958 int | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5959 gaim_gtkconv_get_dest_tab_at_xy(GaimConvWindow *win, int x, int y) |
4359 | 5960 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5961 GaimGtkWindow *gtkwin; |
4359 | 5962 GList *l; |
5963 gint nb_x, nb_y, x_rel, y_rel; | |
5964 GtkNotebook *notebook; | |
5965 GtkWidget *tab; | |
5966 gint i, page_num = 0; | |
5967 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5968 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5969 return -1; |
5970 | |
5971 gtkwin = GAIM_GTK_WINDOW(win); | |
5972 notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
5973 | |
5974 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
5975 x_rel = x - nb_x; | |
5976 y_rel = y - nb_y; | |
5977 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5978 for (l = gaim_conv_window_get_conversations(win), i = 0; |
4359 | 5979 l != NULL; |
5980 l = l->next, i++) { | |
5981 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5982 GaimConversation *conv = l->data; |
4359 | 5983 tab = GAIM_GTK_CONVERSATION(conv)->tab_label; |
5984 | |
5985 if (!GTK_WIDGET_MAPPED(tab)) | |
5986 continue; | |
5987 | |
5988 if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || | |
5989 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM) { | |
5990 | |
5991 if (tab->allocation.x <= x_rel) { | |
5992 if (tab->allocation.x + (tab->allocation.width / 2) <= x_rel) | |
5993 page_num = i + 1; | |
5994 else | |
5995 page_num = i; | |
5996 } | |
5997 else | |
5998 break; | |
5999 } | |
6000 else { | |
6001 if (tab->allocation.y <= y_rel) { | |
6002 if (tab->allocation.y + (tab->allocation.height / 2) <= y_rel) | |
6003 page_num = i + 1; | |
6004 else | |
6005 page_num = i; | |
6006 } | |
6007 else | |
6008 break; | |
6009 } | |
6010 } | |
6011 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
6012 if (i == gaim_conv_window_get_conversation_count(win) + 1) |
4359 | 6013 return -1; |
6014 | |
6015 return page_num; | |
6016 } | |
4940
3708545afe42
[gaim-migrate @ 5274]
Christian Hammond <chipx86@chipx86.com>
parents:
4939
diff
changeset
|
6017 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6018 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6019 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
|
6020 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6021 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6022 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6023 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6024 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6025 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6026 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6027 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6028 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6029 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6030 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6031 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6032 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6033 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6034 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6035 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6036 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6037 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6038 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6039 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6040 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6041 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6042 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6043 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6044 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6045 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6046 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6047 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6048 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6049 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6050 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6051 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
6052 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6053 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6054 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6055 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6056 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6057 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6058 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6059 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6060 if (value) |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
6061 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6062 else { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6063 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6064 gtkspell_detach(spell); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6065 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6066 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6067 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6068 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6069 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6070 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6071 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6072 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6073 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6074 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6075 GtkPositionType pos; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
6076 GaimConvWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6077 GaimGtkWindow *gtkwin; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6078 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6079 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6080 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6081 for (l = gaim_get_windows(); l != NULL; l = l->next) { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
6082 win = (GaimConvWindow *)l->data; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6083 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6084 if (!GAIM_IS_GTK_WINDOW(win)) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6085 continue; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6086 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6087 gtkwin = GAIM_GTK_WINDOW(win); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6088 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6089 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6090 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6091 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6092 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6093 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6094 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6095 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6096 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6097 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6098 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6099 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6100 GaimConvWindow *win; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6101 GaimGtkWindow *gtkwin; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6102 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6103 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6104 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6105 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6106 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6107 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6108 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6109 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6110 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6111 win = gaim_conversation_get_window(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6112 gtkwin = GAIM_GTK_WINDOW(win); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6113 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6114 gtk_check_menu_item_set_active( |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6115 GTK_CHECK_MENU_ITEM(gtkwin->menu.show_formatting_toolbar), |
10377 | 6116 (gboolean)GPOINTER_TO_INT(value)); |
6117 | |
6118 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 6119 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6120 else |
8317 | 6121 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6122 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6123 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6124 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6125 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6126 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6127 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6128 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6129 GList *l; |
8189 | 6130 GaimConversation *conv; |
6131 GaimGtkConversation *gtkconv; | |
6132 GaimConvWindow *win; | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6133 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6134 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
|
6135 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6136 |
8189 | 6137 /* Set the "animate" flag for each icon based on the new preference */ |
6138 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
6139 conv = (GaimConversation *)l->data; | |
6140 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 6141 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6142 } |
8189 | 6143 |
6144 /* Now either stop or start animation for the active conversation in each window */ | |
6145 for (l = gaim_get_windows(); l != NULL; l = l->next) { | |
6146 win = (GaimConvWindow *)l->data; | |
6147 conv = gaim_conv_window_get_active_conversation(win); | |
6148 gaim_gtkconv_update_buddy_icon(conv); | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6149 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6150 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6151 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6152 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6153 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
|
6154 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6155 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6156 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6157 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6158 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6159 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6160 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6161 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6162 gaim_conversation_foreach(gaim_gtkconv_update_buddy_icon); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6163 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6164 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6165 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
6166 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6167 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6168 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6169 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6170 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6171 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6172 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6173 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6174 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6175 func = gaim_conv_placement_get_fnc(value); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6176 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6177 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6178 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6179 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6180 gaim_conv_placement_set_current_func(func); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6181 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6182 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6183 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6184 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6185 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6186 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6187 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6188 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6189 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6190 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6191 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
6192 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6193 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6194 void *handle = gaim_gtk_conversations_get_handle(); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6195 |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11003
diff
changeset
|
6196 gaim_debug_register_category("gtkconv"); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11003
diff
changeset
|
6197 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6198 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6199 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6200 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
9025 | 6201 gaim_prefs_add_bool("/gaim/gtk/conversations/send_formatting", FALSE); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6202 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6203 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6204 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6205 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
10488 | 6206 #if 0 |
9049 | 6207 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_colors", FALSE); |
6208 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_fonts", FALSE); | |
6209 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_font_sizes", FALSE); | |
6210 #else | |
8944 | 6211 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_formatting", FALSE); |
9049 | 6212 #endif |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6213 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 6214 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 6215 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6216 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 6217 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 6218 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
6219 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6220 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6221 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6222 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6223 gaim_prefs_add_int("/gaim/gtk/conversations/tab_side", GTK_POS_TOP); |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
6224 gaim_prefs_add_bool("/gaim/gtk/conversations/warn_on_unread_close", TRUE); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6225 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6226 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6227 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6228 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6229 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6230 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6231 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6232 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6233 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 6234 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6235 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 6236 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6237 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6238 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6239 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 6240 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
|
6241 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6242 /* Connect callbacks. */ |
10087 | 6243 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
|
6244 close_on_tabs_pref_cb, NULL); |
10087 | 6245 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
|
6246 show_formatting_toolbar_pref_cb, NULL); |
10087 | 6247 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6248 spellcheck_pref_cb, NULL); |
10087 | 6249 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6250 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6251 |
10087 | 6252 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6253 conv_placement_pref_cb, NULL); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6254 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6255 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6256 /* IM callbacks */ |
10087 | 6257 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
|
6258 animate_buddy_icons_pref_cb, NULL); |
10087 | 6259 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
|
6260 show_buddy_icons_pref_cb, NULL); |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6261 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6262 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6263 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6264 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6265 **********************************************************************/ |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6266 gaim_signal_register(handle, "conversation-drag-ended", |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6267 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6268 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6269 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6270 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6271 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 6272 |
6273 /********************************************************************** | |
6274 * Register commands | |
6275 **********************************************************************/ | |
9829 | 6276 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
6277 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
6278 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 6279 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
6280 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6281 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 6282 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
6283 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6284 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
|
6285 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6286 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6287 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 6288 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 6289 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
6290 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6291 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6292 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6293 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6294 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6295 { |
10443 | 6296 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6297 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11003
diff
changeset
|
6298 |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11003
diff
changeset
|
6299 gaim_debug_unregister_category("gtkconv"); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6300 } |