Reconcile vertical scrollbars hover over tree view data

In the reconcile window the vertical scrollbars when selected obscure
the tree view data so get the width of the scrollbar and add it to the
cell renderer x padding of the last column.
This commit is contained in:
Robert Fewell 2018-07-15 16:40:18 +01:00 committed by John Ralls
parent c513d78846
commit aa77b21dfb
3 changed files with 32 additions and 2 deletions

View File

@ -233,6 +233,25 @@ gnc_reconcile_view_tooltip_cb (GNCQueryView *qview, gint x, gint y,
}
void
gnc_reconcile_view_add_padding (GNCReconcileView *view, gint column, gint xpadding)
{
GNCQueryView *qview = GNC_QUERY_VIEW (view);
GtkTreeViewColumn *col;
GList *renderers;
GtkCellRenderer *cr0;
gint xpad, ypad;
col = gtk_tree_view_get_column (GTK_TREE_VIEW (qview), (column - 1));
renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col));
cr0 = g_list_nth_data (renderers, 0);
g_list_free (renderers);
gtk_cell_renderer_get_padding (cr0, &xpad, &ypad);
gtk_cell_renderer_set_padding (cr0, xpadding, ypad);
}
/****************************************************************************\
* gnc_reconcile_view_new *
* creates the account tree *

View File

@ -110,6 +110,8 @@ void gnc_reconcile_view_unselect_all (GNCReconcileView *view);
gboolean gnc_reconcile_view_changed (GNCReconcileView *view);
void gnc_reconcile_view_add_padding (GNCReconcileView *view, gint column, gint xpadding);
G_END_DECLS
#endif /* GNC_RECONCILE_VIEW_H */

View File

@ -1141,6 +1141,8 @@ gnc_reconcile_window_create_view_box(Account *account,
GtkWidget **total_save)
{
GtkWidget *frame, *scrollWin, *view, *vbox, *label, *hbox;
GtkWidget *vscroll;
GtkRequisition nat_sb;
frame = gtk_frame_new(NULL);
@ -1184,6 +1186,13 @@ gnc_reconcile_window_create_view_box(Account *account,
gtk_container_add(GTK_CONTAINER(scrollWin), view);
gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
// get the vertical scroll bar width
vscroll = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (scrollWin));
gtk_widget_get_preferred_size (vscroll, NULL, &nat_sb);
// add xpadding to amount column so scrollbar does not cover
gnc_reconcile_view_add_padding (GNC_RECONCILE_VIEW(view), REC_AMOUNT, nat_sb.width);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
gtk_box_set_homogeneous (GTK_BOX (hbox), FALSE);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
@ -1197,9 +1206,9 @@ gnc_reconcile_window_create_view_box(Account *account,
*total_save = label;
#if GTK_CHECK_VERSION(3,12,0)
gtk_widget_set_margin_end (GTK_WIDGET(label), 10);
gtk_widget_set_margin_end (GTK_WIDGET(label), 10 + nat_sb.width);
#else
gtk_widget_set_margin_right (GTK_WIDGET(label), 10);
gtk_widget_set_margin_right (GTK_WIDGET(label), 10 + nat_sb.width);
#endif
return vbox;