Re: TreeView in ScrolledWindow
- From: "q." <mailing-lists xs4all nl>
- To: gtk-app-devel-list gnome org
- Subject: Re: TreeView in ScrolledWindow
- Date: Fri, 14 Sep 2007 18:34:39 +0200 (CEST)
On Fri, 14 Sep 2007, yetist wrote:
Maybe you should use gtk_scrolled_window_add_with_viewport to add the
view into scrollwindow. like this:
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
view);
2007/9/14, q. <mailing-lists xs4all nl>:
Hello ppl,
I have a treeview that works and displays correctly, but when I try put it
into a scrolled window I run into some problems.
Unfortunatly I'm not fluent (yet) in GTK. As such I believe I mixed some
of the wrong properties. I have pasted the creation of the scrolled window
and the toplevel window below. I know the tree works good since I have
already tried it. But getting that thing in a scrolled window; somehow I
missed the point I'm affraid.
Any directions that would get me back on track are greatly appreciated.
Thankx!
int main(int argc, char *argv[]) {
GtkWidget *window;
GtkWidget *scrolled_window;
GtkWidget *view;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window, "delete_event", gtk_main_quit, NULL);
gtk_widget_set_size_request(window, 300, 300);
gtk_container_set_border_width(GTK_CONTAINER(window), 0);
gtk_window_set_title(GTK_WINDOW(window), "Scrolled Treeview ?");
scrolled_window = gtk_scrolled_window_new(NULL, NULL);
gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 10);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
view = create_view_and_model();
gtk_container_add(GTK_CONTAINER(scrolled_window), view);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
Thankx for the reply !
I have changed the root window to a dialog and packed the view model into
the scrolled window and it works. Allthough the code feels a bit clumsy
because I don't understand it fully yet. I hope it is the correct GTK way
now. I have pasted the ``working'' and changed part below. If it's not
correct, any tips on doing it the correct way are welcome.
THankx again!
int main(int argc, char *argv[]) {
GtkWidget *window;
GtkWidget *scrolled_window;
GtkWidget *view;
gtk_init(&argc, &argv);
window = gtk_dialog_new();
g_signal_connect(window, "delete_event", gtk_main_quit, NULL);
gtk_widget_set_size_request(window, 300, 300);
gtk_container_set_border_width(GTK_CONTAINER(window), 0);
gtk_window_set_title(GTK_WINDOW(window), "Scrolled Treeview ?");
scrolled_window = gtk_scrolled_window_new(NULL, NULL);
gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 10);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
view = create_view_and_model();
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
view);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), scrolled_window,
TRUE, TRUE, 0);
gtk_widget_show_all(window);
gtk_widget_show_all(scrolled_window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]