summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorAnatoly Spektor2012-10-15 10:50:57 (EDT)
committer Arun Thondapu2012-10-15 13:38:35 (EDT)
commitb76a3210e5e0d07a0578d9ae225b51140c25db20 (patch)
tree2885905801e06ffb9b66d7e7554a09b1b83df0e7
parent90beec4af69432d76fc877e39fc80aef43f9b1ce (diff)
downloadeclipse.platform.swt-b76a3210e5e0d07a0578d9ae225b51140c25db20.zip
eclipse.platform.swt-b76a3210e5e0d07a0578d9ae225b51140c25db20.tar.gz
eclipse.platform.swt-b76a3210e5e0d07a0578d9ae225b51140c25db20.tar.bz2
Use gtk_cell_renderer_get_preferred_size() for GTK+ 3
This patch replaces gtk_cell_renderer_get_size wth gtk_cell_renderer_get_preferred_size for GTK+ 3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c33
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java10
10 files changed, 75 insertions, 11 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 8d344d8..2bc94db 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -8096,6 +8096,31 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1cell_1layout_1pack_1start)
}
#endif
+#ifndef NO__1gtk_1cell_1renderer_1get_1preferred_1size
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1cell_1renderer_1get_1preferred_1size)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jobject arg2, jobject arg3)
+{
+ GtkRequisition _arg2, *lparg2=NULL;
+ GtkRequisition _arg3, *lparg3=NULL;
+ OS_NATIVE_ENTER(env, that, _1gtk_1cell_1renderer_1get_1preferred_1size_FUNC);
+ if (arg2) if ((lparg2 = getGtkRequisitionFields(env, arg2, &_arg2)) == NULL) goto fail;
+ if (arg3) if ((lparg3 = getGtkRequisitionFields(env, arg3, &_arg3)) == NULL) goto fail;
+/*
+ gtk_cell_renderer_get_preferred_size((GtkCellRenderer *)arg0, (GtkWidget *)arg1, (GtkRequisition *)lparg2, (GtkRequisition *)lparg3);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_cell_renderer_get_preferred_size)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GtkCellRenderer *, GtkWidget *, GtkRequisition *, GtkRequisition *))fp)((GtkCellRenderer *)arg0, (GtkWidget *)arg1, (GtkRequisition *)lparg2, (GtkRequisition *)lparg3);
+ }
+ }
+fail:
+ if (arg3 && lparg3) setGtkRequisitionFields(env, arg3, lparg3);
+ if (arg2 && lparg2) setGtkRequisitionFields(env, arg2, lparg2);
+ OS_NATIVE_EXIT(env, that, _1gtk_1cell_1renderer_1get_1preferred_1size_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1cell_1renderer_1get_1size
JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1cell_1renderer_1get_1size)
(JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jobject arg2, jintArray arg3, jintArray arg4, jintArray arg5, jintArray arg6)
@@ -8111,7 +8136,15 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1cell_1renderer_1get_1size)
if (arg4) if ((lparg4 = (*env)->GetIntArrayElements(env, arg4, NULL)) == NULL) goto fail;
if (arg5) if ((lparg5 = (*env)->GetIntArrayElements(env, arg5, NULL)) == NULL) goto fail;
if (arg6) if ((lparg6 = (*env)->GetIntArrayElements(env, arg6, NULL)) == NULL) goto fail;
+/*
gtk_cell_renderer_get_size((GtkCellRenderer *)arg0, (GtkWidget *)arg1, (GdkRectangle *)lparg2, (gint *)lparg3, (gint *)lparg4, (gint *)lparg5, (gint *)lparg6);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_cell_renderer_get_size)
+ if (fp) {
+ ((void (CALLING_CONVENTION*)(GtkCellRenderer *, GtkWidget *, GdkRectangle *, gint *, gint *, gint *, gint *))fp)((GtkCellRenderer *)arg0, (GtkWidget *)arg1, (GdkRectangle *)lparg2, (gint *)lparg3, (gint *)lparg4, (gint *)lparg5, (gint *)lparg6);
+ }
+ }
fail:
if (arg6 && lparg6) (*env)->ReleaseIntArrayElements(env, arg6, lparg6, 0);
if (arg5 && lparg5) (*env)->ReleaseIntArrayElements(env, arg5, lparg5, 0);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
index 33e91aa..7243201 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
@@ -90,6 +90,8 @@
#define gtk_cell_layout_set_attributes_LIB LIB_GTK
#define gtk_cell_layout_clear_LIB LIB_GTK
#define gtk_cell_layout_pack_start_LIB LIB_GTK
+#define gtk_cell_renderer_get_preferred_size_LIB LIB_GTK
+#define gtk_cell_renderer_get_size_LIB LIB_GTK
#define gtk_combo_box_entry_new_text_LIB LIB_GTK
#define gtk_combo_box_new_text_LIB LIB_GTK
#define gtk_combo_box_insert_text_LIB LIB_GTK
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index 4e78f04..6cc551d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -623,6 +623,7 @@ char * OS_nativeFunctionNames[] = {
"_1gtk_1cell_1layout_1get_1cells",
"_1gtk_1cell_1layout_1pack_1start",
"_1gtk_1cell_1layout_1set_1attributes",
+ "_1gtk_1cell_1renderer_1get_1preferred_1size",
"_1gtk_1cell_1renderer_1get_1size",
"_1gtk_1cell_1renderer_1pixbuf_1new",
"_1gtk_1cell_1renderer_1text_1new",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index c3ede72..a503da0e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -633,6 +633,7 @@ typedef enum {
_1gtk_1cell_1layout_1get_1cells_FUNC,
_1gtk_1cell_1layout_1pack_1start_FUNC,
_1gtk_1cell_1layout_1set_1attributes_FUNC,
+ _1gtk_1cell_1renderer_1get_1preferred_1size_FUNC,
_1gtk_1cell_1renderer_1get_1size_FUNC,
_1gtk_1cell_1renderer_1pixbuf_1new_FUNC,
_1gtk_1cell_1renderer_1text_1new_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 1551cfc..f6539a0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -5992,6 +5992,7 @@ public static final void gtk_cell_layout_pack_start(long /*int*/ cell_layout, lo
}
}
/**
+ * @method flags=dynamic
* @param cell cast=(GtkCellRenderer *)
* @param widget cast=(GtkWidget *)
* @param area cast=(GdkRectangle *),flags=no_in
@@ -6009,6 +6010,22 @@ public static final void gtk_cell_renderer_get_size(long /*int*/ cell, long /*in
lock.unlock();
}
}
+/**
+ * @method flags=dynamic
+ * @param cell cast=(GtkCellRenderer *)
+ * @param widget cast=(GtkWidget *)
+ * @param minimum_size cast=(GtkRequisition *)
+ * @param natural_size cast=(GtkRequisition *)
+ */
+public static final native void _gtk_cell_renderer_get_preferred_size(long /*int*/ cell, long /*int*/ widget, GtkRequisition minimum_size, GtkRequisition natural_size);
+public static final void gtk_cell_renderer_get_preferred_size(long /*int*/ cell, long /*int*/ widget, GtkRequisition minimum_size, GtkRequisition natural_size) {
+ lock.lock();
+ try {
+ _gtk_cell_renderer_get_preferred_size(cell, widget, minimum_size, natural_size);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native long /*int*/ _gtk_cell_renderer_pixbuf_new();
public static final long /*int*/ gtk_cell_renderer_pixbuf_new() {
lock.lock();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
index f078527..a02b2ed 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
@@ -334,7 +334,7 @@ int calculateWidth (long /*int*/ column, long /*int*/ iter) {
while (temp != 0) {
long /*int*/ renderer = OS.g_list_data (temp);
if (renderer != 0) {
- OS.gtk_cell_renderer_get_size (renderer, handle, null, null, null, w, null);
+ gtk_cell_renderer_get_preferred_size (renderer, handle, w, null);
width += w [0];
}
temp = OS.g_list_next (temp);
@@ -2590,7 +2590,7 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /*
//send out measure before erase
long /*int*/ textRenderer = getTextRenderer (columnHandle);
- if (textRenderer != 0) OS.gtk_cell_renderer_get_size (textRenderer, handle, null, null, null, null, null);
+ if (textRenderer != 0) gtk_cell_renderer_get_preferred_size (textRenderer, handle, null, null);
if (hooks (SWT.EraseItem)) {
@@ -2664,8 +2664,8 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /*
OS.gtk_tree_view_get_background_area (handle, path, columnHandle, rect);
OS.gtk_tree_path_free (path);
ignoreSize = true;
- int [] contentX = new int [1], contentWidth = new int [1];
- OS.gtk_cell_renderer_get_size (cell, handle, null, null, null, contentWidth, null);
+ int [] contentX = new int [1], contentWidth = new int [1];
+ gtk_cell_renderer_get_preferred_size (cell, handle, contentWidth, null);
OS.gtk_tree_view_column_cell_get_position (columnHandle, cell, contentX, null);
ignoreSize = false;
Image image = item.getImage (columnIndex);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
index 618367b..510138d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
@@ -300,7 +300,7 @@ public Rectangle getBounds () {
int [] x = new int [1], w = new int [1];
parent.ignoreSize = true;
- OS.gtk_cell_renderer_get_size (textRenderer, parentHandle, null, null, null, w, null);
+ gtk_cell_renderer_get_preferred_size (textRenderer, parentHandle, w, null);
parent.ignoreSize = false;
rect.width = w [0];
int [] buffer = new int [1];
@@ -678,7 +678,7 @@ public Rectangle getTextBounds (int index) {
int [] x = new int [1], w = new int [1];
parent.ignoreSize = true;
- OS.gtk_cell_renderer_get_size (textRenderer, parentHandle, null, null, null, w, null);
+ gtk_cell_renderer_get_preferred_size (textRenderer, parentHandle, w, null);
parent.ignoreSize = false;
int [] buffer = new int [1];
if (OS.gtk_tree_view_get_expander_column (parentHandle) == column) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index b873d6f..ef6005a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
@@ -421,7 +421,7 @@ int calculateWidth (long /*int*/ column, long /*int*/ iter, boolean recurse) {
while (temp != 0) {
long /*int*/ renderer = OS.g_list_data (temp);
if (renderer != 0) {
- OS.gtk_cell_renderer_get_size (renderer, handle, null, null, null, w, null);
+ gtk_cell_renderer_get_preferred_size (renderer, handle, w, null);
width += w [0];
}
temp = OS.g_list_next (temp);
@@ -2581,7 +2581,7 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /*
//send out measure before erase
long /*int*/ textRenderer = getTextRenderer (columnHandle);
- if (textRenderer != 0) OS.gtk_cell_renderer_get_size (textRenderer, handle, null, null, null, null, null);
+ if (textRenderer != 0) gtk_cell_renderer_get_preferred_size (textRenderer, handle, null, null);
if (hooks (SWT.EraseItem)) {
boolean wasSelected = (drawState & SWT.SELECTED) != 0;
@@ -2666,7 +2666,7 @@ long /*int*/ rendererRenderProc (long /*int*/ cell, long /*int*/ window, long /*
}
ignoreSize = true;
int [] contentX = new int [1], contentWidth = new int [1];
- OS.gtk_cell_renderer_get_size (cell, handle, null, null, null, contentWidth, null);
+ gtk_cell_renderer_get_preferred_size (cell, handle, contentWidth, null);
OS.gtk_tree_view_column_cell_get_position (columnHandle, cell, contentX, null);
ignoreSize = false;
Image image = item.getImage (columnIndex);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
index 4efb9a6..4c88cbf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
@@ -515,7 +515,7 @@ public Rectangle getBounds () {
int [] x = new int [1], w = new int [1];
parent.ignoreSize = true;
- OS.gtk_cell_renderer_get_size (textRenderer, parentHandle, null, null, null, w, null);
+ gtk_cell_renderer_get_preferred_size (textRenderer, parentHandle, w, null);
parent.ignoreSize = false;
rect.width = w [0];
int [] buffer = new int [1];
@@ -972,7 +972,7 @@ public Rectangle getTextBounds (int index) {
int [] x = new int [1], w = new int [1];
parent.ignoreSize = true;
- OS.gtk_cell_renderer_get_size (textRenderer, parentHandle, null, null, null, w, null);
+ gtk_cell_renderer_get_preferred_size (textRenderer, parentHandle, w, null);
parent.ignoreSize = false;
int [] buffer = new int [1];
if (OS.GTK_VERSION < OS.VERSION (2, 8, 18) && OS.gtk_tree_view_get_expander_column (parentHandle) == column) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index e03d966..0d8f47d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
@@ -2043,4 +2043,14 @@ void gtk_render_frame (long /*int*/ style, long /*int*/ window, int state_type,
}
}
+void gtk_cell_renderer_get_preferred_size (long /*int*/ cell, long /*int*/ widget, int[] width, int[] height) {
+ if (OS.GTK_VERSION >= OS.VERSION (3, 0, 0)) {
+ GtkRequisition minimum_size = new GtkRequisition ();
+ OS.gtk_cell_renderer_get_preferred_size (cell, widget, minimum_size, null);
+ if (width != null) width [0] = minimum_size.width;
+ if (height != null) height[0] = minimum_size.height;
+ } else {
+ OS.gtk_cell_renderer_get_size (cell, widget, null, null, null, width, height);
+ }
+}
}