Mon, 26 May 2003 08:30:48 +0000
[gaim-migrate @ 5930]
Okay, several changes in this commit.
- We now have gtkprefs.h.
- We have a place where we can add UI prefs.
- show_prefs() -> gaim_gtk_prefs_show().
- make_frame() -> gaim_gtk_make_frame().
- The debug window is the first thing to have prefs. You can even
turn off the toolbar if you edit ~/.gaim/prefs.xml.
| 4390 | 1 | /* |
| 2 | * Mouse gestures plugin for Gaim | |
| 3 | * | |
| 4 | * Copyright (C) 2003 Christian Hammond. | |
| 5 | * | |
| 6 | * This program is free software; you can redistribute it and/or | |
| 7 | * modify it under the terms of the GNU General Public License as | |
| 8 | * published by the Free Software Foundation; either version 2 of the | |
| 9 | * License, or (at your option) any later version. | |
| 10 | * | |
| 11 | * This program is distributed in the hope that it will be useful, but | |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | * General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
| 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
| 19 | * 02111-1307, USA. | |
| 20 | */ | |
| 21 | #include "config.h" | |
| 22 | ||
| 23 | #include "gaim.h" | |
| 24 | #include "gstroke.h" | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
25 | #include "gtkconv.h" |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
26 | #include "gtkplugin.h" |
| 4390 | 27 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
28 | #define GESTURES_PLUGIN_ID "gtk-gestures" |
| 4390 | 29 | |
| 30 | static void | |
| 31 | stroke_close(GtkWidget *widget, void *data) | |
| 32 | { | |
| 33 | struct gaim_conversation *conv; | |
| 34 | struct gaim_gtk_conversation *gtkconv; | |
| 35 | ||
| 36 | conv = (struct gaim_conversation *)data; | |
| 37 | ||
| 38 | /* Double-check */ | |
| 39 | if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
| 40 | return; | |
| 41 | ||
| 42 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 43 | ||
| 44 | gstroke_cleanup(gtkconv->imhtml); | |
| 45 | gaim_conversation_destroy(conv); | |
| 46 | } | |
| 47 | ||
| 48 | static void | |
| 49 | stroke_prev_tab(GtkWidget *widget, void *data) | |
| 50 | { | |
| 51 | struct gaim_conversation *conv; | |
| 52 | struct gaim_window *win; | |
| 53 | unsigned int index; | |
| 54 | ||
| 55 | conv = (struct gaim_conversation *)data; | |
| 56 | win = gaim_conversation_get_window(conv); | |
| 57 | index = gaim_conversation_get_index(conv); | |
| 58 | ||
| 59 | if (index == 0) | |
| 60 | index = gaim_window_get_conversation_count(win) - 1; | |
| 61 | else | |
| 62 | index--; | |
| 63 | ||
| 64 | gaim_window_switch_conversation(win, index); | |
| 65 | } | |
| 66 | ||
| 67 | static void | |
| 68 | stroke_next_tab(GtkWidget *widget, void *data) | |
| 69 | { | |
| 70 | struct gaim_conversation *conv; | |
| 71 | struct gaim_window *win; | |
| 72 | unsigned int index; | |
| 73 | ||
| 74 | conv = (struct gaim_conversation *)data; | |
| 75 | win = gaim_conversation_get_window(conv); | |
| 76 | index = gaim_conversation_get_index(conv); | |
| 77 | ||
| 78 | if (index == gaim_window_get_conversation_count(win) - 1) | |
| 79 | index = 0; | |
| 80 | else | |
| 81 | index++; | |
| 82 | ||
| 83 | gaim_window_switch_conversation(win, index); | |
| 84 | } | |
| 85 | ||
| 86 | void | |
| 87 | stroke_new_win(GtkWidget *widget, void *data) | |
| 88 | { | |
| 89 | struct gaim_window *new_win, *old_win; | |
| 90 | struct gaim_conversation *conv; | |
| 91 | ||
| 92 | conv = (struct gaim_conversation *)data; | |
| 93 | old_win = gaim_conversation_get_window(conv); | |
| 94 | ||
| 95 | if (gaim_window_get_conversation_count(old_win) <= 1) | |
| 96 | return; | |
| 97 | ||
| 98 | new_win = gaim_window_new(); | |
| 99 | ||
| 100 | gaim_window_remove_conversation(old_win, gaim_conversation_get_index(conv)); | |
| 101 | gaim_window_add_conversation(new_win, conv); | |
| 102 | ||
| 103 | gaim_window_show(new_win); | |
| 104 | } | |
| 105 | ||
| 106 | static void | |
| 107 | attach_signals(struct gaim_conversation *conv) | |
| 108 | { | |
| 109 | struct gaim_gtk_conversation *gtkconv; | |
| 110 | ||
| 111 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 112 | ||
| 113 | gstroke_enable(gtkconv->imhtml); | |
| 114 | gstroke_signal_connect(gtkconv->imhtml, "14789", stroke_close, conv); | |
| 115 | gstroke_signal_connect(gtkconv->imhtml, "1456", stroke_close, conv); | |
|
5016
0e42e5f25880
[gaim-migrate @ 5352]
Christian Hammond <chipx86@chipx86.com>
parents:
4843
diff
changeset
|
116 | gstroke_signal_connect(gtkconv->imhtml, "1489", stroke_close, conv); |
| 4390 | 117 | gstroke_signal_connect(gtkconv->imhtml, "74123", stroke_next_tab, conv); |
| 118 | gstroke_signal_connect(gtkconv->imhtml, "7456", stroke_next_tab, conv); | |
| 119 | gstroke_signal_connect(gtkconv->imhtml, "96321", stroke_prev_tab, conv); | |
| 120 | gstroke_signal_connect(gtkconv->imhtml, "9654", stroke_prev_tab, conv); | |
| 121 | gstroke_signal_connect(gtkconv->imhtml, "25852", stroke_new_win, conv); | |
| 122 | } | |
| 123 | ||
| 124 | static void | |
| 125 | new_conv_cb(char *who) | |
| 126 | { | |
| 127 | struct gaim_conversation *conv; | |
| 128 | ||
| 129 | conv = gaim_find_conversation(who); | |
| 130 | ||
| 131 | if (conv == NULL || !GAIM_IS_GTK_CONVERSATION(conv)) | |
| 132 | return; | |
| 133 | ||
| 134 | attach_signals(conv); | |
| 135 | } | |
| 136 | ||
| 137 | #if 0 | |
| 138 | static void | |
| 139 | mouse_button_menu_cb(GtkMenuItem *item, gpointer data) | |
| 140 | { | |
| 141 | int button = (int)data; | |
| 142 | ||
| 143 | gstroke_set_mouse_button(button + 2); | |
| 144 | } | |
| 145 | #endif | |
| 146 | ||
| 147 | static void | |
| 148 | toggle_draw_cb(GtkToggleButton *toggle, gpointer data) | |
| 149 | { | |
| 150 | gstroke_set_draw_strokes(!gstroke_draw_strokes()); | |
| 151 | } | |
| 152 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
153 | static gboolean |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
154 | plugin_load(GaimPlugin *plugin) |
| 4390 | 155 | { |
| 156 | struct gaim_conversation *conv; | |
| 157 | GList *l; | |
| 158 | ||
| 159 | for (l = gaim_get_conversations(); l != NULL; l = l->next) { | |
| 160 | conv = (struct gaim_conversation *)l->data; | |
| 161 | ||
| 162 | if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
| 163 | continue; | |
| 164 | ||
| 165 | attach_signals(conv); | |
| 166 | } | |
| 167 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
168 | gaim_signal_connect(plugin, event_new_conversation, new_conv_cb, NULL); |
| 4390 | 169 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
170 | return TRUE; |
| 4390 | 171 | } |
| 172 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
173 | static gboolean |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
174 | plugin_unload(GaimPlugin *plugin) |
| 4390 | 175 | { |
| 176 | struct gaim_conversation *conv; | |
| 177 | struct gaim_gtk_conversation *gtkconv; | |
| 178 | GList *l; | |
| 179 | ||
| 180 | for (l = gaim_get_conversations(); l != NULL; l = l->next) { | |
| 181 | conv = (struct gaim_conversation *)l->data; | |
| 182 | ||
| 183 | if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
| 184 | continue; | |
| 185 | ||
| 186 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 187 | ||
| 188 | gstroke_cleanup(gtkconv->imhtml); | |
| 189 | } | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
190 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
191 | return TRUE; |
| 4390 | 192 | } |
| 193 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
194 | static GtkWidget * |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
195 | get_config_frame(GaimPlugin *plugin) |
| 4390 | 196 | { |
| 197 | GtkWidget *ret; | |
| 198 | GtkWidget *vbox; | |
| 199 | GtkWidget *toggle; | |
| 200 | #if 0 | |
| 201 | GtkWidget *opt; | |
| 202 | GtkWidget *menu, *item; | |
| 203 | #endif | |
| 204 | ||
| 205 | /* Outside container */ | |
| 206 | ret = gtk_vbox_new(FALSE, 18); | |
| 207 | gtk_container_set_border_width(GTK_CONTAINER(ret), 12); | |
| 208 | ||
| 209 | /* Configuration frame */ | |
|
5530
ba1ad464b56f
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
210 | vbox = gaim_gtk_make_frame(ret, _("Mouse Gestures Configuration")); |
| 4390 | 211 | |
| 212 | #if 0 | |
| 213 | /* Mouse button drop-down menu */ | |
| 214 | menu = gtk_menu_new(); | |
| 215 | opt = gtk_option_menu_new(); | |
| 216 | ||
| 217 | item = gtk_menu_item_new_with_label(_("Middle mouse button")); | |
| 218 | g_signal_connect(G_OBJECT(item), "activate", | |
| 219 | G_CALLBACK(mouse_button_menu_cb), opt); | |
| 220 | gtk_menu_append(menu, item); | |
| 221 | ||
| 222 | item = gtk_menu_item_new_with_label(_("Right mouse button")); | |
| 223 | g_signal_connect(G_OBJECT(item), "activate", | |
| 224 | G_CALLBACK(mouse_button_menu_cb), opt); | |
| 225 | gtk_menu_append(menu, item); | |
| 226 | ||
| 227 | gtk_box_pack_start(GTK_BOX(vbox), opt, FALSE, FALSE, 0); | |
| 228 | gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu); | |
| 229 | gtk_option_menu_set_history(GTK_OPTION_MENU(opt), | |
| 230 | gstroke_get_mouse_button() - 2); | |
| 231 | #endif | |
| 232 | ||
| 233 | /* "Visual gesture display" checkbox */ | |
| 234 | toggle = gtk_check_button_new_with_mnemonic(_("_Visual gesture display")); | |
| 235 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 236 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 237 | gstroke_draw_strokes()); | |
| 238 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 239 | G_CALLBACK(toggle_draw_cb), NULL); | |
| 240 | ||
| 241 | gtk_widget_show_all(ret); | |
| 242 | ||
| 243 | return ret; | |
| 244 | } | |
| 245 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
246 | static GaimGtkPluginUiInfo ui_info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
247 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
248 | get_config_frame |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
249 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
250 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
251 | static GaimPluginInfo info = |
| 4390 | 252 | { |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
253 | 2, /**< api_version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
254 | GAIM_PLUGIN_STANDARD, /**< type */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
255 | GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
256 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
257 | NULL, /**< dependencies */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
258 | GAIM_PRIORITY_DEFAULT, /**< priority */ |
| 4390 | 259 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
260 | GESTURES_PLUGIN_ID, /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
261 | N_("Mouse Gestures"), /**< name */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
262 | VERSION, /**< version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
263 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
264 | N_("Provides support for mouse gestures"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
265 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
266 | N_("Allows support for mouse gestures in conversation windows.\n" |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
267 | "Drag the middle mouse button to perform certain actions:\n\n" |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
268 | "Drag down and then to the right to close a conversation.\n" |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
269 | "Drag up and then to the left to switch to the previous " |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
270 | "conversation.\n" |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
271 | "Drag up and then to the right to switch to the next " |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
272 | "conversation."), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
273 | "Christian Hammond <chipx86@gnupdate.org>", /**< author */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
274 | WEBSITE, /**< homepage */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
275 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
276 | plugin_load, /**< load */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
277 | plugin_unload, /**< unload */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
278 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
279 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
280 | &ui_info, /**< ui_info */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
281 | NULL /**< extra_info */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
282 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
283 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
284 | static void |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
285 | __init_plugin(GaimPlugin *plugin) |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
286 | { |
| 4390 | 287 | } |
| 288 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5016
diff
changeset
|
289 | GAIM_INIT_PLUGIN(gestures, __init_plugin, info); |