Skip to content

Commit 222e953

Browse files
committed
[Gtk3] Resize Tree columns on setImage
Fixes #1739
1 parent 81a811a commit 222e953

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8536,6 +8536,16 @@ JNIEXPORT void JNICALL GTK_NATIVE(gtk_1tree_1view_1column_1set_1widget)
85368536
}
85378537
#endif
85388538

8539+
#ifndef NO_gtk_1tree_1view_1columns_1autosize
8540+
JNIEXPORT void JNICALL GTK_NATIVE(gtk_1tree_1view_1columns_1autosize)
8541+
(JNIEnv *env, jclass that, jlong arg0)
8542+
{
8543+
GTK_NATIVE_ENTER(env, that, gtk_1tree_1view_1columns_1autosize_FUNC);
8544+
gtk_tree_view_columns_autosize((GtkTreeView *)arg0);
8545+
GTK_NATIVE_EXIT(env, that, gtk_1tree_1view_1columns_1autosize_FUNC);
8546+
}
8547+
#endif
8548+
85398549
#ifndef NO_gtk_1tree_1view_1convert_1bin_1window_1to_1tree_1coords
85408550
JNIEXPORT void JNICALL GTK_NATIVE(gtk_1tree_1view_1convert_1bin_1window_1to_1tree_1coords)
85418551
(JNIEnv *env, jclass that, jlong arg0, jint arg1, jint arg2, jintArray arg3, jintArray arg4)

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ typedef enum {
685685
gtk_1tree_1view_1column_1set_1sort_1order_FUNC,
686686
gtk_1tree_1view_1column_1set_1visible_FUNC,
687687
gtk_1tree_1view_1column_1set_1widget_FUNC,
688+
gtk_1tree_1view_1columns_1autosize_FUNC,
688689
gtk_1tree_1view_1convert_1bin_1window_1to_1tree_1coords_FUNC,
689690
gtk_1tree_1view_1convert_1bin_1window_1to_1widget_1coords_FUNC,
690691
gtk_1tree_1view_1create_1row_1drag_1icon_FUNC,

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,8 @@ public class GTK extends OS {
21302130
public static final native void gtk_tree_view_move_column_after(long tree_view, long column, long base_column);
21312131
/** @param model cast=(GtkTreeModel *) */
21322132
public static final native long gtk_tree_view_new_with_model(long model);
2133+
/** @param tree_view cast=(GtkTreeView *) */
2134+
public static final native void gtk_tree_view_columns_autosize(long tree_view);
21332135
/**
21342136
* @param tree_view cast=(GtkTreeView *)
21352137
* @param column cast=(GtkTreeViewColumn *)

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,13 +1522,11 @@ public void setImage(int index, Image image) {
15221522
* bug 480261.
15231523
*
15241524
* Toggle the fixed-height-mode GObject property
1525-
* off and back on. This resets GTK's cached row height
1526-
* (fixed_height = -1) and schedules an async widget resize,
1527-
* so GTK will re-measure on the next layout pass and pick
1528-
* up the updated renderer size.
1525+
* off, autoresize columns and back on.
15291526
*/
15301527
if ((parent.style & SWT.VIRTUAL) != 0) {
15311528
OS.g_object_set(parent.handle, OS.fixed_height_mode, false, 0);
1529+
GTK.gtk_tree_view_columns_autosize(parent.handle);
15321530
OS.g_object_set(parent.handle, OS.fixed_height_mode, true, 0);
15331531
}
15341532
}

0 commit comments

Comments
 (0)