problem removing items from GtkCombo



Hello, guys.

I have the follwing probelm I could not resolve even by (lightly) browsing the
source of gtk+...

To get down to the point, I am talking about making AxY FTP (former WXftp,
http://www.wxftp.seul.org) profile selection combo box to work properly.
The problem arises when I have an item selected and then "Delete" button is
hit. In a callback, I remove selected item from the list associated with 
GtkCombo, hoping to have no selected items at this point and empty text
field. The residual effect is that the next item after the deleted one
remains highlighted and when I attmept to select it, the callback connected
to list is not called. This is a real problem when highlighted item is the 
last one left - there is no way to select it then.

So, how to properly remove items from the GtkCombo?


Here are relevent parts of the code:

initialization...

/* profile is a GtkCombo */
  gtk_signal_connect(GTK_OBJECT(GTK_COMBO(profile)->list),"select_child",
      GTK_SIGNAL_FUNC(listselect_cb),NULL);
}

where listselect_cb:

static void listselect_cb(GtkWidget *w,GtkWidget* item){
  int pos=gtk_list_child_position(GTK_LIST(w),item);
  /* do something not gtk-related with obtained pos */
  return;
}

in a callback connected to a "Delete" button:

/*list is combobox->list */
  gint pos;
  GList *sel=GTK_LIST(list)->selection;

  if(sel!=NULL){
    pos=gtk_list_child_position(GTK_LIST(list),sel->data);
    /* do something not gtk-related with obtained pos */
    sel=g_list_append(NULL,sel->data);
    gtk_list_unselect_all(GTK_LIST(list));
    gtk_list_remove_items(GTK_LIST(list),sel);
    /*gtk_widget_destroy(sel->data);*/ /* needed? */
    g_list_free(sel);
  }

Thanks a lot,

Alex Y.
-- 
   _ 
 _( )_
(     (o___           +-------------------------------------------+
 |      _ 7           |            Alexander Yukhimets            |
  \    (")            |       http://pages.nyu.edu/~aqy6633/      |
  /     \ \           +-------------------------------------------+



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