Re: TextPad and GtkEText



On Sun, 12 Mar 2000, Emmanuel DELOGET wrote:

> > > * some of the TextPad Edit Menu features should be good
> > > too (join lines, change case, and so on) [or at least
> > > providing an interface to register keybings and edit
> > > functions]
> >
> > there's the GtkBinding mechanism readily available for this,
> > configurable even through rc files.
> 
>     GtkBindingSet has a rather complex interface. I never
>     used it before and so my conclusions may be wrong but:
> 
>     1) they cannot be used to generate user signals (which
>     would be helpful in some particular cases when I want to
>     add some very special bindings to an existing widget
>     without poluting the whole widget class with ). This comes from
>     the gtk_binding_entry_activate func:
> 
> for (sig = entry->signals; sig; sig = sig->next)
>   {
>     /* ... */
>     signal_id = gtk_signal_lookup (sig->signal_name, GTK_OBJECT_TYPE (object));
>     if (!signal_id)
>       {
>         g_warning ("gtk_binding_entry_activate(): binding \"%s::%s\": "
>            "could not find signal \"%s\" in the `%s' class ancestry",
>            entry->binding_set->set_name,
>            accelerator,
>            sig->signal_name,
>            gtk_type_name (GTK_OBJECT_TYPE (object)));
>       }
>       /* ... */
>   }

this is just code to lookup signals for certain classes, of course you can
create user signals (with GTK_RUN_ACTION) and have them arbitrarily triggered
through gtk bindings.
say you introduce a signal
  void   (*scroll_vertical)     (GtkEText       *clist,
                                 GtkScrollType   scroll_type,
                                 gfloat          n_lines);
in the GtkETextClass (this could also be a user signal that you connect
a handler for), you can use the bindings mechanism, e.g. from the rc file as:

binding "etext-movement"
{
  bind "<ctrl>j" {
    "scroll-vertical" (step-backward, 1.0)
  }
  bind "<ctrl>k" {
    "scroll-vertical" (step-forward, 1.0)
  }
}
class "GtkEText" binding "etext-movement"

take a look at the end of testgtkrc, it caries this exact example
(amongst others) for the clist.


>     Of course, I can create a widget with a "binding-activate" signal,
>     this signal should have some useful params (the keyval & modifiers
>     and perhaps a function pointer) and finnaly sucessfully handle these.
> 
>     This means that I must say to my users : << if you want to
>     provide additional functionnalities, you need to add a
>     binding entry to the "etext-bindings" binding set. Then you need
>     to connect a callback to "binding-activate". Then I promise to
>     throw some useful informations at your face. Are you happy? >>

nah nah, this is not at all how the bindings are supposed to be used,
you're making me ripp my hair off with that idea ;)

>     Yours,
> 
>     Emmanuel
> 

---
ciaoTJ



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