[Glade-users] GtkTreeView and libglade
Jan Stępień
jan at stepien.com.pl
Sun Apr 1 02:02:00 EDT 2007
john judy napisał(a):
> Here is what I did (and all you more experienced Glade/GTK users feel free to
> critique) to use the tree views with libglade.
>
> currentKeywordListView = glade_xml_get_widget(xml,"currentKeywordList");
> //...
> keywordList = gtk_list_store_new(KEYWORD_NUM_COLS, G_TYPE_STRING, G_TYPE_UINT);
> buildKeywordList(keywordList);
> keywordListBindModel(GTK_TREE_VIEW(currentKeywordListView),keywordList);
> //...
>
> for buildKeywordList() I am just using some dummy inserts right now:
>
> //...
> /*temp dummy data*/
> gtk_list_store_append(keywordList, &iter);
> gtk_list_store_set(keywordList, &iter,
> KEYWORD_COL_KEYWORD,"atest0",
> KEYWORD_COL_KEYWORD_ID,(guint) 0,
> -1);
> //...
>
> Jan Stępień wrote:
>> Hello everyone,
>>
>> I'm beginning to develop an application in C++ using libglade instead of
>> creating user interface in standard way (GtkWidget * window =
>> gtk_window_new(GTK_WINDOW_TOPLEVEL). I've been trying, so far
>> fruitlessly, to add a GtkTreeView to my interface. I'm basing on a
>> source code taken from http://scentric.net/tutorial/ modified in order
>> to cooperate with libglade.
>>
>> While compilation and runtime I get no errors, but the row of hbox which
>> should contain my GtkTreeView is an empty white space. When I've switch
>> back to standard method without libglade the GtkTreeView is rendered
>> flawlessly.
>>
>> I've spent quite a reasonable amount of time looking for a bug, but
>> eventually everything seems to be written alright. I'm curious whether
>> there is some kind of problem between GtkTreeView and Glade or have I
>> simply made a yet unspotted mistake.
>>
>> Here's the code I'm basing on: http://scentric.net/tutorial/ch-treeview.html
>>
>> Here's an extract from my modifications.
>>
>> GtkWidget *vbox1 = glade_xml_get_widget(ui, "vbox1");
>> gtk_container_add (GTK_CONTAINER (vbox1), view);
>>
>> Obviously, I remove gtk_window_new and g_signal_connect lines.
>>
>> I attatch my Glade file. I will be grateful for your feedback.
>>
>> Regards,
>> Jan Stępień
>>
>>
Thanks for your suggestion, unfortunately it wasn't a solution. I've
checked it in two following cases.
Number one, GtkTreeView doesn't exist in the Glade project, but there's
a GtkVBox with an empty row:
GladeXML *ui = glade_xml_new("menuui.glade", "window1", NULL);
GtkTreeIter iter;
GtkWidget *view = gtk_tree_view_new();
enum{
KEYWORD_COL_KEYWORD=0,
KEYWORD_COL_KEYWORD_ID,
KEYWORD_NUM_COLS
};
GtkListStore *keywordList = gtk_list_store_new(KEYWORD_NUM_COLS,
G_TYPE_STRING, G_TYPE_UINT);
gtk_list_store_append(keywordList, &iter);
gtk_list_store_set(keywordList, &iter,KEYWORD_COL_KEYWORD,"atest0",
KEYWORD_COL_KEYWORD_ID,(guint) 0,-1);
gtk_tree_view_set_model (GTK_TREE_VIEW (view),
GTK_TREE_MODEL(keywordList));
GtkWidget *vbox1 = glade_xml_get_widget(ui, "vbox1");
gtk_container_add (GTK_CONTAINER (vbox1), view);
Doesn't work. Instead of a GtkTreeView I've got nothing - the empty row
vanished and rest of the rows have stretched to fill whole container.
Number two, GtkTreeView has been created in Glade file.
GladeXML *ui = glade_xml_new("menuui.glade", "window1", NULL);
GtkWidget *view = glade_xml_get_widget(ui, "treeview1");
GtkTreeIter iter;
enum{
KEYWORD_COL_KEYWORD=0,
KEYWORD_COL_KEYWORD_ID,
KEYWORD_NUM_COLS
};
GtkListStore *keywordList = gtk_list_store_new(KEYWORD_NUM_COLS,
G_TYPE_STRING, G_TYPE_UINT);
gtk_list_store_append(keywordList, &iter);
gtk_list_store_set(keywordList, &iter,KEYWORD_COL_KEYWORD,"atest0",
KEYWORD_COL_KEYWORD_ID,(guint) 0,-1);
gtk_tree_view_set_model (GTK_TREE_VIEW (view),
GTK_TREE_MODEL(keywordList));
As a result, the treeview1 is an empty white space.
I hope I haven't snipped too much from the source. Have you got any
further ideas?
Regards,
Jan Stępień
--
Mail jan at stepien com pl
Jabber jano at jabber aster pl
GG 1894343
Web http://stepien.com.pl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.ximian.com/pipermail/glade-users/attachments/20070401/df788faa/attachment.bin
More information about the Glade-users
mailing list