Re: [gtk-list] Re: combos / clist



Giaslas Georgios wrote:

> > 1) can i add text & pixmaps in a combo widget?

You create GtkListItem widgets and append them to the combo's list,
e.g.

    item = gtk_list_item_new ();
    gtk_widget_show (item);

    hbox = gtk_hbox_new (FALSE, 3);
    gtk_container_add (GTK_CONTAINER (item), hbox);
    gtk_widget_show (hbox);

    <create pixmap>
    gtk_widget_show (pixmap);
    gtk_box_pack_start (GTK_BOX (hbox), pixmap, FALSE, FALSE, 0);

    label = gtk_label_new ("hello");
    gtk_widget_show (label);
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

    gtk_combo_set_item_string (GTK_COMBO (combo), GTK_ITEM (item), "hello");
    gtk_container_add (GTK_CONTAINER (GTK_COMBO (combo)->list), item);

Note that you need to call gtk_combo_set_item_string() to set the text
which is placed in the entry field when the item is selected.


> > 2) how can i learn at any time which rows are selected
> > in a clist widget at GTK_SELECTION_EXTENDED mode?

The selection member of the GtkCList struct contains a list of the rows which
are currently selected:

  GList *selection;
  gint row;

  selection = GTK_CLIST (clist)->selection;
  while (selection)
    {
      row = GPOINTER_TO_INT (selection->data);
      g_print ("Selected Row: %i\n", row);

      selection = selection->next;
    }


Damon




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