aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2012-01-20 04:45:30 (EST)
committerSilenio Quarti2012-01-20 15:36:04 (EST)
commit4fe8da6f2bab6d03a443071a684658611aa5499d (patch)
treee1559641f2c7e37cca36c29076347c04211e00b3
parentc69b73f0b1a48a3d225d1f35f97c4b2441e4986f (diff)
downloadeclipse.platform.swt-4fe8da6f2bab6d03a443071a684658611aa5499d.zip
eclipse.platform.swt-4fe8da6f2bab6d03a443071a684658611aa5499d.tar.gz
eclipse.platform.swt-4fe8da6f2bab6d03a443071a684658611aa5499d.tar.bz2
Kill pre GTK 2.4 leftovers from Tree.
Code is not used and just keeps calls to deprecated functions in GTK.
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java142
1 files changed, 14 insertions, 128 deletions
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 a0c060b..1fa150e 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
@@ -240,29 +240,6 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
if (modelIndex == -1) return 0;
boolean setData = false;
if ((style & SWT.VIRTUAL) != 0) {
- /*
- * Feature in GTK. On GTK before 2.4, fixed_height_mode is not
- * supported, and the tree asks for the data of all items. The
- * fix is to only provide the data if the row is visible.
- */
- if (OS.GTK_VERSION < OS.VERSION (2, 3, 2)) {
- int /*long*/ path = OS.gtk_tree_model_get_path (tree_model, iter);
- OS.gtk_widget_realize (handle);
- GdkRectangle visible = new GdkRectangle ();
- OS.gtk_tree_view_get_visible_rect (handle, visible);
- GdkRectangle area = new GdkRectangle ();
- OS.gtk_tree_view_get_cell_area (handle, path, tree_column, area);
- OS.gtk_tree_path_free (path);
- if (area.y + area.height < 0 || area.y + visible.y > visible.y + visible.height ) {
- /* Give an image from the image list to make sure the row has
- * the correct height.
- */
- if (imageList != null && imageList.size () > 0) {
- if (isPixbuf) OS.g_object_set (cell, OS.pixbuf, imageList.getPixbuf (0), 0);
- }
- return 0;
- }
- }
if (!item.cached) {
//lastIndexOf = index [0];
setData = checkData (item);
@@ -285,18 +262,12 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo
}
}
if (customDraw) {
- /*
- * Bug on GTK. Gtk renders the background on top of the checkbox and pixbuf.
- * This only happens in version 2.2.1 and earlier. The fix is not to set the background.
- */
- if (OS.GTK_VERSION > OS.VERSION (2, 2, 1)) {
- if (!ownerDraw) {
- ptr [0] = 0;
- 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]);
- }
+ if (!ownerDraw) {
+ ptr [0] = 0;
+ 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]);
}
}
if (!isPixbuf) {
@@ -688,7 +659,7 @@ void createColumn (TreeColumn column, int index) {
* Use GTK_TREE_VIEW_COLUMN_GROW_ONLY on GTK versions < 2.3.2
* because fixed_height_mode is not supported.
*/
- boolean useVirtual = (style & SWT.VIRTUAL) != 0 && OS.GTK_VERSION >= OS.VERSION (2, 3, 2);
+ boolean useVirtual = (style & SWT.VIRTUAL) != 0 ;
if (!useVirtual && columnCount == 0) {
OS.gtk_tree_view_column_set_sizing (columnHandle, OS.GTK_TREE_VIEW_COLUMN_GROW_ONLY);
} else {
@@ -756,10 +727,7 @@ void createHandle (int index) {
OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp);
if ((style & SWT.BORDER) != 0) OS.gtk_scrolled_window_set_shadow_type (scrolledHandle, OS.GTK_SHADOW_ETCHED_IN);
if ((style & SWT.VIRTUAL) != 0) {
- /* The fixed_height_mode property only exists in GTK 2.3.2 and greater */
- if (OS.GTK_VERSION >= OS.VERSION (2, 3, 2)) {
- OS.g_object_set (handle, OS.fixed_height_mode, true, 0);
- }
+ OS.g_object_set (handle, OS.fixed_height_mode, true, 0);
}
if (!searchEnabled ()) {
/*
@@ -870,19 +838,8 @@ void createRenderers (int /*long*/ columnHandle, int modelIndex, boolean check,
if ((style & SWT.CHECK) != 0 && check) {
OS.gtk_tree_view_column_pack_start (columnHandle, checkRenderer, false);
OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.active, CHECKED_COLUMN);
- /*
- * Feature in GTK. The inconsistent property only exists in GTK 2.2.x.
- */
- if (OS.GTK_VERSION >= OS.VERSION (2, 2, 0)) {
- OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.inconsistent, GRAYED_COLUMN);
- }
- /*
- * Bug in GTK. GTK renders the background on top of the checkbox.
- * This only happens in version 2.2.1 and earlier. The fix is not to set the background.
- */
- if (OS.GTK_VERSION > OS.VERSION (2, 2, 1)) {
- if (!ownerDraw) OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
- }
+ OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.inconsistent, GRAYED_COLUMN);
+ if (!ownerDraw) OS.gtk_tree_view_column_add_attribute (columnHandle, checkRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
if (ownerDraw) {
OS.gtk_tree_view_column_set_cell_data_func (columnHandle, checkRenderer, display.cellDataProc, handle, 0);
OS.g_object_set_qdata (checkRenderer, Display.SWT_OBJECT_INDEX1, columnHandle);
@@ -927,15 +884,9 @@ void createRenderers (int /*long*/ columnHandle, int modelIndex, boolean check,
/* Add attributes */
OS.gtk_tree_view_column_add_attribute (columnHandle, pixbufRenderer, OS.pixbuf, modelIndex + CELL_PIXBUF);
- /*
- * Bug on GTK. Gtk renders the background on top of the pixbuf.
- * This only happens in version 2.2.1 and earlier. The fix is not to set the background.
- */
- if (OS.GTK_VERSION > OS.VERSION (2, 2, 1)) {
- if (!ownerDraw) {
- OS.gtk_tree_view_column_add_attribute (columnHandle, pixbufRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
- OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
- }
+ if (!ownerDraw) {
+ OS.gtk_tree_view_column_add_attribute (columnHandle, pixbufRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
+ OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.cell_background_gdk, BACKGROUND_COLUMN);
}
OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.text, modelIndex + CELL_TEXT);
OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, OS.foreground_gdk, FOREGROUND_COLUMN);
@@ -1108,28 +1059,6 @@ void destroyItem (TreeColumn column) {
void destroyItem (TreeItem item) {
- /*
- * Bug in GTK. GTK segment faults when a root tree item
- * is destroyed when the tree is expanded and the last leaf of
- * the root is selected. This only happens in versions earlier
- * than 2.0.6. The fix is to collapse the tree item being destroyed
- * when it is a root, before it is destroyed.
- */
- if (OS.GTK_VERSION < OS.VERSION (2, 0, 6)) {
- int length = OS.gtk_tree_model_iter_n_children (modelHandle, 0);
- if (length > 0) {
- int /*long*/ iter = OS.g_malloc (OS.GtkTreeIter_sizeof ());
- boolean valid = OS.gtk_tree_model_iter_children (modelHandle, iter, 0);
- while (valid) {
- if (item.handle == iter) {
- item.setExpanded (false);
- break;
- }
- valid = OS.gtk_tree_model_iter_next (modelHandle, iter);
- }
- OS.g_free (iter);
- }
- }
int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CHANGED);
OS.gtk_tree_store_remove (modelHandle, item.handle);
@@ -1747,20 +1676,7 @@ int /*long*/ getPixbufRenderer (int /*long*/ column) {
public TreeItem[] getSelection () {
checkWidget();
int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
- if (OS.GTK_VERSION < OS.VERSION (2, 2, 0)) {
- display.treeSelectionLength = 0;
- display.treeSelection = new int [items.length];
- OS.gtk_tree_selection_selected_foreach (selection, display.treeSelectionProc, handle);
- TreeItem [] result = new TreeItem [display.treeSelectionLength];
- for (int i=0; i<result.length; i++) result [i] = items [display.treeSelection [i]];
- return result;
- }
- /*
- * Bug in GTK. gtk_tree_selection_get_selected_rows() segmentation faults
- * in versions smaller than 2.2.4 if the model is NULL. The fix is
- * to give a valid pointer instead.
- */
- int /*long*/ [] model = OS.GTK_VERSION < OS.VERSION (2, 2, 4) ? new int /*long*/ [1] : null;
+ int /*long*/ [] model = null;
int /*long*/ list = OS.gtk_tree_selection_get_selected_rows (selection, model);
if (list != 0) {
int count = OS.g_list_length (list);
@@ -1800,12 +1716,6 @@ public TreeItem[] getSelection () {
public int getSelectionCount () {
checkWidget();
int /*long*/ selection = OS.gtk_tree_view_get_selection (handle);
- if (OS.GTK_VERSION < OS.VERSION (2, 2, 0)) {
- display.treeSelectionLength = 0;
- display.treeSelection = null;
- OS.gtk_tree_selection_selected_foreach (selection, display.treeSelectionProc, handle);
- return display.treeSelectionLength;
- }
return OS.gtk_tree_selection_count_selected_rows (selection);
}
@@ -2041,25 +1951,6 @@ int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ eventPtr) {
int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
int /*long*/ result = super.gtk_key_press_event (widget, eventPtr);
if (result != 0) return result;
- if (OS.GTK_VERSION < OS.VERSION (2, 2 ,0)) {
- /*
- * Feature in GTK 2.0.x. When an item is default selected using
- * the return key, GTK does not issue notification. The fix is
- * to issue this notification when the return key is pressed.
- */
- GdkEventKey keyEvent = new GdkEventKey ();
- OS.memmove (keyEvent, eventPtr, GdkEventKey.sizeof);
- int key = keyEvent.keyval;
- switch (key) {
- case OS.GDK_Return:
- case OS.GDK_KP_Enter: {
- Event event = new Event ();
- event.item = getFocusItem ();
- sendSelectionEvent (SWT.DefaultSelection, event, false);
- break;
- }
- }
- }
return result;
}
@@ -3163,11 +3054,6 @@ void setParentWindow (int /*long*/ widget) {
void setScrollWidth (int /*long*/ column, TreeItem item) {
if (columnCount != 0 || currentItem == item) return;
- /*
- * Use GTK_TREE_VIEW_COLUMN_GROW_ONLY on GTK versions < 2.3.2
- * because fixed_height_mode is not supported.
- */
- if (((style & SWT.VIRTUAL) != 0) && OS.GTK_VERSION < OS.VERSION (2, 3, 2)) return;
int width = OS.gtk_tree_view_column_get_fixed_width (column);
int itemWidth = calculateWidth (column, item.handle, true);
if (width < itemWidth) {