summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets
diff options
context:
space:
mode:
authorBogdan Gheorghe <gheorghe@ca.ibm.com>2012-01-18 14:38:30 -0500
committerBogdan Gheorghe <gheorghe@ca.ibm.com>2012-01-18 14:38:30 -0500
commit7a90781a0b4efe2d1023e9b9e3985d7144df555d (patch)
tree365704170b742df3d564d27be5c13bdc425531ae /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets
parent775f7cfbc59632723c3d9a6faa1c78275b5107ae (diff)
parent769e2f86b4a658a863e62444f6c5f651ce456752 (diff)
downloadeclipse.platform.swt-7a90781a0b4efe2d1023e9b9e3985d7144df555d.tar.gz
eclipse.platform.swt-7a90781a0b4efe2d1023e9b9e3985d7144df555d.tar.xz
eclipse.platform.swt-7a90781a0b4efe2d1023e9b9e3985d7144df555d.zip
Merge master into Bug354978
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java760
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java103
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java174
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java67
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java61
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java5
19 files changed, 434 insertions, 861 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
index 862ed982d0..33681fb533 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
@@ -503,7 +503,7 @@ int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
int /*long*/ result = super.gtk_focus_out_event (widget, event);
// widget could be disposed at this point
if (handle == 0) return 0;
- if ((style & SWT.PUSH) != 0 && !OS.GTK_WIDGET_HAS_DEFAULT (handle)) {
+ if ((style & SWT.PUSH) != 0) {
Decorations menuShell = menuShell ();
if (menuShell.defaultButton == this) {
menuShell.defaultButton = null;
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 3582fac77e..c4b4978bd1 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,12 +57,12 @@ import org.eclipse.swt.events.*;
* @noextend This class is not intended to be subclassed by clients.
*/
public class Combo extends Composite {
- int /*long*/ buttonHandle, entryHandle, listHandle, textRenderer, cellHandle, popupHandle, menuHandle;
+ int /*long*/ buttonHandle, entryHandle, textRenderer, cellHandle, popupHandle, menuHandle;
int lastEventTime, visibleCount = 10;
int /*long*/ gdkEventKey = 0;
int fixStart = -1, fixEnd = -1;
String [] items = new String [0];
- boolean ignoreSelect, lockText, selectionAdded;
+ boolean selectionAdded;
int indexSelected;
/**
* the operating system limit for the number of characters
@@ -169,28 +169,9 @@ public void add (String string, int index) {
System.arraycopy (items, index, newItems, index + 1, items.length - index);
items = newItems;
byte [] buffer = Converter.wcsToMbcs (null, string, true);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- OS.gtk_combo_box_insert_text (handle, index, buffer);
- if ((style & SWT.RIGHT_TO_LEFT) != 0 && popupHandle != 0) {
- OS.gtk_container_forall (popupHandle, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);
- }
- } else {
- /*
- * 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;
- int /*long*/ item = OS.gtk_list_item_new_with_label (buffer);
- int /*long*/ label = OS.gtk_bin_get_child (item);
- setForegroundColor (label, getForegroundColor ());
- OS.gtk_widget_modify_font (label, getFontDescription ());
- OS.gtk_widget_set_direction (label, OS.gtk_widget_get_direction (handle));
- 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;
+ OS.gtk_combo_box_insert_text (handle, index, buffer);
+ if ((style & SWT.RIGHT_TO_LEFT) != 0 && popupHandle != 0) {
+ OS.gtk_container_forall (popupHandle, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);
}
}
@@ -338,63 +319,29 @@ public void clearSelection () {
}
void clearText () {
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
- if ((style & SWT.READ_ONLY) != 0) {
- int index = OS.gtk_combo_box_get_active (handle);
- if (index != -1) {
- int /*long*/ modelHandle = OS.gtk_combo_box_get_model (handle);
- int /*long*/ [] ptr = new int /*long*/ [1];
- int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
- OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
- OS.gtk_tree_model_get (modelHandle, iter, 0, ptr, -1);
- OS.g_free (iter);
- if (ptr [0] != 0 && OS.strlen (ptr [0]) > 0) postEvent (SWT.Modify);
- OS.g_free (ptr [0]);
- }
- } else {
- OS.gtk_entry_set_text (entryHandle, new byte[1]);
+ OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+ if ((style & SWT.READ_ONLY) != 0) {
+ int index = OS.gtk_combo_box_get_active (handle);
+ if (index != -1) {
+ int /*long*/ modelHandle = OS.gtk_combo_box_get_model (handle);
+ int /*long*/ [] ptr = new int /*long*/ [1];
+ int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
+ OS.gtk_tree_model_iter_nth_child (modelHandle, iter, 0, index);
+ OS.gtk_tree_model_get (modelHandle, iter, 0, ptr, -1);
+ OS.g_free (iter);
+ if (ptr [0] != 0 && OS.strlen (ptr [0]) > 0) postEvent (SWT.Modify);
+ OS.g_free (ptr [0]);
}
- OS.gtk_combo_box_set_active (handle, -1);
- OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+ } else {
+ OS.gtk_entry_set_text (entryHandle, new byte[1]);
}
+ OS.gtk_combo_box_set_active (handle, -1);
+ OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
}
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- return computeNativeSize (handle, wHint, hHint, changed);
- }
- if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
- if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
- int[] w = new int [1], h = new int [1];
- OS.gtk_widget_realize (entryHandle);
- int /*long*/ layout = OS.gtk_entry_get_layout (entryHandle);
- OS.pango_layout_get_size (layout, w, h);
- int xborder = Display.INNER_BORDER, yborder = Display.INNER_BORDER;
- int /*long*/ style = OS.gtk_widget_get_style (entryHandle);
- xborder += OS.gtk_style_get_xthickness (style);
- yborder += OS.gtk_style_get_ythickness (style);
- int [] property = new int [1];
- OS.gtk_widget_style_get (entryHandle, OS.interior_focus, property, 0);
- if (property [0] == 0) {
- OS.gtk_widget_style_get (entryHandle, OS.focus_line_width, property, 0);
- xborder += property [0];
- yborder += property [0];
- }
- int width = OS.PANGO_PIXELS (w [0]) + xborder * 2;
- int height = OS.PANGO_PIXELS (h [0]) + yborder * 2;
-
- GtkRequisition arrowRequesition = new GtkRequisition ();
- OS.gtk_widget_size_request (buttonHandle, arrowRequesition);
- GtkRequisition listRequesition = new GtkRequisition ();
- int /*long*/ listParent = OS.gtk_widget_get_parent (listHandle);
- OS.gtk_widget_size_request (listParent != 0 ? listParent : listHandle, listRequesition);
-
- width = Math.max (listRequesition.width, width) + arrowRequesition.width + 4;
- width = wHint == SWT.DEFAULT ? width : wHint;
- height = hHint == SWT.DEFAULT ? height : hHint;
- return new Point (width, height);
+ return computeNativeSize (handle, wHint, hHint, changed);
}
/**
@@ -420,110 +367,60 @@ void createHandle (int index) {
fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0);
if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES);
OS.gtk_fixed_set_has_window (fixedHandle, true);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- int /*long*/ oldList = OS.gtk_window_list_toplevels ();
- if ((style & SWT.READ_ONLY) != 0) {
- handle = OS.gtk_combo_box_new_text ();
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- cellHandle = OS.gtk_bin_get_child (handle);
- if (cellHandle == 0) error (SWT.ERROR_NO_HANDLES);
- } else {
- handle = OS.gtk_combo_box_entry_new_text ();
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- entryHandle = OS.gtk_bin_get_child (handle);
- if (entryHandle == 0) error (SWT.ERROR_NO_HANDLES);
- }
- popupHandle = findPopupHandle (oldList);
- OS.gtk_container_add (fixedHandle, handle);
- textRenderer = OS.gtk_cell_renderer_text_new ();
- if (textRenderer == 0) error (SWT.ERROR_NO_HANDLES);
- /*
- * Feature in GTK. In order to make a read only combo box the same
- * height as an editable combo box the ypad must be set to 0. In
- * versions 2.4.x of GTK, a pad of 0 will clip some letters. The
- * fix is to set the pad to 1.
- */
- int pad = 0;
- if (OS.GTK_VERSION < OS.VERSION(2, 6, 0)) pad = 1;
- OS.g_object_set (textRenderer, OS.ypad, pad, 0);
- /*
- * Feature in GTK. In version 2.4.9 of GTK, a warning is issued
- * when a call to gtk_cell_layout_clear() is made. The fix is to hide
- * the warning.
- */
- boolean warnings = display.getWarnings ();
- display.setWarnings (false);
- OS.gtk_cell_layout_clear (handle);
- display.setWarnings (warnings);
- OS.gtk_cell_layout_pack_start (handle, textRenderer, true);
- OS.gtk_cell_layout_set_attributes (handle, textRenderer, OS.text, 0, 0);
- /*
- * Feature in GTK. Toggle button creation differs between GTK versions. The
- * fix is to call size_request() to force the creation of the button
- * for those versions of GTK that defer the creation.
- */
- if (OS.GTK_VERSION < OS.VERSION (2, 8, 0)) {
- OS.gtk_widget_size_request(handle, new GtkRequisition());
- }
- if (popupHandle != 0) findMenuHandle ();
- findButtonHandle ();
- /*
- * Feature in GTK. By default, read only combo boxes
- * process the RETURN key rather than allowing the
- * default button to process the key. The fix is to
- * clear the GTK_RECEIVES_DEFAULT flag.
- */
- if ((style & SWT.READ_ONLY) != 0 && buttonHandle != 0) {
- OS.GTK_WIDGET_UNSET_FLAGS (buttonHandle, OS.GTK_RECEIVES_DEFAULT);
- }
+ int /*long*/ oldList = OS.gtk_window_list_toplevels ();
+ if ((style & SWT.READ_ONLY) != 0) {
+ handle = OS.gtk_combo_box_new_text ();
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ cellHandle = OS.gtk_bin_get_child (handle);
+ if (cellHandle == 0) error (SWT.ERROR_NO_HANDLES);
} else {
- handle = OS.gtk_combo_new ();
+ handle = OS.gtk_combo_box_entry_new_text ();
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- OS.gtk_container_add (fixedHandle, handle);
- GtkCombo combo = new GtkCombo ();
- OS.memmove (combo, handle);
- entryHandle = combo.entry;
- listHandle = combo.list;
-
- if (OS.GTK_VERSION < OS.VERSION (2, 4, 0)) {
- int /*long*/ parentHandle = 0;
- int /*long*/ temp = listHandle;
- while ((temp = OS.gtk_widget_get_parent(temp)) != 0) {
- parentHandle = temp;
- }
- popupHandle = parentHandle;
- if (popupHandle != 0) {
- int /*long*/ modalGroup = getShell().modalGroup;
- if (modalGroup != 0) {
- OS.gtk_window_group_add_window (modalGroup, popupHandle);
- }
- }
- }
- /*
- * Feature in GTK. There is no API to query the arrow
- * handle from a combo box although it is possible to
- * get the list and text field. The arrow handle is needed
- * to hook events. The fix is to find the first child that is
- * not the entry or list and assume this is the arrow handle.
- */
- int /*long*/ list = OS.gtk_container_get_children (handle);
- if (list != 0) {
- int i = 0, count = OS.g_list_length (list);
- while (i<count) {
- int /*long*/ childHandle = OS.g_list_nth_data (list, i);
- if (childHandle != entryHandle && childHandle != listHandle) {
- buttonHandle = childHandle;
- break;
- }
- i++;
- }
- OS.g_list_free (list);
- }
-
- boolean editable = (style & SWT.READ_ONLY) == 0;
- OS.gtk_editable_set_editable (entryHandle, editable);
- OS.gtk_combo_disable_activate (handle);
- OS.gtk_combo_set_case_sensitive (handle, true);
+ entryHandle = OS.gtk_bin_get_child (handle);
+ if (entryHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ }
+ popupHandle = findPopupHandle (oldList);
+ OS.gtk_container_add (fixedHandle, handle);
+ textRenderer = OS.gtk_cell_renderer_text_new ();
+ if (textRenderer == 0) error (SWT.ERROR_NO_HANDLES);
+ /*
+ * Feature in GTK. In order to make a read only combo box the same
+ * height as an editable combo box the ypad must be set to 0. In
+ * versions 2.4.x of GTK, a pad of 0 will clip some letters. The
+ * fix is to set the pad to 1.
+ */
+ int pad = 0;
+ if (OS.GTK_VERSION < OS.VERSION(2, 6, 0)) pad = 1;
+ OS.g_object_set (textRenderer, OS.ypad, pad, 0);
+ /*
+ * Feature in GTK. In version 2.4.9 of GTK, a warning is issued
+ * when a call to gtk_cell_layout_clear() is made. The fix is to hide
+ * the warning.
+ */
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.gtk_cell_layout_clear (handle);
+ display.setWarnings (warnings);
+ OS.gtk_cell_layout_pack_start (handle, textRenderer, true);
+ OS.gtk_cell_layout_set_attributes (handle, textRenderer, OS.text, 0, 0);
+ /*
+ * Feature in GTK. Toggle button creation differs between GTK versions. The
+ * fix is to call size_request() to force the creation of the button
+ * for those versions of GTK that defer the creation.
+ */
+ if (OS.GTK_VERSION < OS.VERSION (2, 8, 0)) {
+ OS.gtk_widget_size_request(handle, new GtkRequisition());
+ }
+ if (popupHandle != 0) findMenuHandle ();
+ findButtonHandle ();
+ /*
+ * Feature in GTK. By default, read only combo boxes
+ * process the RETURN key rather than allowing the
+ * default button to process the key. The fix is to
+ * clear the GTK_RECEIVES_DEFAULT flag.
+ */
+ if ((style & SWT.READ_ONLY) != 0 && buttonHandle != 0) {
+ OS.GTK_WIDGET_UNSET_FLAGS (buttonHandle, OS.GTK_RECEIVES_DEFAULT);
}
}
@@ -550,7 +447,6 @@ void deregister () {
super.deregister ();
if (buttonHandle != 0) display.removeWidget (buttonHandle);
if (entryHandle != 0) display.removeWidget (entryHandle);
- if (listHandle != 0) display.removeWidget (listHandle);
if (popupHandle != 0) display.removeWidget (popupHandle);
if (menuHandle != 0) display.removeWidget (menuHandle);
int /*long*/ imContext = imContext ();
@@ -627,7 +523,7 @@ void findButtonHandle() {
void findMenuHandle() {
OS.gtk_container_forall (popupHandle, display.allChildrenProc, 0);
if (display.allChildren != 0) {
- int /*long*/ list = display.allChildren;
+ int /*long*/ list = display.allChildren;
while (list != 0) {
int /*long*/ widget = OS.g_list_data (list);
if (OS.G_OBJECT_TYPE (widget) == OS.GTK_TYPE_MENU ()) {
@@ -636,8 +532,8 @@ void findMenuHandle() {
}
list = OS.g_list_next (list);
}
- OS.g_list_free (display.allChildren);
- display.allChildren = 0;
+ OS.g_list_free (display.allChildren);
+ display.allChildren = 0;
}
}
@@ -679,9 +575,7 @@ int /*long*/ fontHandle () {
}
int /*long*/ focusHandle () {
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if ((style & SWT.READ_ONLY) != 0 && buttonHandle != 0) return buttonHandle;
- }
+ if ((style & SWT.READ_ONLY) != 0 && buttonHandle != 0) return buttonHandle;
if (entryHandle != 0) return entryHandle;
return super.focusHandle ();
}
@@ -689,15 +583,12 @@ int /*long*/ focusHandle () {
boolean hasFocus () {
if (super.hasFocus ()) return true;
if (entryHandle != 0 && OS.GTK_WIDGET_HAS_FOCUS (entryHandle)) return true;
- if (listHandle != 0 && OS.GTK_WIDGET_HAS_FOCUS (listHandle)) return true;
return false;
}
void hookEvents () {
super.hookEvents ();
- if (OS.GTK_VERSION >= OS.VERSION(2, 4, 0)) {
- OS.g_signal_connect_closure (handle, OS.changed, display.closures [CHANGED], true);
- }
+ OS.g_signal_connect_closure (handle, OS.changed, display.closures [CHANGED], true);
if (entryHandle != 0) {
OS.g_signal_connect_closure (entryHandle, OS.changed, display.closures [CHANGED], true);
@@ -708,7 +599,7 @@ void hookEvents () {
}
int eventMask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_PRESS_MASK |
OS.GDK_BUTTON_RELEASE_MASK;
- int /*long*/ [] handles = new int /*long*/ [] {buttonHandle, entryHandle, listHandle, menuHandle};
+ int /*long*/ [] handles = new int /*long*/ [] {buttonHandle, entryHandle, menuHandle};
for (int i=0; i<handles.length; i++) {
int /*long*/ eventHandle = handles [i];
if (eventHandle != 0) {
@@ -764,22 +655,9 @@ int /*long*/ imContext () {
public void deselect (int index) {
checkWidget();
if (index < 0 || index >= items.length) return;
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
if (OS.gtk_combo_box_get_active (handle) == index) {
clearText ();
}
- } else {
- 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;
- if (selected) {
- OS.gtk_list_unselect_all (listHandle);
- OS.gtk_entry_set_text (entryHandle, new byte[1]);
- }
- OS.g_list_free (children);
- ignoreSelect = false;
- }
}
/**
@@ -798,14 +676,7 @@ public void deselect (int index) {
*/
public void deselectAll () {
checkWidget();
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- clearText ();
- } else {
- ignoreSelect = true;
- OS.gtk_list_unselect_all (listHandle);
- OS.gtk_entry_set_text (entryHandle, new byte[1]);
- ignoreSelect = false;
- }
+ clearText ();
}
boolean dragDetect(int x, int y, boolean filter, boolean dragOnTimeout, boolean[] consume) {
@@ -926,7 +797,7 @@ public int getItemCount () {
*/
public int getItemHeight () {
checkWidget();
- return fontHeight (getFontDescription (), listHandle != 0 ? listHandle : handle);
+ return fontHeight (getFontDescription (), handle);
}
/**
@@ -973,10 +844,7 @@ public String [] getItems () {
*/
public boolean getListVisible () {
checkWidget ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- return popupHandle != 0 && OS.GTK_WIDGET_VISIBLE (popupHandle);
- }
- return false;
+ return popupHandle != 0 && OS.GTK_WIDGET_VISIBLE (popupHandle);
}
String getNameText () {
@@ -1022,13 +890,8 @@ public Point getSelection () {
checkWidget ();
if ((style & SWT.READ_ONLY) != 0) {
int length = 0;
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- int index = OS.gtk_combo_box_get_active (handle);
- if (index != -1) length = getItem (index).length ();
- } else {
- int /*long*/ str = OS.gtk_entry_get_text (entryHandle);
- if (str != 0) length = (int)/*64*/OS.g_utf16_strlen (str, -1);
- }
+ int index = OS.gtk_combo_box_get_active (handle);
+ if (index != -1) length = getItem (index).length ();
return new Point (0, length);
}
int [] start = new int [1];
@@ -1055,23 +918,7 @@ public Point getSelection () {
*/
public int getSelectionIndex () {
checkWidget();
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- return OS.gtk_combo_box_get_active (handle);
- }
- 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;
+ return OS.gtk_combo_box_get_active (handle);
}
/**
@@ -1181,53 +1028,35 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) {
* the left mouse button event from being propagated. The fix is to
* send the mouse event from the event_after handler.
*/
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- GdkEventButton gdkEvent = new GdkEventButton ();
- OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
- if (gdkEvent.type == OS.GDK_BUTTON_PRESS && gdkEvent.button == 1) {
- return gtk_button_press_event(widget, event, false);
- }
+ GdkEventButton gdkEvent = new GdkEventButton ();
+ OS.memmove (gdkEvent, event, GdkEventButton.sizeof);
+ if (gdkEvent.type == OS.GDK_BUTTON_PRESS && gdkEvent.button == 1) {
+ return gtk_button_press_event(widget, event, false);
}
return super.gtk_button_press_event (widget, event);
}
int /*long*/ gtk_changed (int /*long*/ widget) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if (widget == handle) {
- if (entryHandle == 0) {
- sendEvent(SWT.Modify);
- if (isDisposed ()) return 0;
- }
- /*
- * Feature in GTK. GTK emits a changed signal whenever
- * the contents of a combo box are altered by typing or
- * by selecting an item in the list, but the event should
- * only be sent when the list is selected. The fix is to
- * only send out a selection event when there is a selected
- * item.
- *
- * NOTE: This code relies on GTK clearing the selected
- * item and not matching the item as the user types.
- */
- int index = OS.gtk_combo_box_get_active (handle);
- if (index != -1) sendSelectionEvent (SWT.Selection);
- indexSelected = -1;
- return 0;
- }
- } else {
- if (!ignoreSelect) {
- int /*long*/ ptr = OS.gtk_entry_get_text (entryHandle);
- int length = OS.strlen (ptr);
- byte [] buffer = new byte [length];
- OS.memmove (buffer, ptr, length);
- String text = new String (Converter.mbcsToWcs (null, buffer));
- for (int i = 0; i < items.length; i++) {
- if (items [i].equals (text)) {
- sendSelectionEvent (SWT.Selection);
- break;
- }
- }
+ if (widget == handle) {
+ if (entryHandle == 0) {
+ sendEvent(SWT.Modify);
+ if (isDisposed ()) return 0;
}
+ /*
+ * Feature in GTK. GTK emits a changed signal whenever
+ * the contents of a combo box are altered by typing or
+ * by selecting an item in the list, but the event should
+ * only be sent when the list is selected. The fix is to
+ * only send out a selection event when there is a selected
+ * item.
+ *
+ * NOTE: This code relies on GTK clearing the selected
+ * item and not matching the item as the user types.
+ */
+ int index = OS.gtk_combo_box_get_active (handle);
+ if (index != -1) sendSelectionEvent (SWT.Selection);
+ indexSelected = -1;
+ return 0;
}
/*
* Feature in GTK. When the user types, GTK positions
@@ -1295,11 +1124,6 @@ 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;
int /*long*/ ptr = OS.gtk_entry_get_text (entryHandle);
if (end_pos == -1) end_pos = OS.g_utf8_strlen (ptr, -1);
@@ -1338,52 +1162,50 @@ int /*long*/ gtk_event_after (int /*long*/ widget, int /*long*/ gdkEvent) {
* user clicks on the drop down button focus is assigned to the text
* field.
*/
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- GdkEvent event = new GdkEvent ();
- OS.memmove (event, gdkEvent, GdkEvent.sizeof);
- switch (event.type) {
- case OS.GDK_BUTTON_PRESS: {
- if (OS.GTK_VERSION < OS.VERSION (2, 8, 0) && !selectionAdded) {
- int /*long*/ grabHandle = OS.gtk_grab_get_current ();
- if (grabHandle != 0) {
- if (OS.G_OBJECT_TYPE (grabHandle) == OS.GTK_TYPE_MENU ()) {
- menuHandle = grabHandle;
- OS.g_signal_connect_closure_by_id (menuHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT], false);
- OS.g_signal_connect_closure_by_id (menuHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT_INVERSE], true);
- OS.g_signal_connect_closure (menuHandle, OS.selection_done, display.closures [SELECTION_DONE], false);
- display.addWidget (menuHandle, this);
- selectionAdded = true;
- }
+ GdkEvent event = new GdkEvent ();
+ OS.memmove (event, gdkEvent, GdkEvent.sizeof);
+ switch (event.type) {
+ case OS.GDK_BUTTON_PRESS: {
+ if (OS.GTK_VERSION < OS.VERSION (2, 8, 0) && !selectionAdded) {
+ int /*long*/ grabHandle = OS.gtk_grab_get_current ();
+ if (grabHandle != 0) {
+ if (OS.G_OBJECT_TYPE (grabHandle) == OS.GTK_TYPE_MENU ()) {
+ menuHandle = grabHandle;
+ OS.g_signal_connect_closure_by_id (menuHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT], false);
+ OS.g_signal_connect_closure_by_id (menuHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT_INVERSE], true);
+ OS.g_signal_connect_closure (menuHandle, OS.selection_done, display.closures [SELECTION_DONE], false);
+ display.addWidget (menuHandle, this);
+ selectionAdded = true;
}
}
- GdkEventButton gdkEventButton = new GdkEventButton ();
- OS.memmove (gdkEventButton, gdkEvent, GdkEventButton.sizeof);
- if (gdkEventButton.button == 1) {
- if (!sendMouseEvent (SWT.MouseDown, gdkEventButton.button, display.clickCount, 0, false, gdkEventButton.time, gdkEventButton.x_root, gdkEventButton.y_root, false, gdkEventButton.state)) {
- return 1;
- }
- if (OS.GTK_VERSION >= OS.VERSION (2, 6, 0)) {
- if ((style & SWT.READ_ONLY) == 0 && widget == buttonHandle) {
- OS.gtk_widget_grab_focus (entryHandle);
- }
+ }
+ GdkEventButton gdkEventButton = new GdkEventButton ();
+ OS.memmove (gdkEventButton, gdkEvent, GdkEventButton.sizeof);
+ if (gdkEventButton.button == 1) {
+ if (!sendMouseEvent (SWT.MouseDown, gdkEventButton.button, display.clickCount, 0, false, gdkEventButton.time, gdkEventButton.x_root, gdkEventButton.y_root, false, gdkEventButton.state)) {
+ return 1;
+ }
+ if (OS.GTK_VERSION >= OS.VERSION (2, 6, 0)) {
+ if ((style & SWT.READ_ONLY) == 0 && widget == buttonHandle) {
+ OS.gtk_widget_grab_focus (entryHandle);
}
}
- break;
}
- case OS.GDK_FOCUS_CHANGE: {
- if (OS.GTK_VERSION >= OS.VERSION (2, 6, 0)) {
- if ((style & SWT.READ_ONLY) == 0) {
- GdkEventFocus gdkEventFocus = new GdkEventFocus ();
- OS.memmove (gdkEventFocus, gdkEvent, GdkEventFocus.sizeof);
- if (gdkEventFocus.in != 0) {
- OS.gtk_combo_box_set_focus_on_click (handle, false);
- } else {
- OS.gtk_combo_box_set_focus_on_click (handle, true);
- }
+ break;
+ }
+ case OS.GDK_FOCUS_CHANGE: {
+ if (OS.GTK_VERSION >= OS.VERSION (2, 6, 0)) {
+ if ((style & SWT.READ_ONLY) == 0) {
+ GdkEventFocus gdkEventFocus = new GdkEventFocus ();
+ OS.memmove (gdkEventFocus, gdkEvent, GdkEventFocus.sizeof);
+ if (gdkEventFocus.in != 0) {
+ OS.gtk_combo_box_set_focus_on_click (handle, false);
+ } else {
+ OS.gtk_combo_box_set_focus_on_click (handle, true);
}
}
- break;
}
+ break;
}
}
return super.gtk_event_after(widget, gdkEvent);
@@ -1395,11 +1217,6 @@ int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) {
}
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];
@@ -1448,7 +1265,7 @@ int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) {
}
if (gdkEventKey == -1) result = 1;
gdkEventKey = 0;
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0) && (style & SWT.READ_ONLY) == 0) {
+ if ((style & SWT.READ_ONLY) == 0) {
GdkEventKey keyEvent = new GdkEventKey ();
OS.memmove (keyEvent, event, GdkEventKey.sizeof);
int oldIndex = OS.gtk_combo_box_get_active (handle);
@@ -1560,10 +1377,8 @@ public int indexOf (String string, int start) {
}
boolean isFocusHandle(int widget) {
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if (buttonHandle != 0 && widget == buttonHandle) return true;
- if (entryHandle != 0 && widget == entryHandle) return true;
- }
+ if (buttonHandle != 0 && widget == buttonHandle) return true;
+ if (entryHandle != 0 && widget == entryHandle) return true;
return super.isFocusHandle (widget);
}
@@ -1571,9 +1386,7 @@ int /*long*/ paintWindow () {
int /*long*/ childHandle = entryHandle != 0 ? entryHandle : handle;
OS.gtk_widget_realize (childHandle);
int /*long*/ window = OS.GTK_WIDGET_WINDOW (childHandle);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if ((style & SWT.READ_ONLY) != 0) return window;
- }
+ if ((style & SWT.READ_ONLY) != 0) return window;
int /*long*/ children = OS.gdk_window_get_children (window);
if (children != 0) window = OS.g_list_data (children);
OS.g_list_free (children);
@@ -1607,7 +1420,6 @@ void register () {
super.register ();
if (buttonHandle != 0) display.addWidget (buttonHandle, this);
if (entryHandle != 0) display.addWidget (entryHandle, this);
- if (listHandle != 0) display.addWidget (listHandle, this);
if (popupHandle != 0) display.addWidget (popupHandle, this);
if (menuHandle != 0) display.addWidget (menuHandle, this);
int /*long*/ imContext = imContext ();
@@ -1616,7 +1428,7 @@ void register () {
void releaseHandle () {
super.releaseHandle ();
- buttonHandle = entryHandle = listHandle = 0;
+ buttonHandle = entryHandle = 0;
}
void releaseWidget () {
@@ -1649,23 +1461,8 @@ public void remove (int index) {
System.arraycopy (oldItems, 0, newItems, 0, index);
System.arraycopy (oldItems, index + 1, newItems, index, oldItems.length - index - 1);
items = newItems;
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if (OS.gtk_combo_box_get_active (handle) == index) clearText ();
- OS.gtk_combo_box_remove_text (handle, index);
- } else {
- 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;
- }
+ if (OS.gtk_combo_box_get_active (handle) == index) clearText ();
+ OS.gtk_combo_box_remove_text (handle, index);
}
/**
@@ -1695,29 +1492,10 @@ public void remove (int start, int end) {
System.arraycopy (oldItems, 0, newItems, 0, start);
System.arraycopy (oldItems, end + 1, newItems, start, oldItems.length - end - 1);
items = newItems;
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- int index = OS.gtk_combo_box_get_active (handle);
- if (start <= index && index <= end) clearText();
- for (int i = end; i >= start; i--) {
- OS.gtk_combo_box_remove_text (handle, i);
- }
- } else {
- 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;
+ int index = OS.gtk_combo_box_get_active (handle);
+ if (start <= index && index <= end) clearText();
+ for (int i = end; i >= start; i--) {
+ OS.gtk_combo_box_remove_text (handle, i);
}
}
@@ -1758,16 +1536,9 @@ public void removeAll () {
checkWidget();
int count = items.length;
items = new String[0];
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- clearText ();
- for (int i = count - 1; i >= 0; i--) {
- OS.gtk_combo_box_remove_text (handle, i);
- }
- } else {
- ignoreSelect = true;
- OS.gtk_list_clear_items (listHandle, 0, -1);
- OS.gtk_entry_set_text (entryHandle, new byte[1]);
- ignoreSelect = false;
+ clearText ();
+ for (int i = count - 1; i >= 0; i--) {
+ OS.gtk_combo_box_remove_text (handle, i);
}
}
@@ -1861,35 +1632,24 @@ public void removeVerifyListener (VerifyListener listener) {
public void select (int index) {
checkWidget();
if (index < 0 || index >= items.length) return;
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
- OS.gtk_combo_box_set_active (handle, index);
- OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
- if ((style & SWT.READ_ONLY) != 0) {
- /*
- * Feature in GTK. Read Only combo boxes do not get a chance to send out a
- * Modify event in the gtk_changed callback. The fix is to send a Modify event
- * here.
- */
- sendEvent (SWT.Modify);
- }
- } else {
- ignoreSelect = true;
- OS.gtk_list_select_item (listHandle, index);
- ignoreSelect = false;
+ OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+ OS.gtk_combo_box_set_active (handle, index);
+ OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+ if ((style & SWT.READ_ONLY) != 0) {
+ /*
+ * Feature in GTK. Read Only combo boxes do not get a chance to send out a
+ * Modify event in the gtk_changed callback. The fix is to send a Modify event
+ * here.
+ */
+ sendEvent (SWT.Modify);
}
}
void setBackgroundColor (GdkColor color) {
super.setBackgroundColor (color);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if (entryHandle != 0) OS.gtk_widget_modify_base (entryHandle, 0, color);
- if (cellHandle != 0) OS.g_object_set (cellHandle, OS.background_gdk, color, 0);
- OS.g_object_set (textRenderer, OS.background_gdk, color, 0);
- } else {
- OS.gtk_widget_modify_base (entryHandle, 0, color);
- if (listHandle != 0) OS.gtk_widget_modify_base (listHandle, 0, color);
- }
+ if (entryHandle != 0) OS.gtk_widget_modify_base (entryHandle, 0, color);
+ if (cellHandle != 0) OS.g_object_set (cellHandle, OS.background_gdk, color, 0);
+ OS.g_object_set (textRenderer, OS.background_gdk, color, 0);
}
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
@@ -1900,58 +1660,26 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
void setFontDescription (int /*long*/ font) {
super.setFontDescription (font);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if (entryHandle != 0) OS.gtk_widget_modify_font (entryHandle, font);
- OS.g_object_set (textRenderer, OS.font_desc, font, 0);
- if ((style & SWT.READ_ONLY) != 0) {
- /*
- * Bug in GTK. Setting the font can leave the combo box with an
- * invalid minimum size. The fix is to temporarily change the
- * selected item to force the combo box to resize.
- */
- int index = OS.gtk_combo_box_get_active (handle);
- OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
- OS.gtk_combo_box_set_active (handle, -1);
- OS.gtk_combo_box_set_active (handle, index);
- OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
- }
- } else {
- OS.gtk_widget_modify_font (entryHandle, font);
- if (listHandle != 0) {
- OS.gtk_widget_modify_font (listHandle, font);
- int /*long*/ itemsList = OS.gtk_container_get_children (listHandle);
- if (itemsList != 0) {
- int count = OS.g_list_length (itemsList);
- for (int i=count - 1; i>=0; i--) {
- int /*long*/ widget = OS.gtk_bin_get_child (OS.g_list_nth_data (itemsList, i));
- OS.gtk_widget_modify_font (widget, font);
- }
- OS.g_list_free (itemsList);
- }
- }
+ if (entryHandle != 0) OS.gtk_widget_modify_font (entryHandle, font);
+ OS.g_object_set (textRenderer, OS.font_desc, font, 0);
+ if ((style & SWT.READ_ONLY) != 0) {
+ /*
+ * Bug in GTK. Setting the font can leave the combo box with an
+ * invalid minimum size. The fix is to temporarily change the
+ * selected item to force the combo box to resize.
+ */
+ int index = OS.gtk_combo_box_get_active (handle);
+ OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+ OS.gtk_combo_box_set_active (handle, -1);
+ OS.gtk_combo_box_set_active (handle, index);
+ OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
}
}
void setForegroundColor (GdkColor color) {
super.setForegroundColor (color);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if (entryHandle != 0) setForegroundColor (entryHandle, color);
- OS.g_object_set (textRenderer, OS.foreground_gdk, color, 0);
- } else {
- setForegroundColor (entryHandle, color);
- if (listHandle != 0) {
- setForegroundColor (listHandle, color);
- int /*long*/ itemsList = OS.gtk_container_get_children (listHandle);
- if (itemsList != 0) {
- int count = OS.g_list_length (itemsList);
- for (int i=count - 1; i>=0; i--) {
- int /*long*/ widget = OS.gtk_bin_get_child (OS.g_list_nth_data (itemsList, i));
- setForegroundColor (widget, color);
- }
- OS.g_list_free (itemsList);
- }
- }
- }
+ if (entryHandle != 0) setForegroundColor (entryHandle, color);
+ OS.g_object_set (textRenderer, OS.foreground_gdk, color, 0);
}
/**
@@ -1978,20 +1706,10 @@ public void setItem (int index, String string) {
}
items [index] = string;
byte [] buffer = Converter.wcsToMbcs (null, string, true);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- OS.gtk_combo_box_remove_text (handle, index);
- OS.gtk_combo_box_insert_text (handle, index, buffer);
- if ((style & SWT.RIGHT_TO_LEFT) != 0 && popupHandle != 0) {
- OS.gtk_container_forall (popupHandle, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);
- }
- } else {
- ignoreSelect = 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;
+ OS.gtk_combo_box_remove_text (handle, index);
+ OS.gtk_combo_box_insert_text (handle, index, buffer);
+ if ((style & SWT.RIGHT_TO_LEFT) != 0 && popupHandle != 0) {
+ OS.gtk_container_forall (popupHandle, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);
}
}
@@ -2018,40 +1736,17 @@ public void setItems (String [] items) {
int count = this.items.length;
this.items = new String [items.length];
System.arraycopy (items, 0, this.items, 0, items.length);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- clearText ();
- for (int i = count - 1; i >= 0; i--) {
- OS.gtk_combo_box_remove_text (handle, i);
- }
- for (int i = 0; i < items.length; i++) {
- String string = items [i];
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- OS.gtk_combo_box_insert_text (handle, i, buffer);
- if ((style & SWT.RIGHT_TO_LEFT) != 0 && popupHandle != 0) {
- OS.gtk_container_forall (popupHandle, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);
- }
- }
- } else {
- lockText = ignoreSelect = true;
- OS.gtk_list_clear_items (listHandle, 0, -1);
- int /*long*/ font = getFontDescription ();
- GdkColor color = getForegroundColor ();
- int direction = OS.gtk_widget_get_direction (handle);
- int i = 0;
- while (i < items.length) {
- String string = items [i];
- 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);
- setForegroundColor (label, color);
- OS.gtk_widget_modify_font (label, font);
- OS.gtk_widget_set_direction (label, direction);
- OS.gtk_container_add (listHandle, item);
- OS.gtk_widget_show (item);
- i++;
+ clearText ();
+ for (int i = count - 1; i >= 0; i--) {
+ OS.gtk_combo_box_remove_text (handle, i);
+ }
+ for (int i = 0; i < items.length; i++) {
+ String string = items [i];
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ OS.gtk_combo_box_insert_text (handle, i, buffer);
+ if ((style & SWT.RIGHT_TO_LEFT) != 0 && popupHandle != 0) {
+ OS.gtk_container_forall (popupHandle, display.setDirectionProc, OS.GTK_TEXT_DIR_RTL);
}
- lockText = ignoreSelect = false;
- OS.gtk_entry_set_text (entryHandle, new byte[1]);
}
}
@@ -2075,12 +1770,10 @@ public void setItems (String [] items) {
*/
public void setListVisible (boolean visible) {
checkWidget ();
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- if (visible) {
- OS.gtk_combo_box_popup (handle);
- } else {
- OS.gtk_combo_box_popdown (handle);
- }
+ if (visible) {
+ OS.gtk_combo_box_popup (handle);
+ } else {
+ OS.gtk_combo_box_popdown (handle);
}
}
@@ -2088,22 +1781,9 @@ void setOrientation (boolean create) {
super.setOrientation (create);
if ((style & SWT.RIGHT_TO_LEFT) != 0 || !create) {
int dir = (style & SWT.RIGHT_TO_LEFT) != 0 ? OS.GTK_TEXT_DIR_RTL : OS.GTK_TEXT_DIR_LTR;
- if (listHandle != 0) OS.gtk_widget_set_direction (listHandle, dir);
if (entryHandle != 0) OS.gtk_widget_set_direction (entryHandle, dir);
if (cellHandle != 0) OS.gtk_widget_set_direction (cellHandle, dir);
if (!create) {
- if (listHandle != 0) {
- OS.gtk_widget_set_direction (listHandle, dir);
- int /*long*/ itemsList = OS.gtk_container_get_children (listHandle);
- if (itemsList != 0) {
- int count = OS.g_list_length (itemsList);
- for (int i=count - 1; i>=0; i--) {
- int /*long*/ widget = OS.gtk_bin_get_child (OS.g_list_nth_data (itemsList, i));
- OS.gtk_widget_set_direction (widget, dir);
- }
- OS.g_list_free (itemsList);
- }
- }
if (popupHandle != 0) OS.gtk_container_forall (popupHandle, display.setDirectionProc, dir);
}
}
@@ -2187,18 +1867,16 @@ public void setText (String string) {
if ((style & SWT.READ_ONLY) != 0) {
int index = indexOf (string);
if (index == -1) return;
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
- OS.gtk_combo_box_set_active (handle, index);
- OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
- /*
- * Feature in GTK. Read Only combo boxes do not get a chance to send out a
- * Modify event in the gtk_changed callback. The fix is to send a Modify event
- * here.
- */
- sendEvent (SWT.Modify);
- return;
- }
+ OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+ OS.gtk_combo_box_set_active (handle, index);
+ OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
+ /*
+ * Feature in GTK. Read Only combo boxes do not get a chance to send out a
+ * Modify event in the gtk_changed callback. The fix is to send a Modify event
+ * here.
+ */
+ sendEvent (SWT.Modify);
+ return;
}
/*
* Feature in gtk. When text is set in gtk, separate events are fired for the deletion and
@@ -2211,16 +1889,12 @@ public void setText (String string) {
if (string == null) return;
}
byte [] buffer = Converter.wcsToMbcs (null, string, true);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
- }
+ OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.g_signal_handlers_block_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.g_signal_handlers_block_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_TEXT);
OS.g_signal_handlers_block_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
OS.gtk_entry_set_text (entryHandle, buffer);
- if (OS.GTK_VERSION >= OS.VERSION (2, 4, 0)) {
- OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
- }
+ OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.g_signal_handlers_unblock_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.g_signal_handlers_unblock_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, DELETE_TEXT);
OS.g_signal_handlers_unblock_matched (entryHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, INSERT_TEXT);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 07688d5c99..dcada53e7d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -3562,6 +3562,9 @@ void releaseWidget () {
cursor = null;
toolTipText = null;
layoutData = null;
+ if (accessible != null) {
+ accessible.internal_dispose_Accessible ();
+ }
accessible = null;
region = null;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
index 92ac09fbcd..b6979e12a8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -115,12 +115,7 @@ public String getMessage () {
* </ul>
*/
public String open () {
- boolean useChooserDialog = OS.GTK_VERSION >= OS.VERSION (2, 4, 10);
- if (useChooserDialog) {
return openChooserDialog ();
- } else {
- return openClassicDialog ();
- }
}
String openChooserDialog () {
byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
@@ -225,104 +220,6 @@ String openChooserDialog () {
OS.gtk_widget_destroy (handle);
return answer;
}
-String openClassicDialog () {
- byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
- int /*long*/ handle = OS.gtk_file_selection_new (titleBytes);
- if (parent != null) {
- int /*long*/ shellHandle = parent.topHandle ();
- OS.gtk_window_set_transient_for (handle, shellHandle);
- int /*long*/ pixbufs = OS.gtk_window_get_icon_list (shellHandle);
- if (pixbufs != 0) {
- OS.gtk_window_set_icon_list (handle, pixbufs);
- OS.g_list_free (pixbufs);
- }
- }
- OS.gtk_window_set_modal (handle, true);
- String answer = null;
- if (filterPath != null) {
- String path = filterPath;
- if (path.length () > 0 && !path.endsWith (SEPARATOR)) {
- path += SEPARATOR;
- }
- int length = path.length ();
- char [] buffer = new char [length + 1];
- path.getChars (0, length, buffer, 0);
- int /*long*/ utf8Ptr = OS.g_utf16_to_utf8 (buffer, -1, null, null, null);
- int /*long*/ fileNamePtr = OS.g_filename_from_utf8 (utf8Ptr, -1, null, null, null);
- OS.gtk_file_selection_set_filename (handle, fileNamePtr);
- OS.g_free (utf8Ptr);
- OS.g_free (fileNamePtr);
- }
- GtkFileSelection selection = new GtkFileSelection ();
- OS.memmove (selection, handle);
- OS.gtk_file_selection_hide_fileop_buttons (handle);
- int /*long*/ fileListParent = OS.gtk_widget_get_parent (selection.file_list);
- OS.gtk_widget_hide (selection.file_list);
- OS.gtk_widget_hide (fileListParent);
- if (message.length () > 0) {
- byte [] buffer = Converter.wcsToMbcs (null, message, true);
- int /*long*/ labelHandle = OS.gtk_label_new (buffer);
- OS.gtk_label_set_line_wrap (labelHandle, true);
- OS.gtk_misc_set_alignment (labelHandle, 0.0f, 0.0f);
- OS.gtk_container_add (selection.main_vbox, labelHandle);
- OS.gtk_box_set_child_packing (
- selection.main_vbox, labelHandle, false, false, 0, OS.GTK_PACK_START);
- OS.gtk_widget_show (labelHandle);
- }
- Display display = parent != null ? parent.getDisplay (): Display.getCurrent ();
- display.addIdleProc ();
- Dialog oldModal = null;
- if (OS.gtk_window_get_modal (handle)) {
- oldModal = display.getModalDialog ();
- display.setModalDialog (this);
- }
- int signalId = 0;
- int /*long*/ hookId = 0;
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
- signalId = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET());
- hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
- }
- int response = OS.gtk_dialog_run (handle);
- /*
- * This call to gdk_threads_leave() is a temporary work around
- * to avoid deadlocks when gdk_threads_init() is called by native
- * code outside of SWT (i.e AWT, etc). It ensures that the current
- * thread leaves the GTK lock acquired by the function above.
- */
- OS.gdk_threads_leave();
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
- OS.g_signal_remove_emission_hook (signalId, hookId);
- }
- if (OS.gtk_window_get_modal (handle)) {
- display.setModalDialog (oldModal);
- }
- if (response == OS.GTK_RESPONSE_OK) {
- int /*long*/ fileNamePtr = OS.gtk_file_selection_get_filename (handle);
- int /*long*/ utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, null, null);
- if (utf8Ptr != 0) {
- int /*long*/ [] items_written = new int /*long*/ [1];
- int /*long*/ utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
- if (utf16Ptr != 0) {
- int length = (int)/*64*/items_written [0];
- char [] buffer = new char [length];
- OS.memmove (buffer, utf16Ptr, length * 2);
- String osAnswer = new String (buffer);
- if (osAnswer != null) {
- /* remove trailing separator, unless root directory */
- if (!osAnswer.equals (SEPARATOR) && osAnswer.endsWith (SEPARATOR)) {
- osAnswer = osAnswer.substring (0, osAnswer.length () - 1);
- }
- answer = filterPath = osAnswer;
- }
- OS.g_free (utf16Ptr);
- }
- OS.g_free (utf8Ptr);
- }
- }
- display.removeIdleProc ();
- OS.gtk_widget_destroy (handle);
- return answer;
-}
/**
* Sets the path that the dialog will use to filter
* the directories it shows to the argument, which may
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 64dd3cd92d..2f05d62981 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -631,8 +631,8 @@ int /*long*/ allChildrenProc (int /*long*/ widget, int /*long*/ recurse) {
}
void addMouseHoverTimeout (int /*long*/ handle) {
- if (mouseHoverId != 0) OS.gtk_timeout_remove (mouseHoverId);
- mouseHoverId = OS.gtk_timeout_add (400, mouseHoverProc, handle);
+ if (mouseHoverId != 0) OS.g_source_remove (mouseHoverId);
+ mouseHoverId = OS.g_timeout_add (400, mouseHoverProc, handle);
mouseHoverHandle = handle;
}
@@ -3290,7 +3290,7 @@ void releaseDisplay () {
allChildrenProc = 0;
/* Dispose the caret callback */
- if (caretId != 0) OS.gtk_timeout_remove (caretId);
+ if (caretId != 0) OS.g_source_remove (caretId);
caretId = 0;
caretProc = 0;
caretCallback.dispose ();
@@ -3305,7 +3305,7 @@ void releaseDisplay () {
/* Dispose the timer callback */
if (timerIds != null) {
for (int i=0; i<timerIds.length; i++) {
- if (timerIds [i] != 0) OS.gtk_timeout_remove (timerIds [i]);
+ if (timerIds [i] != 0) OS.g_source_remove (timerIds [i]);
}
}
timerIds = null;
@@ -3318,7 +3318,7 @@ void releaseDisplay () {
windowTimerCallback = null;
/* Dispose mouse hover callback */
- if (mouseHoverId != 0) OS.gtk_timeout_remove (mouseHoverId);
+ if (mouseHoverId != 0) OS.g_source_remove (mouseHoverId);
mouseHoverId = 0;
mouseHoverHandle = mouseHoverProc = 0;
mouseHoverCallback.dispose ();
@@ -3485,7 +3485,7 @@ public void removeListener (int eventType, Listener listener) {
void removeMouseHoverTimeout (int /*long*/ handle) {
if (handle != mouseHoverHandle) return;
- if (mouseHoverId != 0) OS.gtk_timeout_remove (mouseHoverId);
+ if (mouseHoverId != 0) OS.g_source_remove (mouseHoverId);
mouseHoverId = 0;
mouseHoverHandle = 0;
}
@@ -4074,7 +4074,7 @@ public void timerExec (int milliseconds, Runnable runnable) {
index++;
}
if (index != timerList.length) {
- OS.gtk_timeout_remove (timerIds [index]);
+ OS.g_source_remove (timerIds [index]);
timerList [index] = null;
timerIds [index] = 0;
if (milliseconds < 0) return;
@@ -4094,7 +4094,7 @@ public void timerExec (int milliseconds, Runnable runnable) {
timerIds = newTimerIds;
}
}
- int timerId = OS.gtk_timeout_add (milliseconds, timerProc, index);
+ int timerId = OS.g_timeout_add (milliseconds, timerProc, index);
if (timerId != 0) {
timerIds [index] = timerId;
timerList [index] = runnable;
@@ -4121,7 +4121,7 @@ int /*long*/ caretProc (int /*long*/ clientData) {
if (currentCaret.blinkCaret()) {
int blinkRate = currentCaret.blinkRate;
if (blinkRate == 0) return 0;
- caretId = OS.gtk_timeout_add (blinkRate, caretProc, 0);
+ caretId = OS.g_timeout_add (blinkRate, caretProc, 0);
} else {
currentCaret = null;
}
@@ -4190,12 +4190,12 @@ void sendEvent (int eventType, Event event) {
}
void setCurrentCaret (Caret caret) {
- if (caretId != 0) OS.gtk_timeout_remove(caretId);
+ if (caretId != 0) OS.g_source_remove(caretId);
caretId = 0;
currentCaret = caret;
if (caret == null) return;
int blinkRate = currentCaret.blinkRate;
- caretId = OS.gtk_timeout_add (blinkRate, caretProc, 0);
+ caretId = OS.g_timeout_add (blinkRate, caretProc, 0);
}
int /*long*/ shellMapProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
index c20f9c59d1..0a0c755a20 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
@@ -215,91 +215,6 @@ String computeResultChooserDialog () {
return fullPath;
}
-String computeResultClassicDialog () {
- filterIndex = -1;
- GtkFileSelection selection = new GtkFileSelection ();
- OS.memmove (selection, handle);
- int /*long*/ entry = selection.selection_entry;
- int /*long*/ entryText = OS.gtk_entry_get_text (entry);
- int entryLength = OS.strlen (entryText);
- if (entryLength == 0) {
- int /*long*/ fileList = selection.file_list;
- int /*long*/ listSelection = OS.gtk_tree_view_get_selection (fileList);
- int /*long*/[] model = new int /*long*/[1];
- int /*long*/ selectedList = OS.gtk_tree_selection_get_selected_rows (listSelection, model);
- if (selectedList == 0) return null;
- int listLength = OS.g_list_length (selectedList);
- if (listLength == 0) {
- OS.g_list_free (selectedList);
- return null;
- }
- int /*long*/ path = OS.g_list_nth_data (selectedList, 0);
- int /*long*/ [] ptr = new int /*long*/[1];
- int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
- if (OS.gtk_tree_model_get_iter (model [0], iter, path)) {
- OS.gtk_tree_model_get (model [0], iter, 0, ptr, -1);
- }
- OS.g_free (iter);
- for (int i = 0; i < listLength; i++) {
- OS.gtk_tree_path_free (OS.g_list_nth_data (selectedList, i));
- }
- OS.g_list_free (selectedList);
- if (ptr [0] == 0) return null;
- int length = OS.strlen (ptr [0]);
- byte [] buffer = new byte [length];
- OS.memmove (buffer, ptr [0], length);
- OS.g_free (ptr [0]);
- OS.gtk_entry_set_text (entry, buffer);
- }
-
- int /*long*/ fileNamePtr = OS.gtk_file_selection_get_filename (handle);
- int /*long*/ utf8Ptr = OS.g_filename_to_utf8 (fileNamePtr, -1, null, null, null);
- int /*long*/ [] items_written = new int /*long*/ [1];
- int /*long*/ utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
- entryLength = (int)/*64*/items_written [0];
- char [] buffer = new char [entryLength];
- OS.memmove (buffer, utf16Ptr, entryLength * 2);
- String osAnswer = new String (buffer);
- OS.g_free (utf16Ptr);
- OS.g_free (utf8Ptr);
-
- int separatorIndex = osAnswer.lastIndexOf (SEPARATOR);
- if (separatorIndex+1 == osAnswer.length ()) return null;
-
- String answer = fullPath = osAnswer;
- fileName = fullPath.substring (separatorIndex+1);
- filterPath = fullPath.substring (0, separatorIndex);
- if ((style & SWT.MULTI) == 0) {
- fileNames = new String[] {fileName};
- } else {
- int /*long*/ namesPtr = OS.gtk_file_selection_get_selections (handle);
- int /*long*/ namesPtr1 = namesPtr;
- int /*long*/ [] namePtr = new int /*long*/ [1];
- OS.memmove (namePtr, namesPtr1, OS.PTR_SIZEOF);
- int length = 0;
- while (namePtr[0] != 0) {
- length++;
- namesPtr1+=OS.PTR_SIZEOF;
- OS.memmove(namePtr, namesPtr1, OS.PTR_SIZEOF);
- }
- fileNames = new String [length];
- namePtr = new int /*long*/ [length];
- OS.memmove (namePtr, namesPtr, length * OS.PTR_SIZEOF);
- for (int i = 0; i < length; i++) {
- utf8Ptr = OS.g_filename_to_utf8 (namePtr [i], -1, null, null, null);
- items_written = new int /*long*/ [1];
- utf16Ptr = OS.g_utf8_to_utf16 (utf8Ptr, -1, null, items_written, null);
- buffer = new char [(int)/*64*/items_written [0]];
- OS.memmove (buffer, utf16Ptr, items_written [0] * 2);
- String name = new String (buffer);
- fileNames [i] = name.substring (name.lastIndexOf (SEPARATOR) + 1);
- OS.g_free (utf16Ptr);
- OS.g_free (utf8Ptr);
- }
- OS.g_strfreev (namesPtr);
- }
- return answer;
-}
/**
* Returns the path of the first file that was
* selected in the dialog relative to the filter path, or an
@@ -393,12 +308,7 @@ public boolean getOverwrite () {
* </ul>
*/
public String open () {
- boolean useChooserDialog = OS.GTK_VERSION >= OS.VERSION (2, 4, 10);
- if (useChooserDialog) {
return openChooserDialog ();
- } else {
- return openClassicDialog ();
- }
}
String openChooserDialog () {
byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
@@ -461,55 +371,6 @@ String openChooserDialog () {
OS.gtk_widget_destroy (handle);
return answer;
}
-String openClassicDialog () {
- byte [] titleBytes = Converter.wcsToMbcs (null, title, true);
- handle = OS.gtk_file_selection_new (titleBytes);
- if (parent != null) {
- int /*long*/ shellHandle = parent.topHandle ();
- OS.gtk_window_set_transient_for (handle, shellHandle);
- int /*long*/ pixbufs = OS.gtk_window_get_icon_list (shellHandle);
- if (pixbufs != 0) {
- OS.gtk_window_set_icon_list (handle, pixbufs);
- OS.g_list_free (pixbufs);
- }
- }
- OS.gtk_window_set_modal (handle, true);
- presetClassicDialog ();
- Display display = parent != null ? parent.getDisplay (): Display.getCurrent ();
- display.addIdleProc ();
- String answer = null;
- Dialog oldModal = null;
- if (OS.gtk_window_get_modal (handle)) {
- oldModal = display.getModalDialog ();
- display.setModalDialog (this);
- }
- int signalId = 0;
- int /*long*/ hookId = 0;
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
- signalId = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET());
- hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
- }
- int response = OS.gtk_dialog_run (handle);
- /*
- * This call to gdk_threads_leave() is a temporary work around
- * to avoid deadlocks when gdk_threads_init() is called by native
- * code outside of SWT (i.e AWT, etc). It ensures that the current
- * thread leaves the GTK lock acquired by the function above.
- */
- OS.gdk_threads_leave();
- if ((style & SWT.RIGHT_TO_LEFT) != 0) {
- OS.g_signal_remove_emission_hook (signalId, hookId);
- }
- if (OS.gtk_window_get_modal (handle)) {
- display.setModalDialog (oldModal);
- }
- if (response == OS.GTK_RESPONSE_OK) {
- answer = computeResultClassicDialog ();
- }
- display.removeIdleProc ();
- OS.gtk_widget_destroy (handle);
- return answer;
-}
void presetChooserDialog () {
/* MULTI is only valid if the native dialog's action is Open */
if ((style & (SWT.SAVE | SWT.MULTI)) == SWT.MULTI) {
@@ -619,41 +480,6 @@ void presetChooserDialog () {
fullPath = null;
fileNames = new String [0];
}
-void presetClassicDialog () {
- OS.gtk_file_selection_set_select_multiple(handle, (style & SWT.MULTI) != 0);
-
- /* Calculate the fully-specified file name and convert to bytes */
- StringBuffer stringBuffer = new StringBuffer ();
- if (filterPath == null) {
- filterPath = "";
- } else {
- if (filterPath.length () > 0) {
- stringBuffer.append (filterPath);
- if (filterPath.charAt (filterPath.length () - 1) != SEPARATOR) {
- stringBuffer.append (SEPARATOR);
- }
- }
- }
- if (fileName == null) {
- fileName = "";
- } else {
- stringBuffer.append (fileName);
- }
- fullPath = stringBuffer.toString ();
- int length = fullPath.length ();
- char [] buffer = new char [length + 1];
- fullPath.getChars (0, length, buffer, 0);
- int /*long*/ utf8Ptr = OS.g_utf16_to_utf8 (buffer, -1, null, null, null);
- int /*long*/ fileNamePtr = OS.g_filename_from_utf8 (utf8Ptr, -1, null, null, null);
- OS.gtk_file_selection_set_filename (handle, fileNamePtr);
- OS.g_free (utf8Ptr);
- OS.g_free (fileNamePtr);
-
- if (filterNames == null) filterNames = new String [0];
- if (filterExtensions == null) filterExtensions = new String [0];
- fullPath = null;
- fileNames = new String [0];
-}
/**
* Set the initial filename which the dialog will
* select by default when opened to the argument,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
index 996751d8b7..5edfc18fec 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java
@@ -623,8 +623,13 @@ public int getSelectionIndex () {
int /*long*/ indices = OS.gtk_tree_path_get_indices (data);
if (indices != 0) {
OS.memmove (index, indices, 4);
+ for (int j = i; j < count; j++) {
+ data = OS.g_list_nth_data (list, j);
+ OS.gtk_tree_path_free (data);
+ }
break;
}
+ OS.gtk_tree_path_free (data);
}
OS.g_list_free (list);
return index [0];
@@ -681,6 +686,7 @@ public int [] getSelectionIndices () {
treeSelection [length] = index [0];
length++;
}
+ OS.gtk_tree_path_free (data);
}
OS.g_list_free (list);
int [] result = new int [length];
@@ -1583,7 +1589,11 @@ public void showSelection () {
GdkRectangle cellRect = new GdkRectangle ();
OS.gtk_tree_view_get_cell_area (handle, path, 0, cellRect);
int[] tx = new int[1], ty = new int[1];
- OS.gtk_tree_view_widget_to_tree_coords(handle, cellRect.x, cellRect.y, tx, ty);
+ if (OS.GTK_VERSION >= OS.VERSION(2, 12, 0)) {
+ OS.gtk_tree_view_convert_widget_to_bin_window_coords(handle, cellRect.x, cellRect.y, tx, ty);
+ } else {
+ OS.gtk_tree_view_widget_to_tree_coords(handle, cellRect.x, cellRect.y, tx, ty);
+ }
if (ty[0] < visibleRect.y ) {
OS.gtk_tree_view_scroll_to_cell (handle, path, 0, true, 0f, 0f);
OS.gtk_tree_view_scroll_to_point (handle, -1, ty[0]);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
index d0a81f5582..07599ce918 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
@@ -313,6 +313,7 @@ int /*long*/ getAccelGroup () {
}
if (menu == null) return 0;
Decorations shell = menu.parent;
+ if (shell == null) return 0;
return shell.menuBar == menu ? shell.accelGroup : 0;
}
@@ -772,7 +773,11 @@ public void setMenu (Menu menu) {
* to replace or GTK will destroy it.
*/
OS.g_object_ref (oldMenu.handle);
- OS.gtk_menu_item_remove_submenu (handle);
+ if (OS.GTK_VERSION >= OS.VERSION(2, 12, 0)) {
+ OS.gtk_menu_item_set_submenu (handle, 0);
+ } else {
+ OS.gtk_menu_item_remove_submenu (handle);
+ }
}
if ((this.menu = menu) != null) {
menu.cascade = this;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java
index 7b4d23efef..811cecd5bf 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java
@@ -90,7 +90,7 @@ void createHandle (int index) {
int orientation = (style & SWT.VERTICAL) != 0 ? OS.GTK_PROGRESS_BOTTOM_TO_TOP : OS.GTK_PROGRESS_LEFT_TO_RIGHT;
OS.gtk_progress_bar_set_orientation (handle, orientation);
if ((style & SWT.INDETERMINATE) != 0) {
- timerId = OS.gtk_timeout_add (DELAY, display.windowTimerProc, handle);
+ timerId = OS.g_timeout_add (DELAY, display.windowTimerProc, handle);
}
}
@@ -176,7 +176,7 @@ int /*long*/ gtk_realize (int /*long*/ widget) {
void releaseWidget () {
super.releaseWidget ();
- if (timerId != 0) OS.gtk_timeout_remove (timerId);
+ if (timerId != 0) OS.g_source_remove (timerId);
timerId = 0;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
index a8e5063d38..5d4ab3ab23 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java
@@ -450,9 +450,9 @@ public boolean getVisible () {
int [] hsp = new int [1], vsp = new int [1];
OS.gtk_scrolled_window_get_policy (scrolledHandle, hsp, vsp);
if ((style & SWT.HORIZONTAL) != 0) {
- return hsp [0] != OS.GTK_POLICY_NEVER;
+ return hsp [0] != OS.GTK_POLICY_NEVER && OS.GTK_WIDGET_VISIBLE(handle);
} else {
- return vsp [0] != OS.GTK_POLICY_NEVER;
+ return vsp [0] != OS.GTK_POLICY_NEVER && OS.GTK_WIDGET_VISIBLE(handle);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index d70bc90eef..af3cc3e3c3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -2397,6 +2397,12 @@ void setToolTipText (int /*long*/ rootWidget, int /*long*/ tipWidget, String str
char [] chars = fixMnemonic (string, false);
buffer = Converter.wcsToMbcs (null, chars, true);
}
+ int /*long*/ oldTooltip = OS.gtk_widget_get_tooltip_text (rootWidget);
+ if (buffer == null && oldTooltip == 0) {
+ return;
+ } else if (buffer != null && oldTooltip != 0) {
+ if (OS.strcmp (oldTooltip, buffer) == 0) return;
+ }
OS.gtk_widget_set_tooltip_text (rootWidget, null);
/*
* Bug in GTK. In GTK 2.12, due to a miscalculation of window
@@ -2438,6 +2444,17 @@ void setToolTipText (int /*long*/ rootWidget, int /*long*/ tipWidget, String str
char [] chars = fixMnemonic (string, false);
buffer = Converter.wcsToMbcs (null, chars, true);
}
+ int /*long*/ tipData = OS.gtk_tooltips_data_get(tipWidget);
+ if (tipData != 0) {
+ int /*long*/ oldTooltip = OS.GTK_TOOLTIPS_GET_TIP_TEXT(tipData);
+ if (string == null && oldTooltip == 0) {
+ return;
+ } else if (string != null && oldTooltip != 0) {
+ if (buffer != null) {
+ if (OS.strcmp (oldTooltip, buffer) == 0) return;
+ }
+ }
+ }
if (tooltipsHandle == 0) {
tooltipsHandle = OS.gtk_tooltips_new ();
if (tooltipsHandle == 0) error (SWT.ERROR_NO_HANDLES);
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 f2b96c4811..968f7ba889 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
@@ -229,6 +229,7 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
if (isPixbuf) {
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_PIXBUF, ptr, -1);
OS.g_object_set (cell, OS.pixbuf, ptr [0], 0);
+ OS.g_object_unref (ptr [0]);
} else {
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_TEXT, ptr, -1);
if (ptr [0] != 0) {
@@ -248,6 +249,7 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_BACKGROUND, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.cell_background_gdk, ptr [0], 0);
+ OS.gdk_color_free (ptr [0]);
}
}
}
@@ -256,11 +258,13 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FOREGROUND, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.foreground_gdk, ptr [0], 0);
+ OS.gdk_color_free (ptr [0]);
}
ptr [0] = 0;
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FONT, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.font_desc, ptr [0], 0);
+ OS.pango_font_description_free (ptr [0]);
}
}
}
@@ -348,7 +352,12 @@ int calculateWidth (int /*long*/ column, int /*long*/ iter) {
int [] w = new int [1];
OS.gtk_widget_style_get(handle, OS.focus_line_width, w, 0);
width += 2 * w [0];
- int /*long*/ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+ int /*long*/ list = 0;
+ if (OS.GTK_VERSION >= OS.VERSION(2, 12, 0)) {
+ list = OS.gtk_cell_layout_get_cells(column);
+ } else {
+ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+ }
if (list == 0) return 0;
int /*long*/ temp = list;
while (temp != 0) {
@@ -539,7 +548,17 @@ void createColumn (TableColumn column, int index) {
for (int j=0; j<modelLength; j++) {
OS.gtk_tree_model_get (oldModel, oldItem, j, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, j, ptr [0], -1);
- if (types [j] == OS.G_TYPE_STRING ()) OS.g_free ((ptr [0]));
+ if (types [j] == OS.G_TYPE_STRING ()) {
+ OS.g_free ((ptr [0]));
+ } else if (ptr [0] != 0) {
+ if (types [j] == OS.GDK_TYPE_COLOR()) {
+ OS.gdk_color_free (ptr [0]);
+ } else if (types [j] == OS.GDK_TYPE_PIXBUF()) {
+ OS.g_object_unref (ptr [0]);
+ } else if (types [j] == OS.PANGO_TYPE_FONT_DESCRIPTION()) {
+ OS.pango_font_description_free (ptr [0]);
+ }
+ }
}
OS.gtk_list_store_remove (oldModel, oldItem);
OS.g_free (oldItem);
@@ -992,18 +1011,29 @@ void destroyItem (TableColumn column) {
for (int j=0; j<FIRST_COLUMN; j++) {
OS.gtk_tree_model_get (oldModel, oldItem, j, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, j, ptr [0], -1);
+ if (ptr [0] != 0) {
+ if (j == FOREGROUND_COLUMN || j == BACKGROUND_COLUMN) {
+ OS.gdk_color_free (ptr [0]);
+ } else if (j == FONT_COLUMN) {
+ OS.pango_font_description_free (ptr [0]);
+ }
+ }
}
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_PIXBUF, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_PIXBUF, ptr [0], -1);
+ if (ptr [0] != 0) OS.g_object_unref (ptr [0]);
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_TEXT, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_TEXT, ptr [0], -1);
OS.g_free (ptr [0]);
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_FOREGROUND, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_FOREGROUND, ptr [0], -1);
+ if (ptr [0] != 0) OS.gdk_color_free (ptr [0]);
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_BACKGROUND, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_BACKGROUND, ptr [0], -1);
+ if (ptr [0] != 0) OS.gdk_color_free (ptr [0]);
OS.gtk_tree_model_get (oldModel, oldItem, column.modelIndex + CELL_FONT, ptr, -1);
OS.gtk_list_store_set (newModel, newItem, FIRST_COLUMN + CELL_FONT, ptr [0], -1);
+ if (ptr [0] != 0) OS.pango_font_description_free (ptr [0]);
OS.gtk_list_store_remove (oldModel, oldItem);
OS.g_free (oldItem);
item.handle = newItem;
@@ -1577,7 +1607,13 @@ public boolean getLinesVisible() {
}
int /*long*/ getPixbufRenderer (int /*long*/ column) {
- int /*long*/ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+ int /*long*/ list = 0;
+ if (OS.GTK_VERSION >= OS.VERSION(2, 12, 0)) {
+ list = OS.gtk_cell_layout_get_cells(column);
+ } else {
+ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+ }
+
if (list == 0) return 0;
int count = OS.g_list_length (list);
int /*long*/ pixbufRenderer = 0;
@@ -1641,6 +1677,7 @@ public TableItem [] getSelection () {
treeSelection [length] = index [0];
length++;
}
+ OS.gtk_tree_path_free (data);
}
OS.g_list_free (list);
TableItem [] result = new TableItem [length];
@@ -1709,8 +1746,13 @@ public int getSelectionIndex () {
int /*long*/ indices = OS.gtk_tree_path_get_indices (data);
if (indices != 0) {
OS.memmove (index, indices, 4);
+ for (int j = i; j < count; j++) {
+ data = OS.g_list_nth_data (list, j);
+ OS.gtk_tree_path_free (data);
+ }
break;
}
+ OS.gtk_tree_path_free (data);
}
OS.g_list_free (list);
return index [0];
@@ -1766,6 +1808,7 @@ public int [] getSelectionIndices () {
treeSelection [length] = index [0];
length++;
}
+ OS.gtk_tree_path_free (data);
}
OS.g_list_free (list);
int [] result = new int [length];
@@ -1818,7 +1861,12 @@ public int getSortDirection () {
}
int /*long*/ getTextRenderer (int /*long*/ column) {
- int /*long*/ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+ int /*long*/ list = 0;
+ if (OS.GTK_VERSION >= OS.VERSION(2, 12, 0)) {
+ list = OS.gtk_cell_layout_get_cells(column);
+ } else {
+ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+ }
if (list == 0) return 0;
int count = OS.g_list_length (list);
int /*long*/ textRenderer = 0;
@@ -2633,7 +2681,10 @@ int /*long*/ rendererRenderProc (int /*long*/ cell, int /*long*/ window, int /*l
int modelIndex = columnCount == 0 ? Table.FIRST_COLUMN : columns [columnIndex].modelIndex;
OS.gtk_tree_model_get (modelHandle, item.handle, modelIndex + Table.CELL_BACKGROUND, ptr, -1);
}
- if (ptr [0] != 0) drawState |= SWT.BACKGROUND;
+ if (ptr [0] != 0) {
+ drawState |= SWT.BACKGROUND;
+ OS.gdk_color_free (ptr [0]);
+ }
if ((flags & OS.GTK_CELL_RENDERER_SELECTED) != 0) drawState |= SWT.SELECTED;
if ((flags & OS.GTK_CELL_RENDERER_FOCUSED) != 0) drawState |= SWT.FOCUSED;
@@ -3576,7 +3627,11 @@ void showItem (int /*long*/ iter) {
GdkRectangle cellRect = new GdkRectangle ();
OS.gtk_tree_view_get_cell_area (handle, path, 0, cellRect);
int[] tx = new int[1], ty = new int[1];
- OS.gtk_tree_view_widget_to_tree_coords(handle, cellRect.x, cellRect.y, tx, ty);
+ if (OS.GTK_VERSION >= OS.VERSION(2, 12, 0)) {
+ OS.gtk_tree_view_convert_widget_to_bin_window_coords(handle, cellRect.x, cellRect.y, tx, ty);
+ } else {
+ OS.gtk_tree_view_widget_to_tree_coords(handle, cellRect.x, cellRect.y, tx, ty);
+ }
if (ty[0] < visibleRect.y ) {
OS.gtk_tree_view_scroll_to_cell (handle, path, 0, true, 0f, 0f);
OS.gtk_tree_view_scroll_to_point (handle, -1, ty[0]);
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 3307d505eb..7119af4343 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
@@ -132,6 +132,7 @@ Color _getBackground () {
if (ptr [0] == 0) return parent.getBackground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+ OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -144,6 +145,7 @@ Color _getBackground (int index) {
if (ptr [0] == 0) return _getBackground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+ OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -159,6 +161,7 @@ Color _getForeground () {
if (ptr [0] == 0) return parent.getForeground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+ OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -171,6 +174,7 @@ Color _getForeground (int index) {
if (ptr [0] == 0) return _getForeground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+ OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -183,6 +187,7 @@ Image _getImage (int index) {
if (ptr [0] == 0) return null;
ImageList imageList = parent.imageList;
int imageIndex = imageList.indexOf (ptr [0]);
+ OS.g_object_unref (ptr [0]);
if (imageIndex == -1) return null;
return imageList.get (imageIndex);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
index 420ab48cae..3d30124842 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
@@ -98,7 +98,11 @@ public ToolBar (Composite parent, int style) {
this.style |= SWT.HORIZONTAL;
}
int orientation = (style & SWT.VERTICAL) != 0 ? OS.GTK_ORIENTATION_VERTICAL : OS.GTK_ORIENTATION_HORIZONTAL;
- OS.gtk_toolbar_set_orientation (handle, orientation);
+ if (OS.GTK_VERSION < OS.VERSION (2, 16, 0)) {
+ OS.gtk_toolbar_set_orientation (handle, orientation);
+ } else {
+ OS.gtk_orientable_set_orientation(handle, orientation);
+ }
}
static int checkStyle (int style) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
index 681e6a5930..ed861249f2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolItem.java
@@ -847,6 +847,7 @@ public void setDisabledImage (Image image) {
public void setEnabled (boolean enabled) {
checkWidget();
int /*long*/ topHandle = topHandle ();
+ if (OS.GTK_WIDGET_SENSITIVE (topHandle) == enabled) return;
OS.gtk_widget_set_sensitive (topHandle, enabled);
if (enabled) {
/*
@@ -1034,6 +1035,7 @@ public void setText (String string) {
checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
if ((style & SWT.SEPARATOR) != 0) return;
+ if (string.equals(this.text)) return;
super.setText (string);
if (labelHandle == 0) return;
char [] chars = fixMnemonic (string);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
index a3b3746401..919dcff28d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
@@ -577,11 +577,12 @@ void register () {
void releaseWidget () {
super.releaseWidget ();
+ setVisible(false);
if (layoutText != 0) OS.g_object_unref (layoutText);
layoutText = 0;
if (layoutMessage != 0) OS.g_object_unref (layoutMessage);
layoutMessage = 0;
- if (timerId != 0) OS.gtk_timeout_remove(timerId);
+ if (timerId != 0) OS.g_source_remove(timerId);
timerId = 0;
text = null;
message = null;
@@ -782,7 +783,7 @@ public void setText (String string) {
*/
public void setVisible (boolean visible) {
checkWidget ();
- if (timerId != 0) OS.gtk_timeout_remove(timerId);
+ if (timerId != 0) OS.g_source_remove(timerId);
timerId = 0;
if (visible) {
if ((style & SWT.BALLOON) != 0) {
@@ -794,18 +795,27 @@ public void setVisible (boolean visible) {
if (text.length () > 0) string.append ("\n\n");
string.append (message);
byte [] buffer = Converter.wcsToMbcs (null, string.toString(), true);
- OS.gtk_tooltips_set_tip (handle, vboxHandle, buffer, null);
- int /*long*/ data = OS.gtk_tooltips_data_get (vboxHandle);
- OS.GTK_TOOLTIPS_SET_ACTIVE (handle, data);
- OS.gtk_tooltips_set_tip (handle, vboxHandle, buffer, null);
+ if (OS.GTK_VERSION >= OS.VERSION(2, 12, 0)) {
+ OS.gtk_widget_set_tooltip_text(vboxHandle, buffer);
+ } else {
+ OS.gtk_tooltips_set_tip (handle, vboxHandle, buffer, null);
+ int /*long*/ data = OS.gtk_tooltips_data_get (vboxHandle);
+ OS.GTK_TOOLTIPS_SET_ACTIVE (handle, data);
+ OS.gtk_tooltips_set_tip (handle, vboxHandle, buffer, null);
+ }
}
- if (autohide) timerId = OS.gtk_timeout_add (DELAY, display.windowTimerProc, handle);
+ if (autohide) timerId = OS.g_timeout_add (DELAY, display.windowTimerProc, handle);
} else {
if ((style & SWT.BALLOON) != 0) {
OS.gtk_widget_hide (handle);
} else {
- int /*long*/ tipWindow = OS.GTK_TOOLTIPS_TIP_WINDOW (handle);
- OS.gtk_widget_hide (tipWindow);
+ int /*long*/ vboxHandle = parent.vboxHandle;
+ byte[] buffer = Converter.wcsToMbcs(null, "", true);
+ if (OS.GTK_VERSION >= OS.VERSION(2, 12, 0)) {
+ OS.gtk_widget_set_tooltip_text(vboxHandle, buffer);
+ } else {
+ OS.gtk_tooltips_set_tip(handle, vboxHandle, buffer, null);
+ }
}
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
index b9558a4b83..44e4b82380 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TrayItem.java
@@ -43,6 +43,7 @@ public class TrayItem extends Item {
int /*long*/ imageHandle;
int /*long*/ tooltipsHandle;
ImageList imageList;
+ Image highlightImage;
/**
* Constructs a new instance of this class given its parent
@@ -220,6 +221,11 @@ public Tray getParent () {
return parent;
}
+public Image getHighlightImage () {
+ checkWidget ();
+ return highlightImage;
+}
+
/**
* Returns the receiver's tool tip, or null if it has
* not been set.
@@ -397,6 +403,7 @@ void releaseWidget () {
if (imageList != null) imageList.dispose ();
imageList = null;
toolTipText = null;
+ highlightImage = null;
}
/**
@@ -451,6 +458,12 @@ public void removeSelectionListener (SelectionListener listener) {
eventTable.unhook (SWT.DefaultSelection, listener);
}
+public void setHighlightImage (Image image) {
+ checkWidget ();
+ if (image != null && image.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+ highlightImage = image;
+}
+
/**
* Sets the receiver's image.
*
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 b607552f4f..a0c060bbd1 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
@@ -274,6 +274,7 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
ptr [0] = 0;
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_PIXBUF, ptr, -1);
OS.g_object_set (cell, OS.pixbuf, ptr[0], 0);
+ OS.g_object_unref (ptr [0]);
} else {
ptr [0] = 0;
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_TEXT, ptr, -1);
@@ -294,6 +295,7 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_BACKGROUND, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.cell_background_gdk, ptr[0], 0);
+ OS.gdk_color_free (ptr [0]);
}
}
}
@@ -302,11 +304,13 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FOREGROUND, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.foreground_gdk, ptr[0], 0);
+ OS.gdk_color_free (ptr [0]);
}
ptr [0] = 0;
OS.gtk_tree_model_get (tree_model, iter, modelIndex + CELL_FONT, ptr, -1);
if (ptr [0] != 0) {
OS.g_object_set (cell, OS.font_desc, ptr[0], 0);
+ OS.pango_font_description_free (ptr [0]);
}
}
}
@@ -435,7 +439,12 @@ int calculateWidth (int /*long*/ column, int /*long*/ iter, boolean recurse) {
}
OS.gtk_widget_style_get(handle, OS.focus_line_width, w, 0);
width += 2 * w [0];
- int /*long*/ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+ int /*long*/ list = 0;
+ if (OS.GTK_VERSION >= OS.VERSION(2, 12, 0)) {
+ list = OS.gtk_cell_layout_get_cells(column);
+ } else {
+ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+ }
if (list == 0) return 0;
int /*long*/ temp = list;
while (temp != 0) {
@@ -584,12 +593,32 @@ void copyModel (int /*long*/ oldModel, int oldStart, int /*long*/ newModel, int
for (int j = 0; j < FIRST_COLUMN; j++) {
OS.gtk_tree_model_get (oldModel, oldItem, j, ptr, -1);
OS.gtk_tree_store_set (newModel, newItem, j, ptr [0], -1);
- if (types [j] == OS.G_TYPE_STRING ()) OS.g_free ((ptr [0]));
+ if (types [j] == OS.G_TYPE_STRING ()) {
+ OS.g_free ((ptr [0]));
+ } else if (ptr[0] != 0) {
+ if (types[j] == OS.GDK_TYPE_COLOR()) {
+ OS.gdk_color_free(ptr[0]);
+ } else if (types[j] == OS.GDK_TYPE_PIXBUF()) {
+ OS.g_object_unref(ptr[0]);
+ } else if (types[j] == OS.PANGO_TYPE_FONT_DESCRIPTION()) {
+ OS.pango_font_description_free(ptr[0]);
+ }
+ }
}
for (int j= 0; j<modelLength - FIRST_COLUMN; j++) {
OS.gtk_tree_model_get (oldModel, oldItem, oldStart + j, ptr, -1);
OS.gtk_tree_store_set (newModel, newItem, newStart + j, ptr [0], -1);
- if (types [j] == OS.G_TYPE_STRING ()) OS.g_free ((ptr [0]));
+ if (types [j] == OS.G_TYPE_STRING ()) {
+ OS.g_free ((ptr [0]));
+ } else if (ptr[0] != 0) {
+ if (types[j] == OS.GDK_TYPE_COLOR()) {
+ OS.gdk_color_free(ptr[0]);
+ } else if (types[j] == OS.GDK_TYPE_PIXBUF()) {
+ OS.g_object_unref(ptr[0]);
+ } else if (types[j] == OS.PANGO_TYPE_FONT_DESCRIPTION()) {
+ OS.pango_font_description_free(ptr[0]);
+ }
+ }
}
}
} else {
@@ -1677,7 +1706,12 @@ public TreeItem getParentItem () {
}
int /*long*/ getPixbufRenderer (int /*long*/ column) {
- int /*long*/ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+ int /*long*/ list = 0;
+ if (OS.GTK_VERSION >= OS.VERSION(2, 12, 0)) {
+ list = OS.gtk_cell_layout_get_cells(column);
+ } else {
+ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+ }
if (list == 0) return 0;
int count = OS.g_list_length (list);
int /*long*/ pixbufRenderer = 0;
@@ -1740,6 +1774,7 @@ public TreeItem[] getSelection () {
length++;
}
OS.g_free (iter);
+ OS.gtk_tree_path_free (data);
}
OS.g_list_free (list);
if (length < count) {
@@ -1817,7 +1852,12 @@ public int getSortDirection () {
}
int /*long*/ getTextRenderer (int /*long*/ column) {
- int /*long*/ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+ int /*long*/ list = 0;
+ if (OS.GTK_VERSION >= OS.VERSION(2, 12, 0)) {
+ list = OS.gtk_cell_layout_get_cells(column);
+ } else {
+ list = OS.gtk_tree_view_column_get_cell_renderers (column);
+ }
if (list == 0) return 0;
int count = OS.g_list_length (list);
int /*long*/ textRenderer = 0;
@@ -2631,7 +2671,10 @@ int /*long*/ rendererRenderProc (int /*long*/ cell, int /*long*/ window, int /*l
int modelIndex = columnCount == 0 ? Tree.FIRST_COLUMN : columns [columnIndex].modelIndex;
OS.gtk_tree_model_get (modelHandle, item.handle, modelIndex + Tree.CELL_BACKGROUND, ptr, -1);
}
- if (ptr [0] != 0) drawState |= SWT.BACKGROUND;
+ if (ptr [0] != 0) {
+ drawState |= SWT.BACKGROUND;
+ OS.gdk_color_free(ptr[0]);
+ }
if ((flags & OS.GTK_CELL_RENDERER_SELECTED) != 0) drawState |= SWT.SELECTED;
if ((flags & OS.GTK_CELL_RENDERER_FOCUSED) != 0) drawState |= SWT.FOCUSED;
@@ -3408,7 +3451,11 @@ void showItem (int /*long*/ path, boolean scroll) {
OS.gtk_tree_view_get_cell_area (handle, path, 0, cellRect);
boolean isHidden = cellRect.y == 0 && cellRect.height == 0;
int [] tx = new int [1], ty = new int [1];
- OS.gtk_tree_view_widget_to_tree_coords (handle, cellRect.x, cellRect.y, tx, ty);
+ if (OS.GTK_VERSION >= OS.VERSION(2, 12, 0)) {
+ OS.gtk_tree_view_convert_widget_to_bin_window_coords(handle, cellRect.x, cellRect.y, tx, ty);
+ } else {
+ OS.gtk_tree_view_widget_to_tree_coords(handle, cellRect.x, cellRect.y, tx, ty);
+ }
GdkRectangle visibleRect = new GdkRectangle ();
OS.gtk_tree_view_get_visible_rect (handle, visibleRect);
if (!isHidden) {
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 c40dea482d..68d8a81a5f 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
@@ -217,6 +217,7 @@ Color _getBackground () {
if (ptr [0] == 0) return parent.getBackground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+ OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -229,6 +230,7 @@ Color _getBackground (int index) {
if (ptr [0] == 0) return _getBackground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+ OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -244,6 +246,7 @@ Color _getForeground () {
if (ptr [0] == 0) return parent.getForeground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+ OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -256,6 +259,7 @@ Color _getForeground (int index) {
if (ptr [0] == 0) return _getForeground ();
GdkColor gdkColor = new GdkColor ();
OS.memmove (gdkColor, ptr [0], GdkColor.sizeof);
+ OS.gdk_color_free (ptr [0]);
return Color.gtk_new (display, gdkColor);
}
@@ -268,6 +272,7 @@ Image _getImage (int index) {
if (ptr [0] == 0) return null;
ImageList imageList = parent.imageList;
int imageIndex = imageList.indexOf (ptr [0]);
+ OS.g_object_unref (ptr [0]);
if (imageIndex == -1) return null;
return imageList.get (imageIndex);
}