Mercurial > pidgin
diff src/gtkimhtml.c @ 6066:c99959f1bb73
[gaim-migrate @ 6516]
Re-add javabsp's F2 patch. I didn't feel like taking it out of my CVS
again, and I think he'll be able to get it working without the weird
highlight behavior.
Also fixed the ctlr+a/ctrl+pgup/ctrl+pgdown thing in gtkimhtml rather
than gtkconv.c. So now it applies to info windows and other stuff.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 09 Jul 2003 00:33:06 +0000 |
parents | 395116fdd270 |
children | 16fd7811effd |
line wrap: on
line diff
--- a/src/gtkimhtml.c Tue Jul 08 23:48:10 2003 +0000 +++ b/src/gtkimhtml.c Wed Jul 09 00:33:06 2003 +0000 @@ -301,6 +301,36 @@ return FALSE; } +/* + * XXX - This should be removed eventually. + * + * This function exists to work around a gross bug in GtkTextView. + * Basically, we short circuit ctrl+a and ctrl+end because they make + * el program go boom. + * + * It's supposed to be fixed in gtk2.2. You can view the bug report at + * http://bugzilla.gnome.org/show_bug.cgi?id=107939 + */ +gboolean gtk_key_pressed_cb(GtkWidget *imhtml, GdkEventKey *event, gpointer data) +{ + if (event->state & GDK_CONTROL_MASK) + switch (event->keyval) { + case 'a': + return TRUE; + break; + + case GDK_Home: + return TRUE; + break; + + case GDK_End: + return TRUE; + break; + } + + return FALSE; +} + static GtkTextViewClass *parent_class = NULL; @@ -385,7 +415,6 @@ imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); imhtml->show_smileys = TRUE; - imhtml->show_comments = TRUE; imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)gtk_smiley_tree_destroy); @@ -394,6 +423,7 @@ g_signal_connect(G_OBJECT(imhtml), "size-allocate", G_CALLBACK(gtk_size_allocate_cb), NULL); g_signal_connect(G_OBJECT(imhtml), "motion-notify-event", G_CALLBACK(gtk_motion_event_notify), NULL); g_signal_connect(G_OBJECT(imhtml), "leave-notify-event", G_CALLBACK(gtk_leave_event_notify), NULL); + g_signal_connect(G_OBJECT(imhtml), "key_press_event", G_CALLBACK(gtk_key_pressed_cb), NULL); gtk_widget_add_events(GTK_WIDGET(imhtml), GDK_LEAVE_NOTIFY_MASK); imhtml->tip = NULL; @@ -401,6 +431,8 @@ imhtml->tip_window = NULL; imhtml->scalables = NULL; + + gtk_text_buffer_create_tag(imhtml->text_buffer, "comment", "invisible", FALSE, NULL); } GtkWidget *gtk_imhtml_new(void *a, void *b) @@ -961,6 +993,9 @@ imhtml->scalables = g_list_append(imhtml->scalables, scalable); \ gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); \ } \ + if (x == NEW_COMMENT_BIT) { \ + gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "comment", &siter, &iter); \ + } \ @@ -1317,8 +1352,7 @@ break; case 59: /* comment */ NEW_BIT (NEW_TEXT_BIT); - if (imhtml->show_comments) - wpos = g_snprintf (ws, len, "%s", tag); + wpos = g_snprintf (ws, len, "%s", tag); NEW_BIT (NEW_COMMENT_BIT); break; default: @@ -1446,7 +1480,14 @@ void gtk_imhtml_show_comments (GtkIMHtml *imhtml, gboolean show) { - imhtml->show_comments = show; + GtkTextIter iter; + GtkTextTagTable *table = gtk_text_buffer_get_tag_table(imhtml->text_buffer); + GtkTextTag *tag = gtk_text_tag_table_lookup(table, "comment"); + g_object_set(G_OBJECT(tag), "invisible", !show, NULL); + gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); + gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &iter); + gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "selection_bound", &iter); + } void