mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-12-02 13:39:43 -06:00
fix main window re-scrolling problem
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@181 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
ddcdc1fd0e
commit
18e23914a3
@ -224,14 +224,56 @@ refreshMainWindow( void )
|
||||
{
|
||||
|
||||
int nrows;
|
||||
int row_from_top;
|
||||
AccountGroup *grp = topgroup; /* hack -- should pass as argument ... */
|
||||
|
||||
/* During refresh, we remove and re-add all displayed accounts.
|
||||
* We need to do this because the refresh may be due to an account
|
||||
* having been added, or due to an expansion of sub-accounts.
|
||||
* However, doing this will cause the window to be scrolled
|
||||
* to the top row, which is visually quite annoying. Thus, we
|
||||
* will save the current selected, visible row, and rescroll
|
||||
* the redrawn window to put this row back to its original location.
|
||||
* So -- first, figure out whats visible, and then restore.
|
||||
*/
|
||||
if (selected_acc) {
|
||||
int i, toprow;
|
||||
XtVaGetValues( accountlist, XmNrows, &nrows, NULL );
|
||||
|
||||
for (i=0; i<nrows; i++) {
|
||||
Account * racc;
|
||||
racc = (Account *) XbaeMatrixGetRowUserData (accountlist, i);
|
||||
if (racc == selected_acc) break;
|
||||
}
|
||||
XtVaGetValues( accountlist, XmNtopRow, &toprow, NULL );
|
||||
row_from_top = i - toprow;
|
||||
if (0 > row_from_top) row_from_top = 0; /* this should neve happen !? */
|
||||
}
|
||||
|
||||
XtVaGetValues( accountlist, XmNrows, &nrows, NULL );
|
||||
XbaeMatrixDeleteRows( accountlist, 0, nrows );
|
||||
|
||||
xaccRecomputeGroupBalance (grp);
|
||||
xaccMainWindowAddAcct (accountlist, grp, 0);
|
||||
xaccMainWindowRedisplayBalance ();
|
||||
|
||||
/* find the selected account in the new window,
|
||||
* and scroll to it. */
|
||||
if (selected_acc) {
|
||||
int i, toprow;
|
||||
XtVaGetValues( accountlist, XmNrows, &nrows, NULL );
|
||||
|
||||
for (i=0; i<nrows; i++) {
|
||||
Account * racc;
|
||||
racc = (Account *) XbaeMatrixGetRowUserData (accountlist, i);
|
||||
if (racc == selected_acc) break;
|
||||
}
|
||||
toprow = i - row_from_top;
|
||||
|
||||
/* set this row to be the top visible row */
|
||||
XtVaSetValues( accountlist, XmNtopRow, toprow, NULL );
|
||||
XbaeMatrixSelectRow( accountlist, i );
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
@ -332,27 +374,8 @@ expandListCB( Widget mw, XtPointer pClientData, XtPointer cb)
|
||||
}
|
||||
|
||||
/* redraw the main window */
|
||||
selected_acc = acc;
|
||||
refreshMainWindow ();
|
||||
|
||||
/* find the selected account in the new window,
|
||||
* and scroll to it. */
|
||||
XtVaGetValues( accountlist, XmNrows, &nrows, NULL );
|
||||
|
||||
for (i=0; i<nrows; i++) {
|
||||
Account * racc;
|
||||
racc = (Account *) XbaeMatrixGetRowUserData (accountlist, i);
|
||||
if (racc == acc) {
|
||||
Boolean isviz;
|
||||
isviz = XbaeMatrixIsRowVisible (accountlist, i);
|
||||
if (False == isviz) {
|
||||
/* scroll to bottom first, so that during rewind,
|
||||
* sub-accounts become visible too */
|
||||
XbaeMatrixMakeCellVisible (accountlist, nrows-1, 0);
|
||||
XbaeMatrixMakeCellVisible (accountlist, i, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
|
Loading…
Reference in New Issue
Block a user