Mercurial > pidgin
comparison src/gtkimhtml.c @ 8317:6f549c1d0829
[gaim-migrate @ 9041]
Because I won't be able to work on this until late this week at the earliest,
here's GtkIMHtmlToolbar. It's a composite widget that attaches to an editable
gtkimhtml and controls all the formatting with ease. All one has to do to get
a formattable, editable, gtkimhtml now is to replace a gtktextview with a
gtkimhtml (you can even leave all the other calls that control it as gtkimhtml
descends from gtktextview) throw one of these toolbars in there and
gtk_imhtml_toolbar_attach it to the gtkimhtml. That's what I did in the New
Away Message dialog. This would also be nice in gtkrequest.c and gtkpounce.c.
Of course, this isn't done and there's a ton of hacky commented out old code in
there. Things like keyboard shortcut preferences don't currently work and
there's a lot of things I want to move around yet. However, if anyone feels
inspired to work on it before I get back to it feel free. Maybe you can IM me
beforehand or something.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 23 Feb 2004 21:18:27 +0000 |
parents | f694277e8341 |
children | 0d1e5870d328 |
comparison
equal
deleted
inserted
replaced
8316:cf84056fed27 | 8317:6f549c1d0829 |
---|---|
349 * el program go boom. | 349 * el program go boom. |
350 * | 350 * |
351 * It's supposed to be fixed in gtk2.2. You can view the bug report at | 351 * It's supposed to be fixed in gtk2.2. You can view the bug report at |
352 * http://bugzilla.gnome.org/show_bug.cgi?id=107939 | 352 * http://bugzilla.gnome.org/show_bug.cgi?id=107939 |
353 */ | 353 */ |
354 gboolean gtk_key_pressed_cb(GtkWidget *imhtml, GdkEventKey *event, gpointer data) | 354 |
355 { | 355 /* |
356 * I'm adding some keyboard shortcuts too. | |
357 */ | |
358 | |
359 gboolean gtk_key_pressed_cb(GtkIMHtml *imhtml, GdkEventKey *event, gpointer data) | |
360 { | |
361 char buf[7]; | |
362 buf[0] = '\0'; | |
363 | |
356 if (event->state & GDK_CONTROL_MASK) | 364 if (event->state & GDK_CONTROL_MASK) |
357 switch (event->keyval) { | 365 switch (event->keyval) { |
358 case 'a': | 366 case 'a': |
359 return TRUE; | 367 return TRUE; |
360 break; | 368 break; |
361 | 369 |
362 case GDK_Home: | 370 case GDK_Home: |
363 return TRUE; | 371 return TRUE; |
364 break; | 372 break; |
365 | 373 |
366 case GDK_End: | 374 case GDK_End: |
367 return TRUE; | 375 return TRUE; |
368 break; | 376 break; |
369 } | 377 |
370 | 378 case 'b': /* ctrl-b is GDK_Left, which moves backwards. */ |
379 case 'B': | |
380 gtk_imhtml_toggle_bold(imhtml); | |
381 return TRUE; | |
382 break; | |
383 | |
384 case 'f': | |
385 case 'F': | |
386 /*set_toggle(gtkconv->toolbar.font, | |
387 !gtk_toggle_button_get_active( | |
388 GTK_TOGGLE_BUTTON(gtkconv->toolbar.font)));*/ | |
389 | |
390 return TRUE; | |
391 break; | |
392 | |
393 case 'i': | |
394 case 'I': | |
395 /*set_toggle(gtkconv->toolbar.italic, | |
396 !gtk_toggle_button_get_active( | |
397 GTK_TOGGLE_BUTTON(gtkconv->toolbar.italic)));*/ | |
398 gtk_imhtml_toggle_italic(imhtml); | |
399 return TRUE; | |
400 break; | |
401 | |
402 case 'u': /* ctrl-u is GDK_Clear, which clears the line. */ | |
403 case 'U': | |
404 /*set_toggle(gtkconv->toolbar.underline, | |
405 !gtk_toggle_button_get_active( | |
406 GTK_TOGGLE_BUTTON(gtkconv->toolbar.underline)));*/ | |
407 gtk_imhtml_toggle_underline(imhtml); | |
408 return TRUE; | |
409 break; | |
410 | |
411 case '-': | |
412 /*set_toggle(gtkconv->toolbar.smaller_size, | |
413 !gtk_toggle_button_get_active( | |
414 GTK_TOGGLE_BUTTON(gtkconv->toolbar.smaller_size)));*/ | |
415 gtk_imhtml_font_shrink(imhtml); | |
416 return TRUE; | |
417 break; | |
418 | |
419 case '=': | |
420 case '+': | |
421 /*set_toggle(gtkconv->toolbar.larger_size, | |
422 !gtk_toggle_button_get_active( | |
423 GTK_TOGGLE_BUTTON(gtkconv->toolbar.larger_size)));*/ | |
424 gtk_imhtml_font_grow(imhtml); | |
425 return TRUE; | |
426 break; | |
427 | |
428 case '1': strcpy(buf, ":-)"); break; | |
429 case '2': strcpy(buf, ":-("); break; | |
430 case '3': strcpy(buf, ";-)"); break; | |
431 case '4': strcpy(buf, ":-P"); break; | |
432 case '5': strcpy(buf, "=-O"); break; | |
433 case '6': strcpy(buf, ":-*"); break; | |
434 case '7': strcpy(buf, ">:o"); break; | |
435 case '8': strcpy(buf, "8-)"); break; | |
436 case '!': strcpy(buf, ":-$"); break; | |
437 case '@': strcpy(buf, ":-!"); break; | |
438 case '#': strcpy(buf, ":-["); break; | |
439 case '$': strcpy(buf, "O:-)"); break; | |
440 case '%': strcpy(buf, ":-/"); break; | |
441 case '^': strcpy(buf, ":'("); break; | |
442 case '&': strcpy(buf, ":-X"); break; | |
443 case '*': strcpy(buf, ":-D"); break; | |
444 } | |
445 if (*buf) { | |
446 gtk_imhtml_insert_smiley(imhtml, NULL, buf);//->account->protocol_id, buf); | |
447 return TRUE; | |
448 } | |
371 return FALSE; | 449 return FALSE; |
372 } | 450 } |
373 | 451 |
374 #if GTK_CHECK_VERSION(2,2,0) | 452 #if GTK_CHECK_VERSION(2,2,0) |
375 static void gtk_imhtml_clipboard_get(GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, GtkIMHtml *imhtml) { | 453 static void gtk_imhtml_clipboard_get(GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, GtkIMHtml *imhtml) { |
1755 break; | 1833 break; |
1756 case 60: /* SPAN */ | 1834 case 60: /* SPAN */ |
1757 break; | 1835 break; |
1758 case 62: /* comment */ | 1836 case 62: /* comment */ |
1759 /* NEW_BIT (NEW_TEXT_BIT); */ | 1837 /* NEW_BIT (NEW_TEXT_BIT); */ |
1838 ws[wpos] = '\0'; | |
1839 if (url) | |
1840 gtk_imhtml_insert_link(imhtml, url, ws); | |
1841 else | |
1842 gtk_text_buffer_insert(imhtml->text_buffer, &iter, ws, wpos); | |
1760 if (imhtml->show_comments) | 1843 if (imhtml->show_comments) |
1761 wpos = g_snprintf (ws, len, "%s", tag); | 1844 wpos = g_snprintf (ws, len, "%s", tag); |
1762 /* NEW_BIT (NEW_COMMENT_BIT); */ | 1845 /* NEW_BIT (NEW_COMMENT_BIT); */ |
1763 break; | 1846 break; |
1764 default: | 1847 default: |