Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties39
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c94
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java72
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java137
6 files changed, 327 insertions, 39 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
index e1c59eae0f..5933299349 100644
--- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
+++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/org.eclipse.swt.internal.gtk.OS.properties
@@ -573,6 +573,9 @@ OS__GTK_WIDGET_SET_FLAGS=
OS__GTK_WIDGET_SET_FLAGS_0=
OS__GTK_WIDGET_SET_FLAGS_1=
+OS__GTK_WIDGET_STATE=
+OS__GTK_WIDGET_STATE_0=
+
OS__GTK_WIDGET_UNSET_FLAGS=
OS__GTK_WIDGET_UNSET_FLAGS_0=
OS__GTK_WIDGET_UNSET_FLAGS_1=
@@ -2306,22 +2309,43 @@ OS__gtk_label_set_line_wrap=
OS__gtk_label_set_line_wrap_0=cast=(GtkLabel *)
OS__gtk_label_set_line_wrap_1=cast=(gboolean)
-OS__gtk_label_set_text=
-OS__gtk_label_set_text_0=cast=(GtkLabel *)
-OS__gtk_label_set_text_1=cast=(const gchar *)
+OS__1gtk_1label_1set_1text__II=
+OS__1gtk_1label_1set_1text__II_0=cast=(GtkLabel *)
+OS__1gtk_1label_1set_1text__II_1=cast=(const gchar *)
+
+OS__1gtk_1label_1set_1text__I_3B=
+OS__1gtk_1label_1set_1text__I_3B_0=cast=(GtkLabel *)
+OS__1gtk_1label_1set_1text__I_3B_1=cast=(const gchar *)
OS__gtk_label_set_text_with_mnemonic=
OS__gtk_label_set_text_with_mnemonic_0=cast=(GtkLabel *)
OS__gtk_label_set_text_with_mnemonic_1=cast=(const gchar *)
+OS__gtk_list_append_items=
+OS__gtk_list_append_items_0=cast=(GtkList *)
+OS__gtk_list_append_items_1=cast=(GList *)
+
OS__gtk_list_clear_items=
-OS__gtk_list_clear_items_0=cast=GtkList *
+OS__gtk_list_clear_items_0=cast=(GtkList *)
OS__gtk_list_clear_items_1=
OS__gtk_list_clear_items_2=
+OS__gtk_list_insert_items=
+OS__gtk_list_insert_items_0=cast=(GtkList *)
+OS__gtk_list_insert_items_1=cast=(GList *)
+OS__gtk_list_insert_items_2=
+
OS__gtk_list_item_new_with_label=
OS__gtk_list_item_new_with_label_0=
+OS__gtk_list_remove_items=
+OS__gtk_list_remove_items_0=cast=(GtkList *)
+OS__gtk_list_remove_items_1=cast=(GList *)
+
+OS__gtk_list_select_item=
+OS__gtk_list_select_item_0=cast=(GtkList *)
+OS__gtk_list_select_item_1=
+
OS__gtk_list_store_append=
OS__gtk_list_store_append_0=cast=(GtkListStore *)
OS__gtk_list_store_append_1=cast=(GtkTreeIter *)
@@ -2377,6 +2401,13 @@ OS__1gtk_1list_1store_1set__III_3BI_2=
OS__1gtk_1list_1store_1set__III_3BI_3=
OS__1gtk_1list_1store_1set__III_3BI_4=
+OS__gtk_list_unselect_all=
+OS__gtk_list_unselect_all_0=cast=(GtkList *)
+
+OS__gtk_list_unselect_item=
+OS__gtk_list_unselect_item_0=cast=(GtkList *)
+OS__gtk_list_unselect_item_1=
+
OS__gtk_main=
OS__gtk_main_do_event=
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 fb46c0e741..7b8b59b435 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
@@ -999,6 +999,18 @@ JNIEXPORT void JNICALL OS_NATIVE(_1GTK_1WIDGET_1SET_1FLAGS)
}
#endif
+#ifndef NO__1GTK_1WIDGET_1STATE
+JNIEXPORT jint JNICALL OS_NATIVE(_1GTK_1WIDGET_1STATE)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1GTK_1WIDGET_1STATE_FUNC);
+ rc = (jint)GTK_WIDGET_STATE(arg0);
+ OS_NATIVE_EXIT(env, that, _1GTK_1WIDGET_1STATE_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1GTK_1WIDGET_1UNSET_1FLAGS
JNIEXPORT void JNICALL OS_NATIVE(_1GTK_1WIDGET_1UNSET_1FLAGS)
(JNIEnv *env, jclass that, jint arg0, jint arg1)
@@ -6566,13 +6578,27 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1label_1set_1line_1wrap)
}
#endif
-#ifndef NO__1gtk_1label_1set_1text
-JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1label_1set_1text)
+#ifndef NO__1gtk_1label_1set_1text__II
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1label_1set_1text__II)
(JNIEnv *env, jclass that, jint arg0, jint arg1)
{
- OS_NATIVE_ENTER(env, that, _1gtk_1label_1set_1text_FUNC);
+ OS_NATIVE_ENTER(env, that, _1gtk_1label_1set_1text__II_FUNC);
gtk_label_set_text((GtkLabel *)arg0, (const gchar *)arg1);
- OS_NATIVE_EXIT(env, that, _1gtk_1label_1set_1text_FUNC);
+ OS_NATIVE_EXIT(env, that, _1gtk_1label_1set_1text__II_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1label_1set_1text__I_3B
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1label_1set_1text__I_3B)
+ (JNIEnv *env, jclass that, jint arg0, jbyteArray arg1)
+{
+ jbyte *lparg1=NULL;
+ OS_NATIVE_ENTER(env, that, _1gtk_1label_1set_1text__I_3B_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ gtk_label_set_text((GtkLabel *)arg0, (const gchar *)lparg1);
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1gtk_1label_1set_1text__I_3B_FUNC);
}
#endif
@@ -6590,6 +6616,16 @@ fail:
}
#endif
+#ifndef NO__1gtk_1list_1append_1items
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1append_1items)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ OS_NATIVE_ENTER(env, that, _1gtk_1list_1append_1items_FUNC);
+ gtk_list_append_items((GtkList *)arg0, (GList *)arg1);
+ OS_NATIVE_EXIT(env, that, _1gtk_1list_1append_1items_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1list_1clear_1items
JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1clear_1items)
(JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
@@ -6600,6 +6636,16 @@ JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1clear_1items)
}
#endif
+#ifndef NO__1gtk_1list_1insert_1items
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1insert_1items)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1, jint arg2)
+{
+ OS_NATIVE_ENTER(env, that, _1gtk_1list_1insert_1items_FUNC);
+ gtk_list_insert_items((GtkList *)arg0, (GList *)arg1, arg2);
+ OS_NATIVE_EXIT(env, that, _1gtk_1list_1insert_1items_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1list_1item_1new_1with_1label
JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1list_1item_1new_1with_1label)
(JNIEnv *env, jclass that, jbyteArray arg0)
@@ -6616,6 +6662,26 @@ fail:
}
#endif
+#ifndef NO__1gtk_1list_1remove_1items
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1remove_1items)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ OS_NATIVE_ENTER(env, that, _1gtk_1list_1remove_1items_FUNC);
+ gtk_list_remove_items((GtkList *)arg0, (GList *)arg1);
+ OS_NATIVE_EXIT(env, that, _1gtk_1list_1remove_1items_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1select_1item
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1select_1item)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ OS_NATIVE_ENTER(env, that, _1gtk_1list_1select_1item_FUNC);
+ gtk_list_select_item((GtkList *)arg0, arg1);
+ OS_NATIVE_EXIT(env, that, _1gtk_1list_1select_1item_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1list_1store_1append
JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1store_1append)
(JNIEnv *env, jclass that, jint arg0, jint arg1)
@@ -6730,6 +6796,26 @@ fail:
}
#endif
+#ifndef NO__1gtk_1list_1unselect_1all
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1unselect_1all)
+ (JNIEnv *env, jclass that, jint arg0)
+{
+ OS_NATIVE_ENTER(env, that, _1gtk_1list_1unselect_1all_FUNC);
+ gtk_list_unselect_all((GtkList *)arg0);
+ OS_NATIVE_EXIT(env, that, _1gtk_1list_1unselect_1all_FUNC);
+}
+#endif
+
+#ifndef NO__1gtk_1list_1unselect_1item
+JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1list_1unselect_1item)
+ (JNIEnv *env, jclass that, jint arg0, jint arg1)
+{
+ OS_NATIVE_ENTER(env, that, _1gtk_1list_1unselect_1item_FUNC);
+ gtk_list_unselect_item((GtkList *)arg0, arg1);
+ OS_NATIVE_EXIT(env, that, _1gtk_1list_1unselect_1item_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1main
JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1main)
(JNIEnv *env, jclass that)
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 3ec7068a5f..3f94793fb8 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
@@ -18,8 +18,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 937;
-int OS_nativeFunctionCallCount[937];
+int OS_nativeFunctionCount = 945;
+int OS_nativeFunctionCallCount[945];
char * OS_nativeFunctionNames[] = {
"Call",
"GDK_1WINDOWING_1X11",
@@ -104,6 +104,7 @@ char * OS_nativeFunctionNames[] = {
"_1GTK_1WIDGET_1MAPPED",
"_1GTK_1WIDGET_1SENSITIVE",
"_1GTK_1WIDGET_1SET_1FLAGS",
+ "_1GTK_1WIDGET_1STATE",
"_1GTK_1WIDGET_1UNSET_1FLAGS",
"_1GTK_1WIDGET_1VISIBLE",
"_1G_1OBJECT_1CLASS",
@@ -511,10 +512,15 @@ char * OS_nativeFunctionNames[] = {
"_1gtk_1label_1set_1attributes",
"_1gtk_1label_1set_1justify",
"_1gtk_1label_1set_1line_1wrap",
- "_1gtk_1label_1set_1text",
+ "_1gtk_1label_1set_1text__II",
+ "_1gtk_1label_1set_1text__I_3B",
"_1gtk_1label_1set_1text_1with_1mnemonic",
+ "_1gtk_1list_1append_1items",
"_1gtk_1list_1clear_1items",
+ "_1gtk_1list_1insert_1items",
"_1gtk_1list_1item_1new_1with_1label",
+ "_1gtk_1list_1remove_1items",
+ "_1gtk_1list_1select_1item",
"_1gtk_1list_1store_1append",
"_1gtk_1list_1store_1clear",
"_1gtk_1list_1store_1insert",
@@ -525,6 +531,8 @@ char * OS_nativeFunctionNames[] = {
"_1gtk_1list_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I",
"_1gtk_1list_1store_1set__IIIZI",
"_1gtk_1list_1store_1set__III_3BI",
+ "_1gtk_1list_1unselect_1all",
+ "_1gtk_1list_1unselect_1item",
"_1gtk_1main",
"_1gtk_1main_1do_1event",
"_1gtk_1main_1iteration",
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 053283d2d2..26b29917b2 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
@@ -108,6 +108,7 @@ typedef enum {
_1GTK_1WIDGET_1MAPPED_FUNC,
_1GTK_1WIDGET_1SENSITIVE_FUNC,
_1GTK_1WIDGET_1SET_1FLAGS_FUNC,
+ _1GTK_1WIDGET_1STATE_FUNC,
_1GTK_1WIDGET_1UNSET_1FLAGS_FUNC,
_1GTK_1WIDGET_1VISIBLE_FUNC,
_1G_1OBJECT_1CLASS_FUNC,
@@ -515,10 +516,15 @@ typedef enum {
_1gtk_1label_1set_1attributes_FUNC,
_1gtk_1label_1set_1justify_FUNC,
_1gtk_1label_1set_1line_1wrap_FUNC,
- _1gtk_1label_1set_1text_FUNC,
+ _1gtk_1label_1set_1text__II_FUNC,
+ _1gtk_1label_1set_1text__I_3B_FUNC,
_1gtk_1label_1set_1text_1with_1mnemonic_FUNC,
+ _1gtk_1list_1append_1items_FUNC,
_1gtk_1list_1clear_1items_FUNC,
+ _1gtk_1list_1insert_1items_FUNC,
_1gtk_1list_1item_1new_1with_1label_FUNC,
+ _1gtk_1list_1remove_1items_FUNC,
+ _1gtk_1list_1select_1item_FUNC,
_1gtk_1list_1store_1append_FUNC,
_1gtk_1list_1store_1clear_FUNC,
_1gtk_1list_1store_1insert_FUNC,
@@ -529,6 +535,8 @@ typedef enum {
_1gtk_1list_1store_1set__IIILorg_eclipse_swt_internal_gtk_GdkColor_2I_FUNC,
_1gtk_1list_1store_1set__IIIZI_FUNC,
_1gtk_1list_1store_1set__III_3BI_FUNC,
+ _1gtk_1list_1unselect_1all_FUNC,
+ _1gtk_1list_1unselect_1item_FUNC,
_1gtk_1main_FUNC,
_1gtk_1main_1do_1event_FUNC,
_1gtk_1main_1iteration_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 e518765107..0fddb6bd6a 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
@@ -879,6 +879,15 @@ public static final int GTK_WIDGET_FLAGS(int /*long*/ wid) {
lock.unlock();
}
}
+public static final native int _GTK_WIDGET_STATE(int /*long*/ wid);
+public static final int GTK_WIDGET_STATE(int /*long*/ wid) {
+ lock.lock();
+ try {
+ return _GTK_WIDGET_STATE(wid);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native boolean _GTK_WIDGET_HAS_DEFAULT(int /*long*/ wid);
public static final boolean GTK_WIDGET_HAS_DEFAULT(int /*long*/ wid) {
lock.lock();
@@ -4363,6 +4372,15 @@ public static final void gtk_label_set_text(int /*long*/ label, int /*long*/ str
lock.unlock();
}
}
+public static final native void _gtk_label_set_text(int /*long*/ label, byte[] str);
+public static final void gtk_label_set_text(int /*long*/ label, byte[] str) {
+ lock.lock();
+ try {
+ _gtk_label_set_text(label, str);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native void _gtk_label_set_text_with_mnemonic(int /*long*/ label, byte[] str);
public static final void gtk_label_set_text_with_mnemonic(int /*long*/ label, byte[] str) {
lock.lock();
@@ -4372,6 +4390,15 @@ public static final void gtk_label_set_text_with_mnemonic(int /*long*/ label, by
lock.unlock();
}
}
+public static final native void _gtk_list_append_items(int /*long*/ list, int /*long*/ items);
+public static final void gtk_list_append_items(int /*long*/ list, int /*long*/ items) {
+ lock.lock();
+ try {
+ _gtk_list_append_items(list, items);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native void _gtk_list_clear_items(int /*long*/ list, int start, int end);
public static final void gtk_list_clear_items(int /*long*/ list, int start, int end) {
lock.lock();
@@ -4381,6 +4408,15 @@ public static final void gtk_list_clear_items(int /*long*/ list, int start, int
lock.unlock();
}
}
+public static final native void _gtk_list_insert_items(int /*long*/ list, int /*long*/ items, int position);
+public static final void gtk_list_insert_items(int /*long*/ list, int /*long*/ items, int position) {
+ lock.lock();
+ try {
+ _gtk_list_insert_items(list, items, position);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native int /*long*/ _gtk_list_item_new_with_label(byte[] label);
public static final int /*long*/ gtk_list_item_new_with_label(byte[] label) {
lock.lock();
@@ -4390,6 +4426,42 @@ public static final int /*long*/ gtk_list_item_new_with_label(byte[] label) {
lock.unlock();
}
}
+public static final native void _gtk_list_remove_items(int /*long*/ list, int /*long*/ items);
+public static final void gtk_list_remove_items(int /*long*/ list, int /*long*/ items) {
+ lock.lock();
+ try {
+ _gtk_list_remove_items(list, items);
+ } finally {
+ lock.unlock();
+ }
+}
+public static final native void _gtk_list_select_item(int /*long*/ list, int item);
+public static final void gtk_list_select_item(int /*long*/ list, int item) {
+ lock.lock();
+ try {
+ _gtk_list_select_item(list, item);
+ } finally {
+ lock.unlock();
+ }
+}
+public static final native void _gtk_list_unselect_all(int /*long*/ list);
+public static final void gtk_list_unselect_all(int /*long*/ list) {
+ lock.lock();
+ try {
+ _gtk_list_unselect_all(list);
+ } finally {
+ lock.unlock();
+ }
+}
+public static final native void _gtk_list_unselect_item(int /*long*/ list, int item);
+public static final void gtk_list_unselect_item(int /*long*/ list, int item) {
+ lock.lock();
+ try {
+ _gtk_list_unselect_item(list, item);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native void _gtk_list_store_append(int /*long*/ list_store, int /*long*/ iter);
public static final void gtk_list_store_append(int /*long*/ list_store, int /*long*/ iter) {
lock.lock();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index a60cc4cd82..76b4fafc89 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -57,7 +57,7 @@ public class Combo extends Composite {
int /*long*/ arrowHandle, entryHandle, listHandle;
int lastEventTime, visibleCount = 5;
String [] items = new String [0];
- boolean ignoreSelect;
+ boolean ignoreSelect, lockText;
static final int INNER_BORDER = 2;
@@ -131,10 +131,7 @@ public Combo (Composite parent, int style) {
public void add (String string) {
checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- String [] newItems = new String [items.length + 1];
- System.arraycopy (items, 0, newItems, 0, items.length);
- newItems [items.length] = string;
- setItems (newItems, true, true);
+ add(string, items.length);
}
/**
@@ -173,7 +170,23 @@ public void add (String string, int index) {
System.arraycopy (items, 0, newItems, 0, index);
newItems [index] = string;
System.arraycopy (items, index, newItems, index + 1, items.length - index);
- setItems (newItems, true, true);
+ items = newItems;
+ /*
+ * Feature in GTK. When the list is empty and the first item
+ * is added, the combo box selects that item replacing the
+ * text in the entry field. The fix is to avoid this by
+ * stopping the "delete" and "insert_text" signal emission.
+ */
+ ignoreSelect = lockText = true;
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int /*long*/ item = OS.gtk_list_item_new_with_label (buffer);
+ int /*long*/ label = OS.gtk_bin_get_child (item);
+ OS.gtk_widget_modify_fg (label, OS.GTK_STATE_NORMAL, getForegroundColor ());
+ OS.gtk_widget_modify_font (label, getFontDescription ());
+ OS.gtk_widget_show (item);
+ int /*long*/ items = OS.g_list_append (0, item);
+ OS.gtk_list_insert_items (listHandle, items, index);
+ ignoreSelect = lockText = false;
}
/**
@@ -543,8 +556,15 @@ int /*long*/ imContext () {
*/
public void deselect (int index) {
checkWidget();
- boolean isSelected = getSelectionIndex () == index;
- setItems (items, !isSelected, !isSelected);
+ if (index < 0 || index >= items.length) return;
+ ignoreSelect = true;
+ int /*long*/ children = OS.gtk_container_get_children (listHandle);
+ int /*long*/ item = OS.g_list_nth_data (children, index);
+ boolean selected = OS.GTK_WIDGET_STATE (item) == OS.GTK_STATE_SELECTED;
+ OS.gtk_list_unselect_all (listHandle);
+ if (selected) OS.gtk_entry_set_text (entryHandle, new byte[1]);
+ OS.g_list_free (children);
+ ignoreSelect = false;
}
/**
@@ -563,7 +583,10 @@ public void deselect (int index) {
*/
public void deselectAll () {
checkWidget();
- setItems (items, false, false);
+ ignoreSelect = true;
+ OS.gtk_list_unselect_all (listHandle);
+ OS.gtk_entry_set_text (entryHandle, new byte[1]);
+ ignoreSelect = false;
}
GdkColor getBackgroundColor () {
@@ -716,8 +739,20 @@ public Point getSelection () {
*/
public int getSelectionIndex () {
checkWidget();
- //NOT RIGHT FOR EDITABLE
- return indexOf (getText ());
+ int index = 0, result = -1;
+ int /*long*/ children = OS.gtk_container_get_children (listHandle);
+ int /*long*/ temp = children;
+ while (temp != 0) {
+ int /*long*/ item = OS.g_list_data (temp);
+ if (OS.GTK_WIDGET_STATE (item) == OS.GTK_STATE_SELECTED) {
+ result = index;
+ break;
+ }
+ index++;
+ temp = OS.g_list_next (temp);
+ }
+ OS.g_list_free (children);
+ return result;
}
/**
@@ -853,6 +888,11 @@ int /*long*/ gtk_commit (int /*long*/ imContext, int /*long*/ text) {
}
int /*long*/ gtk_delete_text (int /*long*/ widget, int /*long*/ start_pos, int /*long*/ end_pos) {
+ if (lockText) {
+ OS.gtk_list_unselect_item (listHandle, 0);
+ OS.g_signal_stop_emission_by_name (entryHandle, OS.delete_text);
+ return 0;
+ }
if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0;
String newText = verifyText ("", (int)/*64*/start_pos, (int)/*64*/end_pos);
if (newText == null) {
@@ -874,6 +914,11 @@ int /*long*/ gtk_delete_text (int /*long*/ widget, int /*long*/ start_pos, int /
}
int /*long*/ gtk_insert_text (int /*long*/ widget, int /*long*/ new_text, int /*long*/ new_text_length, int /*long*/ position) {
+ if (lockText) {
+ OS.gtk_list_unselect_item (listHandle, 0);
+ OS.g_signal_stop_emission_by_name (entryHandle, OS.insert_text);
+ return 0;
+ }
if (!hooks (SWT.Verify) && !filters (SWT.Verify)) return 0;
if (new_text == 0 || new_text_length == 0) return 0;
byte [] buffer = new byte [(int)/*64*/new_text_length];
@@ -1021,7 +1066,19 @@ public void remove (int index) {
String [] newItems = new String [oldItems.length - 1];
System.arraycopy (oldItems, 0, newItems, 0, index);
System.arraycopy (oldItems, index + 1, newItems, index, oldItems.length - index - 1);
- setItems (newItems, true, true);
+ items = newItems;
+ ignoreSelect = true;
+ int /*long*/ children = OS.gtk_container_get_children (listHandle);
+ int /*long*/ item = OS.g_list_nth_data (children, index);
+ boolean selected = OS.GTK_WIDGET_STATE (item) == OS.GTK_STATE_SELECTED;
+ int /*long*/ items = OS.g_list_append (0, item);
+ OS.gtk_list_remove_items(listHandle, items);
+ OS.g_list_free(items);
+ OS.g_list_free(children);
+ if (selected) {
+ OS.gtk_entry_set_text (entryHandle, new byte[1]);
+ }
+ ignoreSelect = false;
}
/**
@@ -1053,7 +1110,23 @@ public void remove (int start, int end) {
String [] newItems = new String [oldItems.length - (end - start + 1)];
System.arraycopy (oldItems, 0, newItems, 0, start);
System.arraycopy (oldItems, end + 1, newItems, start, oldItems.length - end - 1);
- setItems (newItems, true, true);
+ items = newItems;
+ boolean selected = false;
+ ignoreSelect = true;
+ int /*long*/ items = 0;
+ int /*long*/ children = OS.gtk_container_get_children (listHandle);
+ for (int i = start; i <= end; i++) {
+ int /*long*/ item = OS.g_list_nth_data (children, i);
+ selected |= OS.GTK_WIDGET_STATE (item) == OS.GTK_STATE_SELECTED;
+ items = OS.g_list_append (items, item);
+ }
+ OS.gtk_list_remove_items(listHandle, items);
+ OS.g_list_free(items);
+ OS.g_list_free(children);
+ if (selected) {
+ OS.gtk_entry_set_text (entryHandle, new byte[1]);
+ }
+ ignoreSelect = false;
}
/**
@@ -1093,7 +1166,11 @@ public void remove (String string) {
*/
public void removeAll () {
checkWidget();
- setItems (new String [0], false, false);
+ ignoreSelect = true;
+ OS.gtk_list_clear_items (listHandle, 0, -1);
+ OS.gtk_entry_set_text (entryHandle, new byte[1]);
+ items = new String[0];
+ ignoreSelect = false;
}
/**
@@ -1186,7 +1263,9 @@ public void removeVerifyListener (VerifyListener listener) {
public void select (int index) {
checkWidget();
if (index < 0 || index >= items.length) return;
- setText (items [index]);
+ ignoreSelect = true;
+ OS.gtk_list_select_item (listHandle, index);
+ ignoreSelect = false;
}
void setBackgroundColor (GdkColor color) {
@@ -1263,7 +1342,14 @@ public void setItem (int index, String string) {
error (SWT.ERROR_INVALID_ARGUMENT);
}
items [index] = string;
- setItems (items, true, true);
+ ignoreSelect = true;
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int /*long*/ children = OS.gtk_container_get_children (listHandle);
+ int /*long*/ item = OS.g_list_nth_data (children, index);
+ int /*long*/ label = OS.gtk_bin_get_child (item);
+ OS.gtk_label_set_text (label, buffer);
+ OS.g_list_free (children);
+ ignoreSelect = false;
}
/**
@@ -1285,18 +1371,12 @@ public void setItem (int index, String string) {
public void setItems (String [] items) {
checkWidget();
if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
- setItems (items, false, false);
-}
-
-void setItems (String [] items, boolean keepText, boolean keepSelection) {
- this.items = items;
- String text = keepText ? getText() : "";
- int selectedIndex = keepSelection ? getSelectionIndex() : -1;
- ignoreSelect = true;
+ lockText = ignoreSelect = true;
OS.gtk_list_clear_items (listHandle, 0, -1);
int /*long*/ font = getFontDescription ();
GdkColor color = getForegroundColor ();
- for (int i=0; i<items.length; i++) {
+ int i = 0;
+ while (i < items.length) {
String string = items [i];
if (string == null) break;
byte [] buffer = Converter.wcsToMbcs (null, string, true);
@@ -1306,9 +1386,12 @@ void setItems (String [] items, boolean keepText, boolean keepSelection) {
OS.gtk_widget_modify_font (label, font);
OS.gtk_container_add (listHandle, item);
OS.gtk_widget_show (item);
+ i++;
}
- OS.gtk_entry_set_text (entryHandle, Converter.wcsToMbcs (null, selectedIndex != -1 ? items [selectedIndex] : text, true));
- ignoreSelect = false;
+ this.items = new String [items.length];
+ System.arraycopy (items, 0, this.items, 0, i);
+ lockText = ignoreSelect = false;
+ OS.gtk_entry_set_text (entryHandle, new byte[0]);
}
/**

Back to the top