CList scrollbar setting solution!
- From: "D. Emilio Grimaldo Tunon" <emilio_tunon nl compuware com>
- To: gtk-list redhat com
- Subject: CList scrollbar setting solution!
- Date: Fri, 27 Nov 1998 15:31:01 +0100
Please disregard my previous message (didn't get any responses
anyway...) I found out how to do it in 1.0.5 if anybody is
interested I will post it here. It looks ugly (and is ugly
and heavily relies upon knowledge of the internal structures!)
but it works:
typedef struct {
GtkAdjustment *adjustment;
gfloat value;
} ClistScrollStruct;
ClistScrollStruct cscroll;
gfloat getClistScrollbarValue(gint vertical, GtkAdjustment **adj)
{
GtkWidget *vsw;
GtkScrollbar vs;
GtkRange vsr;
GtkAdjustment *adjPtr;
gfloat value;
if (vertical) {
vsw = GTK_CLIST(clist)->vscrollbar;
} else {
vsw = GTK_CLIST(clist)->hscrollbar;
}
vs = GTK_VSCROLLBAR(vsw)->scrollbar;
vsr = vs.range;
adjPtr = gtk_range_get_adjustment(&vsr);
value = adjPtr->value;
*adj = adjPtr;
return(value);
}
/* Some point just before using clist_clear() save the
* current position of the scrollbar
*/
cscroll.value = getClistScrollbarValue(1, &cscroll.adjustment);
gtk_clist_clear();
/* Then the clist is populated again. And for the sake of the
* hack let's assume the previous setting is still within
* bounds.
*/
<populate clist>
/*
* At this point the vscrollbar is at the top, lets position
* it to our last known setting that we saved.
*/
gtk_adjustment_set_value(cscroll.adjustment, cscroll.value);
I will clean this up and use it in my 1.0.5 application (this
was just an experiment so coding is not perfect!. But I would
definitely like to know:
1. Is there a simpler way to do it in 1.0.5?
2. What about less internals-dependent way? (1.0.5)
3. How to do it in 1.1.x (I don't have that)
Thanks,
Emilio
--
D. Emilio Grimaldo Tunon Compuware Europe B.V. (Uniface Lab)
Software Engineer Amsterdam, The Netherlands
emilio_tunon@nl.compuware.com Tel. +31 (0)20 3126 516
*** The opinions expressed hereby are mine and not my employer's ***
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]