get handler_id given a signal_id



So this question is related to my previous question of how to get the
scrollbar to stick in place and not flicker when you update it.

So far we have:

    int pos = GTK_ADJUSTMENT (GTK_TEXT (text)->vadj)->value;
    gtk_text_freeze (GTK_TEXT (text));
      [do stuff]
    gtk_text_thaw (GTK_TEXT (text));
    gtk_adjustment_set_value (GTK_ADJUSTMENT (GTK_TEXT (text)->vadj), pos);

But it flickers when the adjustment is reset to its old value. So
Miranda Hawarden-Ogata suggests to block the signal handler for the
adjustment like so:

    gtk_signal_handler_block (GTK_OBJECT (text->vadj), handler_id);
     [freeze text]
     [get adj val]
     [do stuff]
     [set adj val]
     [thaw text]
    gtk_signal_handler_unblock (GTK_OBJECT (text->vadj), handler_id);

    (note - I didn't actually do the typecasting macros so to save space)
    (note 2 - see how the adjustment value is set *before* we thaw this time)

So my question is, how do I get the handler_id? Normally, a handler id
is assigned when using gtk_signal_connect (). But what if I'm not using
gtk_signal_connect to connect my scrollbar to my text widget?

    GtkWidget *vscroll;
    GtkWidget *text;

    text    = gtk_text_new (NULL, NULL);
    vscroll = gtk_vscrollbar_new (GTK_TEXT (text)->vadj);

No handler id there, and therefore, can't use gtk_signal_handler_block.
Now what I *can* get is the signal_id:

    sig_id = gtk_signal_lookup ("changed", GTK_OBJECT_TYPE (text->vadj));
    (again, no casting to save space)

So, given a signal id, how can I get a handler id to block the "changed"
signal. Would it even work? Is there a better way to solve the problem?
I've been playing around, but I'm stumped.

To recap - want a sticky scrollbar. If set adjustment before thawing,
it's useless, since thawing will reset the adjustment value. If set
adjustment after thawing, annoying flicker occurs. Possible solution by
blocking signal handler, but don't know how to get the handler id given
a signal id. Don't really want to wait for Gtk v2.0. :)

Thanks.

/Alex

-- 
Alex Chiang       <> verily, the thoughts contained withal be mine own,
Hewlett-Packard   <> and not, as it were, of mine gracious employer 
ph: 972.497.3817




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]