Re: A question about "event" signal of GtkTextTag
- From: "Dongho Shin" <electman acadcorp com>
- To: "Sven Neumann" <sven gimp org>
- Cc: <gtk-list gnome org>
- Subject: Re: A question about "event" signal of GtkTextTag
- Date: Tue, 28 May 2002 21:45:21 +0900
Here is a sample test program which shows the problem.
(Libraries used: glib-2.0.1 gtk+-2.0.2 pango-1.0.1 atk-1.0.1
And 'uname -a' on my system printed:
SunOS hostname 5.6 Generic_105181-23 sun4u sparc SUNW,Ultra-5_10)
-*-*-*-*-*-*-
#include <gtk/gtk.h>
gboolean TagEventCB(tag, object, event, iter, user_data)
GtkTextTag *tag;
GObject *object;
GdkEvent *event;
GtkTextIter *iter;
gpointer user_data;
{
switch (event->type) {
case GDK_MOTION_NOTIFY:
g_print("Motion captured\n");
g_print(" -- x: [%.2f], y: [%.2f]\n",
event->motion.x, event->motion.y);
break;
case GDK_BUTTON_PRESS:
g_print("Button pressed on Bold Text\n");
g_print(" -- x: [%.2f], y: [%.2f]\n",
event->button.x, event->button.y);
break;
case GDK_BUTTON_RELEASE:
g_print("Button released from Bold Text\n");
g_print(" -- x: [%.2f], y: [%.2f]\n",
event->button.x, event->button.y);
break;
default:
g_print("Some event...\n");
break;
}
return FALSE;
}
int main(argc, argv)
int argc;
char *argv[];
{
GtkWidget *window;
GtkWidget *hbox;
GtkTextTagTable *tag_table;
GtkTextTag *tag;
GtkTextBuffer *textbuffer;
GtkWidget *textview;
GtkTextIter iter;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_uposition(window, 100, 100);
gtk_window_set_default_size(GTK_WINDOW(window), 300, 100);
gtk_window_set_title(GTK_WINDOW(window), "Bug??");
hbox = gtk_hbox_new(FALSE, 0);
tag_table = gtk_text_tag_table_new();
tag = gtk_text_tag_new(NULL);
g_object_set(G_OBJECT(tag), "weight", PANGO_WEIGHT_BOLD, NULL);
gtk_text_tag_table_add(tag_table, tag);
textbuffer = gtk_text_buffer_new(tag_table);
textview = gtk_text_view_new_with_buffer(textbuffer);
gtk_text_buffer_get_start_iter(textbuffer, &iter);
gtk_text_buffer_insert(textbuffer, &iter, " * NORMAL TEXT * ", -1);
gtk_text_buffer_insert_with_tags(textbuffer, &iter,
"BOLD TEXT", -1, tag, NULL);
gtk_text_buffer_insert(textbuffer, &iter,
" * NORMAL TEXT AGAIN * ",-1);
g_signal_connect(G_OBJECT(tag), "event", G_CALLBACK(TagEventCB), NULL);
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), NULL);
gtk_box_pack_start(GTK_BOX(hbox), textview, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(window), hbox);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
-*-*-*-*-*-*-
Sample running messages:
Button pressed on Bold Text
-- x: [113.00], y: [5.00]
Button released from Bold Text
-- x: [113.00], y: [5.00]
Motion captured
-- x: [116.00], y: [5.00]
Button pressed on Bold Text
-- x: [145.00], y: [7.00]
Button released from Bold Text
-- x: [145.00], y: [7.00]
Motion captured
-- x: [145.00], y: [11.00]
Thanks.
Dongho.
> Hi,
>
> "Dongho Shin" <electman acadcorp com> writes:
>
> > My working platform is Solaris 2.6 / Sun Ultra Sparc 10.
> > Can it be the source of my problem?
>
> it shouldn't, but unfortunately there are some bugs that are not
> triggered on Linux (where most gtk+ developers work on) but show up on
> Solaris (and other systems). So it might be that you are seeing a bug
> here that is sort of solaris-specific.
>
> In GTK+-2.0 event emission is stopped as soon as a signal handler
> returns TRUE. A typical mistake is to omit the return value of an
> event handler and declare it as a void functions. It seems that the
> usual Linux compiler generates code that works as if the void function
> returned FALSE while the typical Solaris compiler uses some value from
> the stack. In a lot of cases this value is != FALSE and thus the event
> emission stops.
>
> I'd suggest you write a very simple test case that shows the problem
> and post it here so that others can try to reproduce the problem.
> Perhaps it turns out to be a bug in GTK+-2.0.
>
>
> Salut, Sven
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]