From 4fe8da6f2bab6d03a443071a684658611aa5499d Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Fri, 20 Jan 2012 11:45:30 +0200 Subject: Kill pre GTK 2.4 leftovers from Tree. Code is not used and just keeps calls to deprecated functions in GTK. --- .../gtk/org/eclipse/swt/widgets/Tree.java | 142 ++------------------- 1 file 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 a0c060bbd1..1fa150e0ed 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