annotate plugins/gestures/gestures.c @ 4425:be8f9ca74ddf

[gaim-migrate @ 4700] Gaim should no longer crash when the user is NULL and the conversation is closed. This happened for instance when a user typed /part in an IRC channel and then closed the tab. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 26 Jan 2003 07:17:07 +0000
parents 16540914c963
children 2308397639df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4390
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /*
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * Mouse gestures plugin for Gaim
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * Copyright (C) 2003 Christian Hammond.
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * published by the Free Software Foundation; either version 2 of the
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 *
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * General Public License for more details.
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 *
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * 02111-1307, USA.
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 #include "config.h"
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #ifndef GAIM_PLUGINS
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #define GAIM_PLUGINS
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #endif
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 #include "gaim.h"
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 #include "gstroke.h"
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 static GModule *handle = NULL;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 struct gaim_plugin_description desc;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 static void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 stroke_close(GtkWidget *widget, void *data)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 struct gaim_conversation *conv;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 struct gaim_gtk_conversation *gtkconv;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 conv = (struct gaim_conversation *)data;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 /* Double-check */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 if (!GAIM_IS_GTK_CONVERSATION(conv))
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 return;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 gtkconv = GAIM_GTK_CONVERSATION(conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 gstroke_cleanup(gtkconv->imhtml);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 gaim_conversation_destroy(conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 static void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 stroke_prev_tab(GtkWidget *widget, void *data)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 struct gaim_conversation *conv;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 struct gaim_window *win;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 unsigned int index;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 conv = (struct gaim_conversation *)data;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 win = gaim_conversation_get_window(conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 index = gaim_conversation_get_index(conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 if (index == 0)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 index = gaim_window_get_conversation_count(win) - 1;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 else
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 index--;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 gaim_window_switch_conversation(win, index);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 static void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 stroke_next_tab(GtkWidget *widget, void *data)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 struct gaim_conversation *conv;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 struct gaim_window *win;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 unsigned int index;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 conv = (struct gaim_conversation *)data;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 win = gaim_conversation_get_window(conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 index = gaim_conversation_get_index(conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 if (index == gaim_window_get_conversation_count(win) - 1)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 index = 0;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 else
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 index++;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 gaim_window_switch_conversation(win, index);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 stroke_new_win(GtkWidget *widget, void *data)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 struct gaim_window *new_win, *old_win;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 struct gaim_conversation *conv;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 conv = (struct gaim_conversation *)data;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 old_win = gaim_conversation_get_window(conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 if (gaim_window_get_conversation_count(old_win) <= 1)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 return;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 new_win = gaim_window_new();
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 gaim_window_remove_conversation(old_win, gaim_conversation_get_index(conv));
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 gaim_window_add_conversation(new_win, conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 gaim_window_show(new_win);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 static void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 attach_signals(struct gaim_conversation *conv)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 struct gaim_gtk_conversation *gtkconv;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 gtkconv = GAIM_GTK_CONVERSATION(conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 gstroke_enable(gtkconv->imhtml);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 gstroke_signal_connect(gtkconv->imhtml, "14789", stroke_close, conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 gstroke_signal_connect(gtkconv->imhtml, "1456", stroke_close, conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 gstroke_signal_connect(gtkconv->imhtml, "74123", stroke_next_tab, conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 gstroke_signal_connect(gtkconv->imhtml, "7456", stroke_next_tab, conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 gstroke_signal_connect(gtkconv->imhtml, "96321", stroke_prev_tab, conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 gstroke_signal_connect(gtkconv->imhtml, "9654", stroke_prev_tab, conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 gstroke_signal_connect(gtkconv->imhtml, "25852", stroke_new_win, conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 static void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 new_conv_cb(char *who)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 struct gaim_conversation *conv;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 conv = gaim_find_conversation(who);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 if (conv == NULL || !GAIM_IS_GTK_CONVERSATION(conv))
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 return;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 attach_signals(conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 #if 0
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 static void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 mouse_button_menu_cb(GtkMenuItem *item, gpointer data)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 int button = (int)data;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 gstroke_set_mouse_button(button + 2);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 #endif
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 static void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 toggle_draw_cb(GtkToggleButton *toggle, gpointer data)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 gstroke_set_draw_strokes(!gstroke_draw_strokes());
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 char *
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 gaim_plugin_init(GModule *h)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 struct gaim_conversation *conv;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 GList *l;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 handle = h;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 for (l = gaim_get_conversations(); l != NULL; l = l->next) {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 conv = (struct gaim_conversation *)l->data;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 if (!GAIM_IS_GTK_CONVERSATION(conv))
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 continue;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 attach_signals(conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 gaim_signal_connect(handle, event_new_conversation, new_conv_cb, NULL);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 return NULL;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 void
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 gaim_plugin_remove(void)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 struct gaim_conversation *conv;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 struct gaim_gtk_conversation *gtkconv;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 GList *l;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 for (l = gaim_get_conversations(); l != NULL; l = l->next) {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 conv = (struct gaim_conversation *)l->data;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 if (!GAIM_IS_GTK_CONVERSATION(conv))
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 continue;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 gtkconv = GAIM_GTK_CONVERSATION(conv);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 gstroke_cleanup(gtkconv->imhtml);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 GtkWidget *
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 gaim_plugin_config_gtk(void)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 GtkWidget *ret;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 GtkWidget *vbox;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 GtkWidget *toggle;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 #if 0
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 GtkWidget *opt;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 GtkWidget *menu, *item;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 #endif
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 /* Outside container */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 ret = gtk_vbox_new(FALSE, 18);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 gtk_container_set_border_width(GTK_CONTAINER(ret), 12);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 /* Configuration frame */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 vbox = make_frame(ret, _("Mouse Gestures Configuration"));
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 #if 0
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 /* Mouse button drop-down menu */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 menu = gtk_menu_new();
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 opt = gtk_option_menu_new();
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 item = gtk_menu_item_new_with_label(_("Middle mouse button"));
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 g_signal_connect(G_OBJECT(item), "activate",
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 G_CALLBACK(mouse_button_menu_cb), opt);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 gtk_menu_append(menu, item);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 item = gtk_menu_item_new_with_label(_("Right mouse button"));
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 g_signal_connect(G_OBJECT(item), "activate",
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 G_CALLBACK(mouse_button_menu_cb), opt);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 gtk_menu_append(menu, item);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 gtk_box_pack_start(GTK_BOX(vbox), opt, FALSE, FALSE, 0);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 gtk_option_menu_set_history(GTK_OPTION_MENU(opt),
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 gstroke_get_mouse_button() - 2);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 #endif
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 /* "Visual gesture display" checkbox */
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 toggle = gtk_check_button_new_with_mnemonic(_("_Visual gesture display"));
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle),
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 gstroke_draw_strokes());
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 g_signal_connect(G_OBJECT(toggle), "toggled",
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 G_CALLBACK(toggle_draw_cb), NULL);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 gtk_widget_show_all(ret);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245 return ret;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248 struct gaim_plugin_description *
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 gaim_plugin_desc()
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 desc.api_version = PLUGIN_API_VERSION;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 desc.name = g_strdup(_("Mouse Gestures"));
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 desc.version = g_strdup(VERSION);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 desc.description = g_strdup(
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255 _("Allows support for mouse gestures in conversation windows.\n\n"
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 "Drag down and then to the right to close a conversation.\n"
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257 "Drag up and then to the left to switch to the previous "
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 "conversation.\n"
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 "Drag up and then to the right to switch to the next "
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 "conversation."));
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 desc.authors = g_strdup("Christian Hammond &lt;chipx86@gnupdate.org&gt;");
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 desc.url = g_strdup(WEBSITE);
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 return &desc;
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 char *
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268 name(void)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 return _("Mouse Gestures");
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271 }
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273 char *
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 description(void)
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 {
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276 return _("Allows support for mouse gestures in conversation windows.\n\n"
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277 "Drag down and then to the right to close a conversation.\n"
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278 "Drag up and then to the left to switch to the previous "
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 "conversation.\n"
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 "Drag up and then to the right to switch to the next "
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281 "conversation.");
16540914c963 [gaim-migrate @ 4656]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
282 }