Re: GtkClist and scrollbars
- From: Adam Bernstein <number6 ip120 gte16 rb1 bel nwlink com>
- To: suzan Allen <sue200270 hotmail com>
- Cc: gtk-list gnome org
- Subject: Re: GtkClist and scrollbars
- Date: Thu, 28 Nov 2002 09:44:21 -0800 (PST)
On Thu, 28 Nov 2002, suzan Allen wrote:
>
>
> Hi everyone,
>
> I have a GtkClist with one column that I want to add scrollbars to. I am
> using
> gtk+1.2 and found out that I have to add first a scrolled window then add
> the clist
> to it. I used gtk_scrolled_window_add_with_viewport(). But the problem is
> that the
> clist gets very small and can only view one char per row. Although I have
> set the
> column width to a certain size,it still doesnt work.
> Does anyone have an idea how could this be done?
>
> Thanks,
> Sue.
Sue:
I am doing exactly what you are doing in this application I am writing, and
it works just fine. Here is the code from my application for creating the
clist/scrolled window. After the ___make_scrolled_window() function, is the
code where that gets called:
GtkWidget *___make_scrolled_window(GtkWidget **rlist, GtkWidget **revent_box)
{
GtkWidget *scrolled_window;
GtkWidget *event_box;
GtkWidget *list;
char *list_titles[3];
/*
* create a new scrolled window.
*/
scrolled_window = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_show(scrolled_window);
list_titles[0] = "File name";
list_titles[1] = "Start Time";
list_titles[2] = "End Time";
list = gtk_clist_new_with_titles(3, list_titles);
event_box = gtk_event_box_new();
gtk_widget_show(event_box);
gtk_container_add(GTK_CONTAINER(event_box), list);
gtk_scrolled_window_add_with_viewport(
GTK_SCROLLED_WINDOW(scrolled_window), event_box);
gtk_widget_set_events(event_box, GDK_BUTTON_PRESS_MASK);
gtk_widget_show(list);
gtk_clist_set_column_auto_resize(GTK_CLIST(list), 0, TRUE);
gtk_clist_set_column_auto_resize(GTK_CLIST(list), 1, TRUE);
gtk_clist_set_column_auto_resize(GTK_CLIST(list), 2, TRUE);
gtk_clist_column_titles_passive(GTK_CLIST(list));
gtk_clist_set_column_justification(GTK_CLIST(list), 1, GTK_JUSTIFY_FILL);
gtk_clist_set_column_justification(GTK_CLIST(list), 2, GTK_JUSTIFY_FILL);
*rlist = list;
if (revent_box) {
*revent_box = event_box;
}
return scrolled_window;
}
...
editctx.scrolled_window =
___make_scrolled_window(&editctx.clist, &event_box);
gtk_widget_set_size_request(editctx.scrolled_window,
400, 200);
gtk_box_pack_start(GTK_BOX(box),
editctx.scrolled_window, FALSE, FALSE, 2);
...
This snipit does not tell the whole story. The scrolled window is one of
many widgets in the main window box container. Your scrolled window/clist
widget is probably fine. Once you force the scrolled window size to be
larger than the default when it is empty, it will be more what you expect.
You can force the scrolled window to have a non-degenerate size by calling
gtk_widget_set_size_request(), like above. Once you use the scrolled window
in a container context that forces its size to be larger than the empty
default, you will no longer need the gtk_widget_set_size_request() call.
The fact my clist is in an event box should not change the size of either
the list or the scrolled window. I am doing that so I can intercept
mouse button presses that the main window would otherwise get.
Hope this helps,
Adam
---
Adam Bernstein no6 pobox com http://pobox.com/~no6 http://mpgedit.org
"Who are you? The new Number 2. Who is Number 1? You are, Number 6.
I am not a number, I am a free man! Aha ha ha ha ha..."
Key fingerprint = DD 2B 08 4C 51 B6 2B FF 18 41 84 E8 93 8A 27 8D
Adam
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]