Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk4.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,18 @@ JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1editable_1get_1delegate)
}
#endif

#ifndef NO_gtk_1editable_1get_1max_1width_1chars
JNIEXPORT jint JNICALL GTK4_NATIVE(gtk_1editable_1get_1max_1width_1chars)
(JNIEnv *env, jclass that, jlong arg0)
{
jint rc = 0;
GTK4_NATIVE_ENTER(env, that, gtk_1editable_1get_1max_1width_1chars_FUNC);
rc = (jint)gtk_editable_get_max_width_chars((GtkEditable *)arg0);
GTK4_NATIVE_EXIT(env, that, gtk_1editable_1get_1max_1width_1chars_FUNC);
return rc;
}
#endif

#ifndef NO_gtk_1editable_1get_1text
JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1editable_1get_1text)
(JNIEnv *env, jclass that, jlong arg0)
Expand All @@ -719,6 +731,16 @@ JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1editable_1get_1text)
}
#endif

#ifndef NO_gtk_1editable_1set_1max_1width_1chars
JNIEXPORT void JNICALL GTK4_NATIVE(gtk_1editable_1set_1max_1width_1chars)
(JNIEnv *env, jclass that, jlong arg0, jint arg1)
{
GTK4_NATIVE_ENTER(env, that, gtk_1editable_1set_1max_1width_1chars_FUNC);
gtk_editable_set_max_width_chars((GtkEditable *)arg0, (int)arg1);
GTK4_NATIVE_EXIT(env, that, gtk_1editable_1set_1max_1width_1chars_FUNC);
}
#endif

#ifndef NO_gtk_1entry_1buffer_1get_1text
JNIEXPORT jlong JNICALL GTK4_NATIVE(gtk_1entry_1buffer_1get_1text)
(JNIEnv *env, jclass that, jlong arg0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ typedef enum {
gtk_1drop_1target_1async_1new_FUNC,
gtk_1drop_1target_1async_1set_1formats_FUNC,
gtk_1editable_1get_1delegate_FUNC,
gtk_1editable_1get_1max_1width_1chars_FUNC,
gtk_1editable_1get_1text_FUNC,
gtk_1editable_1set_1max_1width_1chars_FUNC,
gtk_1entry_1buffer_1get_1text_FUNC,
gtk_1entry_1get_1buffer_FUNC,
gtk_1entry_1get_1text_1length_FUNC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ public class GTK4 {
public static final native long gtk_editable_get_text(long editable);
/** @param editable cast=(GtkEditable *) */
public static final native long gtk_editable_get_delegate(long editable);
/**
* @param editable cast=(GtkEditable *)
*/
public static final native int gtk_editable_get_max_width_chars(long editable);
/**
* @param editable cast=(GtkEditable *)
* @param chars cast=(int)
*/
public static final native void gtk_editable_set_max_width_chars(long editable, int chars);

/* GtkPicture */
public static final native long gtk_picture_new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void createHandle (int index) {
GTK3.gtk_widget_set_has_window(fixedHandle, true);
GTK3.gtk_container_add (fixedHandle, handle);
}
GTK.gtk_editable_set_editable (GTK.GTK4 ? entryHandle : handle, (style & SWT.READ_ONLY) == 0);
GTK.gtk_editable_set_editable (handle, (style & SWT.READ_ONLY) == 0);
GTK.gtk_spin_button_set_wrap (handle, (style & SWT.WRAP) != 0);
imContext = OS.imContextLast();
// In GTK 3 font description is inherited from parent widget which is not how SWT has always worked,
Expand Down Expand Up @@ -586,7 +586,12 @@ public String getText() {
*/
public int getTextLimit () {
checkWidget ();
int limit = GTK.gtk_entry_get_max_length (GTK.GTK4 ? entryHandle : handle);
int limit;
if (GTK.GTK4) {
limit = GTK4.gtk_editable_get_max_width_chars(handle);
} else {
limit = GTK.gtk_entry_get_max_length (handle);
}
return limit == 0 ? LIMIT : limit;
}

Expand Down Expand Up @@ -1160,7 +1165,11 @@ public void setSelection (int value) {
public void setTextLimit (int limit) {
checkWidget ();
if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
GTK.gtk_entry_set_max_length (GTK.GTK4 ? entryHandle : handle, limit);
if(GTK.GTK4) {
GTK4.gtk_editable_set_max_width_chars (handle, limit);
} else {
GTK.gtk_entry_set_max_length (handle, limit);
}
}

/**
Expand Down
Loading