GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Oct 23, 2014 12:25 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Limit GtkComboBox popup height
PostPosted: Sat Nov 19, 2011 11:22 am 
Offline

Joined: Sat Nov 19, 2011 11:12 am
Posts: 1
I was finding the way to limit of height of popup window for GtkComboBox and when that height is reached the control will get scrollbars. I cannot find wa way to do that. the list flows from top to bottom of window (try the attached code). I have checked API and I cannot find useful method. I'm new to GTK+ and I have searched google for days.
Code:
#include <gtk/gtk.h> 

int main(int argc, char** argv) {
    GtkWidget* frame;//main frame
    GtkWidget* combobox;
    GtkWidget* listbox;
    GtkWidget* okbutton;
    GtkWidget* cancelbutton;
    GtkWidget* hbox_buttons;
    GtkWidget* vbox;

    gtk_init(&argc, &argv);
    //create widgets
    frame = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    /*Combobox issues*/
    GtkListStore* list_store;
    list_store = NULL;
    GtkTreeIter iter;
    list_store=gtk_list_store_new(1,G_TYPE_STRING);
    int i;
    for(i=0; i<100; i++) { 
        gtk_list_store_append(list_store, &iter);
        gtk_list_store_set(list_store, &iter,0,"Residental", -1);
    }
    combobox = gtk_combo_box_new_with_model((GtkTreeModel *)list_store);
    g_object_unref(G_OBJECT(list_store));
    GtkCellRenderer* cell = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), cell, TRUE);
    gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), cell, "text", 0, NULL);


    listbox = gtk_list_new();
    okbutton = gtk_button_new_with_label("Ok");
    cancelbutton = gtk_button_new_with_label("Cancel");
    //create containers
    hbox_buttons = gtk_hbox_new(FALSE, 5);
    vbox = gtk_vbox_new(FALSE, 5);

    //Pack things
    gtk_container_add(GTK_CONTAINER(frame),vbox);
    gtk_box_pack_start(GTK_BOX(vbox), combobox, FALSE, FALSE, 5);
    gtk_box_pack_start(GTK_BOX(vbox), listbox, TRUE, TRUE, 5);
    //pack buttons
    gtk_box_pack_start(GTK_BOX(hbox_buttons), okbutton, TRUE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(hbox_buttons), cancelbutton, TRUE, TRUE, 5);
    gtk_box_pack_start(GTK_BOX(vbox), hbox_buttons, FALSE, TRUE, 5);
    //gtk_box_pack_start(vbox, listbox, TRUE, TRUE, 5);
    g_signal_connect_swapped(G_OBJECT(frame), "destroy",
                             G_CALLBACK(gtk_main_quit), G_OBJECT(frame));

    gtk_widget_show_all(frame);

    gtk_main();


    return 0;
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group