Re: [gtk-list] accelerators and lists (gtklist?)



On Tue, 28 Apr 1998, Pascal Rigaux wrote:

> 
> I'd like to write a file manager like program, but a very crude one, with a lot
> of short-cuts. I've written one in a perl-tk but it uses too much memory
> (something like 5Mo). That's why I'm trying to rewrite it in C/gtk+ (much more
> difficult).
> 
> There's something easy I can't do with gtk: to scroll the list with the arrow
> keys.  As far as I've seen, the arrow keys change which widget has the focus,
> and the gtklist widget isn't doing the selection.
> More precisely, I'd like a list widget in normal style, but when pressing the
> <Shift> key to extend the selection (multi style). And wen holding the <Control> 
> key... like the Windobe mechanism...
> I'm wondering if I don't have to completly rewrite the gtklist widget to do what 
> I want...

nope, not really, i've just recently implemented the possibility to
automatically adjust a GtkAdjustment so that the currently focussed
widget of a certain container is always visible. look at the usage of
gtk_container_set_focus_vadjustment in testgtk.c in Gtk+-1.0.1 (which is
not yet out, but on cvs already ;).

as for the automatic selection of the focussed widget, i think you should
derive a new widget (lets say GtkMyList ;) and do something like
(warning: untested code):

static void
gtk_my_list_class_init (GtkMyListClass *class)
{
  [...]
  
  parent_class = gtk_type_class (gtk_list_get_type ());
  
  /* override the GtkContainer::focus method with our own
   * implementation.
   */
  container_class->focus = gtk_my_list_focus;
}

static gint
gtk_my_list (GtkContainer     *container,
             GtkDirectionType  direction)
{
  gint ret_val;
  
  if (GTK_CONTAINER_CLASS (parent_class)->focus)
    ret_val = GTK_CONTAINER_CLASS (parent_class)->focus (container, direction);
  else
    ret_val = FALSE;
  
  if (container->focus_child)
    gtk_list_select_child (GTK_LIST (container), container->focus_child);
  
  return ret_val;
}


> 
> It also seems a bit complicated to add accelerators.
> All I have able to do is: add a signal, and then connect a short-cut to that
> signal. It's a bit complicated.
> By the way, I've been able to add short-cuts with gtk_accelerator_table_install
> for some shortcuts like <control-q>, but not for <Delete>...

that is a limitation in the accelerator code that will eventually be removed
in the gtk-1-1 branch, but so far noone has offered to go through the
accelerator code and make the appropriate changes.

> 
> Thank's, Pixel.
> 
> --------------
> Excuse my english, I'm French...

excuse mine, i'm german ;)

---
ciaoTJ



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