Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Mon, 02 May 2016 13:19:26 UTC Commit: abf0365e43156be12cc0a03b0a5fb6325039b6f0 https://github.com/geany/geany/commit/abf0365e43156be12cc0a03b0a5fb6325039b6...
Log Message: ----------- GTK: Fix auto-completion popup sizing code for GTK 3.20
GTK 3.20's GtkScrolledWinodw doesn't like having a too small allocation and spews scary assertion failures. Fix that by requesting the real size we'd like instead of hard-coding 1 as small-enough value in our overriding height requisition method.
The actual value doesn't really matter so long as it's small enough anyway, as we resize the popup to fit later on.
Note: this moves the actual implementation of ListBoxX::GetRowHeight() to the new convenience function treeViewGetRowHeight(), with no changes in implementation.
X-Scintilla-Bug-URL: https://sourceforge.net/p/scintilla/bugs/1825/ X-Scintilla-Commit-ID: 5a0afdd87d56d837dd8068e234aed8e2b6bdbe93
Modified Paths: -------------- scintilla/gtk/PlatGTK.cxx
Modified: scintilla/gtk/PlatGTK.cxx 63 lines changed, 39 insertions(+), 24 deletions(-) =================================================================== @@ -1263,6 +1263,31 @@ ListBox *ListBox::Allocate() { return lb; }
+static int treeViewGetRowHeight(GtkTreeView *view) +{ +#if GTK_CHECK_VERSION(3,0,0) + // This version sometimes reports erroneous results on GTK2, but the GTK2 + // version is inaccurate for GTK 3.14. + GdkRectangle rect; + GtkTreePath *path = gtk_tree_path_new_first(); + gtk_tree_view_get_background_area(view, path, NULL, &rect); + gtk_tree_path_free(path); + return rect.height; +#else + int row_height=0; + int vertical_separator=0; + int expander_size=0; + GtkTreeViewColumn *column = gtk_tree_view_get_column(view, 0); + gtk_tree_view_column_cell_get_size(column, NULL, NULL, NULL, NULL, &row_height); + gtk_widget_style_get(GTK_WIDGET(view), + "vertical-separator", &vertical_separator, + "expander-size", &expander_size, NULL); + row_height += vertical_separator; + row_height = Platform::Maximum(row_height, expander_size); + return row_height; +#endif +} + // SmallScroller, a GtkScrolledWindow that can shrink very small, as // gtk_widget_set_size_request() cannot shrink widgets on GTK3 typedef struct { @@ -1287,9 +1312,19 @@ G_DEFINE_TYPE(SmallScroller, small_scroller, GTK_TYPE_SCROLLED_WINDOW)
#if GTK_CHECK_VERSION(3,0,0) static void small_scroller_get_preferred_height(GtkWidget *widget, gint *min, gint *nat) { - GTK_WIDGET_CLASS(small_scroller_parent_class)->get_preferred_height(widget, min, nat); - if (*min > 1) - *min = 1; + GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget)); + if (GTK_IS_TREE_VIEW(child)) { + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(child)); + int n_rows = gtk_tree_model_iter_n_children(model, NULL); + int row_height = treeViewGetRowHeight(GTK_TREE_VIEW(child)); + + *min = MAX(1, row_height); + *nat = MAX(*min, n_rows * row_height); + } else { + GTK_WIDGET_CLASS(small_scroller_parent_class)->get_preferred_height(widget, min, nat); + if (*min > 1) + *min = 1; + } } #else static void small_scroller_size_request(GtkWidget *widget, GtkRequisition *req) { @@ -1488,27 +1523,7 @@ int ListBoxX::GetVisibleRows() const {
int ListBoxX::GetRowHeight() { -#if GTK_CHECK_VERSION(3,0,0) - // This version sometimes reports erroneous results on GTK2, but the GTK2 - // version is inaccurate for GTK 3.14. - GdkRectangle rect; - GtkTreePath *path = gtk_tree_path_new_first(); - gtk_tree_view_get_background_area(GTK_TREE_VIEW(list), path, NULL, &rect); - gtk_tree_path_free(path); - return rect.height; -#else - int row_height=0; - int vertical_separator=0; - int expander_size=0; - GtkTreeViewColumn *column = gtk_tree_view_get_column(GTK_TREE_VIEW(list), 0); - gtk_tree_view_column_cell_get_size(column, NULL, NULL, NULL, NULL, &row_height); - gtk_widget_style_get(PWidget(list), - "vertical-separator", &vertical_separator, - "expander-size", &expander_size, NULL); - row_height += vertical_separator; - row_height = Platform::Maximum(row_height, expander_size); - return row_height; -#endif + return treeViewGetRowHeight(GTK_TREE_VIEW(list)); }
PRectangle ListBoxX::GetDesiredRect() {
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).