gtk question: GtkComboBox

From: Andreas Røsdal (andrearo_at_stud.ntnu.no)
Date: 05/29/04

  • Next message: jerrygarciuh: "newbie sed question"
    Date: Sat, 29 May 2004 23:26:16 +0200
    
    

    Hi,

    I'm trying to modify some Gtk code, and need some help. Sorry, there is
    no gtk newsgroup, so this is the closest I get..

    I'm modifying the gtk-demo which comes with the gtk distribution. The file
    is sizegroup.c The original code doesn't use a list model to hold the
    text, so I want to create a model (liste_modell), which holds the text I'm
    interested in. See code attached.

    The problem is that the list becomes empty, even though I put several
    strings in the listmodel. Thus, the combobox is also empty.

    Can anyone spot the problem? Thanks!

    /* Convenience function to create a combo box holding a number of strings
     */
    GtkWidget *
    create_combo_box (const char **strings)
    {
      GtkWidget *combo_box;
      GtkListStore *liste_modell;
      GtkTreePath *path;
      GtkTreeIter iter;
      const char **str;

       liste_modell = gtk_list_store_new(1, G_TYPE_STRING );

      gtk_list_store_insert(liste_modell, &iter, 0);

      for (str = strings; *str; str++) {
        gtk_list_store_set (liste_modell, &iter,
                          0, *str,
                              -1);
    }

      combo_box = gtk_combo_box_new_with_model
    (GTK_TREE_MODEL(liste_modell));

     gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);

      return combo_box;
    }


  • Next message: jerrygarciuh: "newbie sed question"

    Relevant Pages