Mercurial > pidgin
annotate plugins/gestures/gestures.c @ 5129:c19cc54f4df6
[gaim-migrate @ 5492]
Stuff I did (in order from most important to least):
-Made set away message and set profile count the number of bytes
rather than the number of characters. This fixes the lack of a
warning dialog when setting info that needs an encoding other than
ascii or iso8859-1. (Because "hi" in UCS-2BE is 4 bytes but "hi"
in utf8 is only 2.)
-Created an oscar_encoding_to_utf8 function to convert from a given
encoding to utf8. This is AIM/ICQ specific.
-Added a "Profile:" and "Away Message:" line to the get info response
window. Is it better this way or without it? I thought it would be
good if there was a way for users to tell which text was the away
message and which was the info, but I also think this solution could
be nicer looking.
-Added a little check for some server icon stuff because someone
reported an obscure crash.
-Shuffled some stuff around in oscar.c
-Bouldered on the little wall outside of the gym today. It's much
more difficult than climbing inside. I think my forearms are just
a bit too weak. The holds are tiny, though.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Mon, 14 Apr 2003 04:52:42 +0000 |
| parents | ae7760945ef2 |
| children | fefad67de2c7 |
| rev | line source |
|---|---|
| 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 #ifndef GAIM_PLUGINS | |
| 24 #define GAIM_PLUGINS | |
| 25 #endif | |
| 26 | |
| 27 #include "gaim.h" | |
| 28 #include "gstroke.h" | |
| 29 | |
| 30 static GModule *handle = NULL; | |
| 31 struct gaim_plugin_description desc; | |
| 32 | |
| 33 static void | |
| 34 stroke_close(GtkWidget *widget, void *data) | |
| 35 { | |
| 36 struct gaim_conversation *conv; | |
| 37 struct gaim_gtk_conversation *gtkconv; | |
| 38 | |
| 39 conv = (struct gaim_conversation *)data; | |
| 40 | |
| 41 /* Double-check */ | |
| 42 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
| 43 return; | |
| 44 | |
| 45 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 46 | |
| 47 gstroke_cleanup(gtkconv->imhtml); | |
| 48 gaim_conversation_destroy(conv); | |
| 49 } | |
| 50 | |
| 51 static void | |
| 52 stroke_prev_tab(GtkWidget *widget, void *data) | |
| 53 { | |
| 54 struct gaim_conversation *conv; | |
| 55 struct gaim_window *win; | |
| 56 unsigned int index; | |
| 57 | |
| 58 conv = (struct gaim_conversation *)data; | |
| 59 win = gaim_conversation_get_window(conv); | |
| 60 index = gaim_conversation_get_index(conv); | |
| 61 | |
| 62 if (index == 0) | |
| 63 index = gaim_window_get_conversation_count(win) - 1; | |
| 64 else | |
| 65 index--; | |
| 66 | |
| 67 gaim_window_switch_conversation(win, index); | |
| 68 } | |
| 69 | |
| 70 static void | |
| 71 stroke_next_tab(GtkWidget *widget, void *data) | |
| 72 { | |
| 73 struct gaim_conversation *conv; | |
| 74 struct gaim_window *win; | |
| 75 unsigned int index; | |
| 76 | |
| 77 conv = (struct gaim_conversation *)data; | |
| 78 win = gaim_conversation_get_window(conv); | |
| 79 index = gaim_conversation_get_index(conv); | |
| 80 | |
| 81 if (index == gaim_window_get_conversation_count(win) - 1) | |
| 82 index = 0; | |
| 83 else | |
| 84 index++; | |
| 85 | |
| 86 gaim_window_switch_conversation(win, index); | |
| 87 } | |
| 88 | |
| 89 void | |
| 90 stroke_new_win(GtkWidget *widget, void *data) | |
| 91 { | |
| 92 struct gaim_window *new_win, *old_win; | |
| 93 struct gaim_conversation *conv; | |
| 94 | |
| 95 conv = (struct gaim_conversation *)data; | |
| 96 old_win = gaim_conversation_get_window(conv); | |
| 97 | |
| 98 if (gaim_window_get_conversation_count(old_win) <= 1) | |
| 99 return; | |
| 100 | |
| 101 new_win = gaim_window_new(); | |
| 102 | |
| 103 gaim_window_remove_conversation(old_win, gaim_conversation_get_index(conv)); | |
| 104 gaim_window_add_conversation(new_win, conv); | |
| 105 | |
| 106 gaim_window_show(new_win); | |
| 107 } | |
| 108 | |
| 109 static void | |
| 110 attach_signals(struct gaim_conversation *conv) | |
| 111 { | |
| 112 struct gaim_gtk_conversation *gtkconv; | |
| 113 | |
| 114 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 115 | |
| 116 gstroke_enable(gtkconv->imhtml); | |
| 117 gstroke_signal_connect(gtkconv->imhtml, "14789", stroke_close, conv); | |
| 118 gstroke_signal_connect(gtkconv->imhtml, "1456", stroke_close, conv); | |
|
5016
ae7760945ef2
[gaim-migrate @ 5352]
Christian Hammond <chipx86@chipx86.com>
parents:
4843
diff
changeset
|
119 gstroke_signal_connect(gtkconv->imhtml, "1489", stroke_close, conv); |
| 4390 | 120 gstroke_signal_connect(gtkconv->imhtml, "74123", stroke_next_tab, conv); |
| 121 gstroke_signal_connect(gtkconv->imhtml, "7456", stroke_next_tab, conv); | |
| 122 gstroke_signal_connect(gtkconv->imhtml, "96321", stroke_prev_tab, conv); | |
| 123 gstroke_signal_connect(gtkconv->imhtml, "9654", stroke_prev_tab, conv); | |
| 124 gstroke_signal_connect(gtkconv->imhtml, "25852", stroke_new_win, conv); | |
| 125 } | |
| 126 | |
| 127 static void | |
| 128 new_conv_cb(char *who) | |
| 129 { | |
| 130 struct gaim_conversation *conv; | |
| 131 | |
| 132 conv = gaim_find_conversation(who); | |
| 133 | |
| 134 if (conv == NULL || !GAIM_IS_GTK_CONVERSATION(conv)) | |
| 135 return; | |
| 136 | |
| 137 attach_signals(conv); | |
| 138 } | |
| 139 | |
| 140 #if 0 | |
| 141 static void | |
| 142 mouse_button_menu_cb(GtkMenuItem *item, gpointer data) | |
| 143 { | |
| 144 int button = (int)data; | |
| 145 | |
| 146 gstroke_set_mouse_button(button + 2); | |
| 147 } | |
| 148 #endif | |
| 149 | |
| 150 static void | |
| 151 toggle_draw_cb(GtkToggleButton *toggle, gpointer data) | |
| 152 { | |
| 153 gstroke_set_draw_strokes(!gstroke_draw_strokes()); | |
| 154 } | |
| 155 | |
| 156 char * | |
| 157 gaim_plugin_init(GModule *h) | |
| 158 { | |
| 159 struct gaim_conversation *conv; | |
| 160 GList *l; | |
| 161 | |
| 162 handle = h; | |
| 163 | |
| 164 for (l = gaim_get_conversations(); l != NULL; l = l->next) { | |
| 165 conv = (struct gaim_conversation *)l->data; | |
| 166 | |
| 167 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
| 168 continue; | |
| 169 | |
| 170 attach_signals(conv); | |
| 171 } | |
| 172 | |
| 173 gaim_signal_connect(handle, event_new_conversation, new_conv_cb, NULL); | |
| 174 | |
| 175 return NULL; | |
| 176 } | |
| 177 | |
| 178 void | |
| 179 gaim_plugin_remove(void) | |
| 180 { | |
| 181 struct gaim_conversation *conv; | |
| 182 struct gaim_gtk_conversation *gtkconv; | |
| 183 GList *l; | |
| 184 | |
| 185 for (l = gaim_get_conversations(); l != NULL; l = l->next) { | |
| 186 conv = (struct gaim_conversation *)l->data; | |
| 187 | |
| 188 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
| 189 continue; | |
| 190 | |
| 191 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 192 | |
| 193 gstroke_cleanup(gtkconv->imhtml); | |
| 194 } | |
| 195 } | |
| 196 | |
| 197 GtkWidget * | |
| 198 gaim_plugin_config_gtk(void) | |
| 199 { | |
| 200 GtkWidget *ret; | |
| 201 GtkWidget *vbox; | |
| 202 GtkWidget *toggle; | |
| 203 #if 0 | |
| 204 GtkWidget *opt; | |
| 205 GtkWidget *menu, *item; | |
| 206 #endif | |
| 207 | |
| 208 /* Outside container */ | |
| 209 ret = gtk_vbox_new(FALSE, 18); | |
| 210 gtk_container_set_border_width(GTK_CONTAINER(ret), 12); | |
| 211 | |
| 212 /* Configuration frame */ | |
| 213 vbox = make_frame(ret, _("Mouse Gestures Configuration")); | |
| 214 | |
| 215 #if 0 | |
| 216 /* Mouse button drop-down menu */ | |
| 217 menu = gtk_menu_new(); | |
| 218 opt = gtk_option_menu_new(); | |
| 219 | |
| 220 item = gtk_menu_item_new_with_label(_("Middle mouse button")); | |
| 221 g_signal_connect(G_OBJECT(item), "activate", | |
| 222 G_CALLBACK(mouse_button_menu_cb), opt); | |
| 223 gtk_menu_append(menu, item); | |
| 224 | |
| 225 item = gtk_menu_item_new_with_label(_("Right mouse button")); | |
| 226 g_signal_connect(G_OBJECT(item), "activate", | |
| 227 G_CALLBACK(mouse_button_menu_cb), opt); | |
| 228 gtk_menu_append(menu, item); | |
| 229 | |
| 230 gtk_box_pack_start(GTK_BOX(vbox), opt, FALSE, FALSE, 0); | |
| 231 gtk_option_menu_set_menu(GTK_OPTION_MENU(opt), menu); | |
| 232 gtk_option_menu_set_history(GTK_OPTION_MENU(opt), | |
| 233 gstroke_get_mouse_button() - 2); | |
| 234 #endif | |
| 235 | |
| 236 /* "Visual gesture display" checkbox */ | |
| 237 toggle = gtk_check_button_new_with_mnemonic(_("_Visual gesture display")); | |
| 238 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 239 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 240 gstroke_draw_strokes()); | |
| 241 g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 242 G_CALLBACK(toggle_draw_cb), NULL); | |
| 243 | |
| 244 gtk_widget_show_all(ret); | |
| 245 | |
| 246 return ret; | |
| 247 } | |
| 248 | |
| 249 struct gaim_plugin_description * | |
| 250 gaim_plugin_desc() | |
| 251 { | |
| 252 desc.api_version = PLUGIN_API_VERSION; | |
| 253 desc.name = g_strdup(_("Mouse Gestures")); | |
| 254 desc.version = g_strdup(VERSION); | |
| 255 desc.description = g_strdup( | |
| 4843 | 256 _("Allows support for mouse gestures in conversation windows.\n" |
| 257 "Drag the middle mouse button to perform certain actions:\n\n" | |
| 4390 | 258 "Drag down and then to the right to close a conversation.\n" |
| 259 "Drag up and then to the left to switch to the previous " | |
| 260 "conversation.\n" | |
| 261 "Drag up and then to the right to switch to the next " | |
| 262 "conversation.")); | |
| 263 desc.authors = g_strdup("Christian Hammond <chipx86@gnupdate.org>"); | |
| 264 desc.url = g_strdup(WEBSITE); | |
| 265 | |
| 266 return &desc; | |
| 267 } | |
| 268 | |
| 269 char * | |
| 270 name(void) | |
| 271 { | |
| 272 return _("Mouse Gestures"); | |
| 273 } | |
| 274 | |
| 275 char * | |
| 276 description(void) | |
| 277 { | |
| 4843 | 278 return _("Allows support for mouse gestures in conversation windows.\n" |
| 279 "Drag the middle mouse button to perform certain actions:\n\n" | |
| 4390 | 280 "Drag down and then to the right to close a conversation.\n" |
| 281 "Drag up and then to the left to switch to the previous " | |
| 282 "conversation.\n" | |
| 283 "Drag up and then to the right to switch to the next " | |
| 284 "conversation."); | |
| 285 } |
