[Glade-users] (newbie) combobx and model



2007/5/4, John Coppens <john at jcoppens.com>:
On Fri, 4 May 2007 13:40:21 +0200
"david cobac" <david.cobac at gmail.com> wrote:

But, i don't know how to link this to my combobox !

gtk_combo_box_set_model is your friend here.

Look up the gtktree tutorial, which will answer many of those questions:

http://scentric.net/tutorial/ gtk_combo_box_set_model


Hi,
i studied this document, but had some difficulties to link it with
glade's combobox. I'va created a single combobox 'combobox1' in a
single window 'window1' and  i try this but no success in display :

/////////////
#include <gtk/gtk.h>
#include <glade/glade.h>

#define FILENAME "cb.glade"

GladeXML *xml;
GtkWidget *maFenetre;
GtkWidget *c;

int init ();
gboolean onFerme(GtkObject *w,gpointer d);

int
main(int argc, char **argv)
{
  gtk_init(&argc, &argv);
  xml = glade_xml_new(FILENAME, NULL, NULL);

  maFenetre=glade_xml_get_widget(xml,"window1");
  glade_xml_signal_autoconnect(xml);
  gtk_signal_connect(GTK_OBJECT(maFenetre),"destroy",(GtkSignalFunc)
onFerme,NULL);
  init();
  gtk_widget_show(maFenetre);
  gtk_main();

  return 0;
}

int init () {
  GtkListStore *l;
  GtkTreeIter iter;
  GtkTreeModel *model;
  int i;
  gchar *ch;

  //
  l=gtk_list_store_new(1,GTK_TYPE_INT);
  c=glade_xml_get_widget(xml,"combobox1");
  gtk_combo_box_set_model(GTK_COMBO_BOX(c),GTK_TREE_MODEL(l));
  for(i=0;i<30;i++) {
    gtk_list_store_append(l,&iter);
    gtk_list_store_set(l,&iter,0,i+1,-1);
  }
  return 0;
}

gboolean onFerme (GtkObject *w,gpointer d) {
  gtk_main_quit();
  return 0;
}
/////////////


what am i doing so wrong ?

thanks for any help.

-- 
Cordialement
                           David Cobac <http://dcobac.free.fr>




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