mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Change the way the sheet popup treeview height is obtained.
Instead of using the sheet row height as the basis of obtaining the popup height use the treeview cellrenderer height instead. This has the advantage that any CSS font change applied to the treeview will be used to get the correct height.
This commit is contained in:
@@ -904,7 +904,8 @@ popup_get_height (G_GNUC_UNUSED GtkWidget* widget,
|
||||
int count, height;
|
||||
|
||||
count = gnc_item_list_num_entries (box->item_list);
|
||||
height = count * row_height;
|
||||
height = count * (gnc_item_list_get_cell_height (box->item_list) + 2);
|
||||
|
||||
if (height < space_available)
|
||||
{
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwin),
|
||||
|
||||
@@ -125,6 +125,8 @@ gnc_date_picker_class_init (GNCDatePickerClass *date_picker_class)
|
||||
|
||||
object_class = G_OBJECT_CLASS (date_picker_class);
|
||||
|
||||
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS(date_picker_class), "gnc-id-date-picker");
|
||||
|
||||
gnc_date_picker_signals[DATE_SELECTED] =
|
||||
g_signal_new("date_selected",
|
||||
G_TYPE_FROM_CLASS(object_class),
|
||||
|
||||
@@ -1015,7 +1015,10 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
|
||||
// Lets check popup height is the true height
|
||||
item_edit->popup_returned_height = popup_h;
|
||||
|
||||
gtk_widget_set_size_request (item_edit->popup_item, popup_w - 1, popup_h);
|
||||
if (popup_h == popup_max_height)
|
||||
gtk_widget_set_size_request (item_edit->popup_item, popup_w - 1, popup_h);
|
||||
else
|
||||
gtk_widget_set_size_request (item_edit->popup_item, popup_w - 1, -1);
|
||||
|
||||
toggle = GTK_TOGGLE_BUTTON(item_edit->popup_toggle.tbutton);
|
||||
|
||||
@@ -1084,6 +1087,7 @@ gnc_item_edit_hide_popup (GncItemEdit *item_edit)
|
||||
gtk_widget_grab_focus (GTK_WIDGET (item_edit->sheet));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gnc_item_edit_set_popup (GncItemEdit *item_edit,
|
||||
GtkWidget *popup_item,
|
||||
|
||||
@@ -283,6 +283,7 @@ gnc_item_list_init (GncItemList* item_list)
|
||||
item_list->tree_view = NULL;
|
||||
item_list->list_store = NULL;
|
||||
item_list->temp_store = NULL;
|
||||
item_list->cell_height = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -385,6 +386,7 @@ gnc_item_list_class_init (GncItemListClass* item_list_class)
|
||||
|
||||
gnc_item_list_parent_class = g_type_class_peek_parent (item_list_class);
|
||||
|
||||
gtk_widget_class_set_css_name (GTK_WIDGET_CLASS(item_list_class), "gnc-id-sheet-list");
|
||||
|
||||
gnc_item_list_signals[SELECT_ITEM] =
|
||||
g_signal_new ("select_item",
|
||||
@@ -474,11 +476,25 @@ tree_view_selection_changed (GtkTreeSelection* selection,
|
||||
g_free (string);
|
||||
}
|
||||
|
||||
|
||||
gint
|
||||
gnc_item_list_get_cell_height (GncItemList *item_list)
|
||||
{
|
||||
|
||||
gint min_height, nat_height;
|
||||
gtk_cell_renderer_get_preferred_height (item_list->renderer,
|
||||
GTK_WIDGET(item_list->tree_view),
|
||||
&min_height,
|
||||
&nat_height);
|
||||
|
||||
return min_height;
|
||||
}
|
||||
|
||||
|
||||
GtkWidget*
|
||||
gnc_item_list_new (GtkListStore* list_store)
|
||||
{
|
||||
GtkWidget* tree_view;
|
||||
GtkCellRenderer* renderer;
|
||||
GtkTreeViewColumn* column;
|
||||
|
||||
GncItemList* item_list =
|
||||
@@ -508,9 +524,9 @@ gnc_item_list_new (GtkListStore* list_store)
|
||||
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store),
|
||||
0, GTK_SORT_ASCENDING);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
item_list->renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes (_ ("List"),
|
||||
renderer,
|
||||
item_list->renderer,
|
||||
"text", 0,
|
||||
NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
|
||||
@@ -526,11 +542,9 @@ gnc_item_list_new (GtkListStore* list_store)
|
||||
g_signal_connect (G_OBJECT (tree_view), "key_press_event",
|
||||
G_CALLBACK (gnc_item_list_key_event), item_list);
|
||||
|
||||
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (
|
||||
tree_view))), "changed",
|
||||
g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (
|
||||
GTK_TREE_VIEW (tree_view))), "changed",
|
||||
G_CALLBACK (tree_view_selection_changed), item_list);
|
||||
|
||||
return GTK_WIDGET (item_list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -45,6 +45,8 @@ typedef struct
|
||||
GtkScrolledWindow* scrollwin;
|
||||
GtkListStore *list_store; /* Contains the list items */
|
||||
GtkListStore *temp_store; /* Temporary store for typeahead select */
|
||||
GtkCellRenderer *renderer;
|
||||
gint cell_height;
|
||||
} GncItemList;
|
||||
|
||||
typedef struct
|
||||
@@ -69,6 +71,8 @@ GtkWidget *gnc_item_list_new (GtkListStore *shared_store);
|
||||
|
||||
gint gnc_item_list_num_entries (GncItemList *item_list);
|
||||
|
||||
gint gnc_item_list_get_cell_height (GncItemList *item_list);
|
||||
|
||||
void gnc_item_list_clear (GncItemList *item_list);
|
||||
|
||||
void gnc_item_list_append (GncItemList *item_list, const char *string);
|
||||
|
||||
Reference in New Issue
Block a user