Re: RE: gtkcombobox with self internal code to the options



Woah, Like a commandment. Although I understand the sentiment.

On Jun 24, 2010 11:41am, Jeff Hallock <Jhallock wbanda com> wrote:
>
>
> You shall RTFM and try it out yourself.
>
>
>
>
>
> -----Original Message-----
>
> From: gtk-list-bounces gnome org [mailto:gtk-list-bounces gnome org] On Behalf Of John Williams
>
> Sent: Thursday, June 24, 2010 2:08 PM
>
> To: Tadej Borovšak
>
> Cc: gtk-list gnome org
>
> Subject: Re: gtkcombobox with self internal code to the options
>
>
>
> Shall I beg?
>
>
>
> 2010/6/21 John Williams asb1231 gmail com>:
>
> > Anyone?
>
> >
>
> > 2010/6/16 John Williams asb1231 gmail com>:
>
> >> Other question, how can I set the active option? gtk_combo_box_set_active?
>
> >>
>
> >> 2010/6/16 John Williams asb1231 gmail com>:
>
> >>> Yes Tadej, you understand perfectly.
>
> >>>
>
> >>> Thank you for the example!
>
> >>>
>
> >>> 2010/6/15 Tadej Borovšak tadeboro gmail com>:
>
> >>>> Hello.
>
> >>>>
>
> >>>> If I understand you correctly, you want to store name and ID of your
>
> >>>> field inside combo box and retrieve it when needed. If this is true,
>
> >>>> have a look at this snippet of code that demonstrates how to do this:
>
> >>>>
>
> >>>> -------
>
> >>>> #include
>
> >>>>
>
> >>>> enum
>
> >>>> {
>
> >>>>  COL_NAME,
>
> >>>>  COL_ID,
>
> >>>>  NO_COLS
>
> >>>> };
>
> >>>>
>
> >>>> static void
>
> >>>> cb_changed (GtkComboBox *combo)
>
> >>>> {
>
> >>>>  GtkTreeIter   iter;
>
> >>>>  GtkTreeModel *model;
>
> >>>>  gint          id;
>
> >>>>  gchar        *name;
>
> >>>>
>
> >>>>  gtk_combo_box_get_active_iter (combo, &iter);
>
> >>>>  model = gtk_combo_box_get_model (combo);
>
> >>>>  gtk_tree_model_get (model, &iter, COL_NAME, &name, COL_ID, &id, -1);
>
> >>>>
>
> >>>>  g_print ("Active selection: %s (id: %d)\n", name, id);
>
> >>>>  g_free (name);
>
> >>>> }
>
> >>>>
>
> >>>> int
>
> >>>> main (int    argc,
>
> >>>>      char **argv)
>
> >>>> {
>
> >>>>  GtkWidget       *window,
>
> >>>>                  *combo;
>
> >>>>  GtkCellRenderer *cell;
>
> >>>>  GtkListStore    *store;
>
> >>>>  gint             i;
>
> >>>>
>
> >>>>  gtk_init (&argc, &argv);
>
> >>>>
>
> >>>>  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
>
> >>>>  g_signal_connect (window, "destroy", gtk_main_quit, NULL);
>
> >>>>
>
> >>>>  store = gtk_list_store_new (NO_COLS, G_TYPE_STRING, G_TYPE_INT);
>
> >>>>  for (i = 0; i
> >>>>    {
>
> >>>>      GtkTreeIter iter;
>
> >>>>      gchar       name[] = "Item  ";
>
> >>>>
>
> >>>>      name[5] = '0' + i;
>
> >>>>      gtk_list_store_append (store, &iter);
>
> >>>>      gtk_list_store_set (store, &iter, COL_NAME, name,
>
> >>>>                                        COL_ID, g_random_int (),
>
> >>>>                                        -1);
>
> >>>>    }
>
> >>>>
>
> >>>>  combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
>
> >>>>  g_signal_connect (combo, "changed", G_CALLBACK (cb_changed), NULL);
>
> >>>>  gtk_container_add (GTK_CONTAINER (window), combo);
>
> >>>>
>
> >>>>  cell = gtk_cell_renderer_text_new ();
>
> >>>>  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
>
> >>>>  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo), cell,
>
> >>>>                                 "text", COL_NAME);
>
> >>>>
>
> >>>>  gtk_widget_show_all (window);
>
> >>>>
>
> >>>>  gtk_main();
>
> >>>>
>
> >>>>  return 0;
>
> >>>> }
>
> >>>> ----------
>
> >>>>
>
> >>>> Tadej
>
> >>>>
>
> >>>> --
>
> >>>> Tadej Borovšak
>
> >>>> tadeboro.blogspot.com
>
> >>>> tadeboro gmail com
>
> >>>> tadej borovsak gmail com
>
> >>>>
>
> >>>
>
> >>
>
> >
>
> _______________________________________________
>
> gtk-list mailing list
>
> gtk-list gnome org
>
> http://mail.gnome.org/mailman/listinfo/gtk-list
>
> _______________________________________________
>
> gtk-list mailing list
>
> gtk-list gnome org
>
> http://mail.gnome.org/mailman/listinfo/gtk-list
>

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