Re: GtkComboBox

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

 



On Fri, Jul 01, 2005 at 05:06:15PM +0530, Pramod Patangay wrote:
> I asked this question previously but there were no replies. So here I
> am again. I would like to disable a particular entry in the
> GtkComboBox. I am using a GtkComboBox with a model and supplying it
> cell renderers.

So just add a column that will control sensitivity.

Yeti


--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


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

enum { COL_TEXT, COL_SENS };

int
main(int argc, char *argv[])
{
    GtkCellRenderer *renderer;
    GtkListStore *store;
    GtkTreeIter iter;
    GtkWidget *window, *combo;

    gtk_init(&argc, &argv);
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

    store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_BOOLEAN);
    gtk_list_store_append(store, &iter);
    gtk_list_store_set(store, &iter, COL_TEXT, "Foo", COL_SENS, TRUE, -1);
    gtk_list_store_append(store, &iter);
    gtk_list_store_set(store, &iter, COL_TEXT, "Bar", COL_SENS, TRUE, -1);
    gtk_list_store_append(store, &iter);
    gtk_list_store_set(store, &iter, COL_TEXT, "Baz", COL_SENS, FALSE, -1);

    combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
    renderer = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE);
    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo), renderer,
                                  "text", COL_TEXT);
    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(combo), renderer,
                                  "sensitive", COL_SENS);
    gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
    gtk_container_add(GTK_CONTAINER(window), combo);

    gtk_widget_show_all(window);
    gtk_main();

    return 0;
}
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux