Re: GTK 2.6 - gtk_cell_renderer_combo_new example
- From: Stephane Raimbault <stephane raimbault syneo fr>
- To: Marcus von Appen <mva sysfault org>
- Cc: GTK app-devel <gtk-app-devel-list gnome org>
- Subject: Re: GTK 2.6 - gtk_cell_renderer_combo_new example
- Date: Tue, 08 Feb 2005 17:21:21 +0100
http://cvs.sourceforge.net/viewcvs.py/lingoteach/lingoteach-ui/src/gtk/gtklearn-wiz.c?rev=1.20&view=auto
You can find it in function create_lesson_param_tree (learnSession *session).
I used an own gtk_cell_renderer_combo based on the one shipped with
gtkgrid for Gtk-2.4, but it seems to be nearly the same as the one in
Gtk-2.6.x, so you surely can give it a try.
Regards
Marcus
Works fine, thank you for your help, I have forgotten to set "editable"
to TRUE.
I join a small example if someone need help :
------
#include <gtk/gtk.h>
enum {
C_STRING,
C_TEXT_COLUMN,
NB_COLUMN
};
static void
combo_edited_cb (GtkCellRendererText *cell, const gchar *path,
const gchar *value, GtkListStore *list)
{
g_debug("COMBO_EDITED_CB");
}
GtkWidget* create_list(void)
{
GtkListStore *list_store;
GtkWidget *list;
GtkCellRenderer *renderer;
GtkListStore *list_store_combo;
GtkTreeIter iter;
list_store = gtk_list_store_new (NB_COLUMN,
G_TYPE_STRING,
G_TYPE_UINT);
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter, 0, "First Item (default)", -1);
list = gtk_tree_view_new_with_model( GTK_TREE_MODEL (list_store));
g_object_unref (list_store);
/* Combo */
renderer = gtk_cell_renderer_combo_new ();
list_store_combo = gtk_list_store_new (1, G_TYPE_STRING);
gtk_list_store_append (list_store_combo, &iter);
gtk_list_store_set (list_store_combo, &iter, 0, "First Item", -1);
gtk_list_store_append (list_store_combo, &iter);
gtk_list_store_set (list_store_combo, &iter, 0, "Second Item", -1);
gtk_list_store_append (list_store_combo, &iter);
gtk_list_store_set (list_store_combo, &iter, 0, "Third Item", -1);
g_object_set (G_OBJECT (renderer),
"model", list_store_combo,
"editable", TRUE,
NULL);
g_signal_connect (G_OBJECT (renderer),
"edited",
G_CALLBACK (combo_edited_cb),
list_store);
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(list), -1,
"Combo", renderer,
"text", C_STRING,
"text-column", C_TEXT_COLUMN,
NULL);
return list;
}
int main (int argc, char **argv)
{
GtkWidget *window;
GtkWidget *list;
gtk_init (&argc, &argv);
/* Create window, etc */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
G_CALLBACK(gtk_main_quit),
NULL);
list = create_list ();
gtk_container_add (GTK_CONTAINER (window),
list);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
--------
Bye,
Stephane
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]