GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Mar 30, 2015 11:02 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: gtk_combo_box_set_wrap_width NOT WORKING
PostPosted: Sun Mar 29, 2015 2:03 pm 
Offline

Joined: Sat Mar 28, 2015 10:36 pm
Posts: 3
Hello,

I have used the function gtk_combo_box_set_wrap_width in gtk+ version 2.14 and it worked fine. But, since I updated to 2.16 and 3.xx now, the function does not work. It does not display my tree model in a table format anymore.

I have written a small program (see below) and could not get gtk_combo_box_set_wrap_width to work.

Any help would be much appreciated.

Thanks
Nethaji
------------------------------------------
Code:
#include <stdio.h>
#include <gtk/gtk.h>

gint destroymainwin(GtkWidget *any_widget, GdkEvent *event, gpointer data)
{
g_print("Exiting on user command!\n");
gtk_main_quit();
return FALSE;
}

main(int argc, char *argv[])
{
gtk_init(&argc, &argv);

GtkWidget *main_window;
GtkTreeStore *treestore;
GtkWidget *combobox;
GtkCellRenderer *name_renderer;
GtkTreeIter iter;
gint count = 0;

/*Declare tree store and pack some text into it:*/
treestore = gtk_tree_store_new(2, G_TYPE_INT, G_TYPE_STRING);
name_renderer = gtk_cell_renderer_text_new();
gtk_cell_renderer_set_fixed_size(GTK_CELL_RENDERER(name_renderer), -1, -1);

for(count = 1; count <= 50; count++)
   {
      gtk_tree_store_append(treestore, &iter, NULL);
      gtk_tree_store_set(
                        treestore, &iter,
                        0, count,
                        1, "One",
                        -1
                       );
   }

/*Set the tree model to the combo box:*/
combobox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(treestore));
gtk_widget_set_size_request(GTK_WIDGET(combobox), -1, -1);
gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(combobox), 10);
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), name_renderer, TRUE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), name_renderer, "text", 0, NULL);

main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request(GTK_WIDGET(main_window),100,25);
gtk_container_add(GTK_CONTAINER(main_window), combobox);

gtk_widget_show_all(main_window);

/*Signals and event handlers:*/
g_signal_connect(G_OBJECT(main_window), "delete_event", G_CALLBACK(destroymainwin), NULL); /*Signal handler to close the window.*/

gtk_main();
}

----------------------
Compile the program with
gcc `pkg-config --cflags --libs gtk+-3.0` -g combobox.c


Top
 Profile  
 
 Post subject: Re: gtk_combo_box_set_wrap_width NOT WORKING
PostPosted: Sun Mar 29, 2015 7:49 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 847
Location: UK
Hi,

I have just tried your example on on Debian Jessie with GTK+ 3.14 using the Adwaita theme. It produces the expected table format for the combo box. When the drop down is selected a table is shown.

_________________
E.


Top
 Profile  
 
 Post subject: Re: gtk_combo_box_set_wrap_width NOT WORKING
PostPosted: Mon Mar 30, 2015 9:34 am 
Offline

Joined: Sat Mar 28, 2015 10:36 pm
Posts: 3
Hi Errol,

Many thanks for your reply. The gtk+ version is 3.10 and my OS is Fedora 20. I will try to install gtk+ v3.14 and compile the program to see what the result would be.

Not sure about the theme for the GTK+ behaviour though.

I will update soon.

Thanks
Nethaji


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

All times are UTC


Who is online

Users browsing this forum: Yahoo [Bot] and 2 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