changeset 211:00180515eb65

Update to SWT 3.3.2
author Frank Benoit <benoit@tionex.de>
date Wed, 19 Mar 2008 21:36:28 +0100
parents e3472c527a14
children 8ab606c00520
files dwt/custom/CCombo.d dwt/internal/Library.d dwt/internal/gtk/OS.d dwt/printing/Printer.d dwt/widgets/ToolTip.d dwt/widgets/Tree.d
diffstat 6 files changed, 46 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/custom/CCombo.d	Wed Mar 19 20:14:48 2008 +0100
+++ b/dwt/custom/CCombo.d	Wed Mar 19 21:36:28 2008 +0100
@@ -50,6 +50,7 @@
 static import tango.text.convert.Utf;
 static import tango.text.Unicode;
 static import tango.text.convert.Format;
+import dwt.dwthelper.utils;
 
 /**
  * The CCombo class represents a selectable user interface object
@@ -1086,7 +1087,21 @@
             dropDown (false);
             break;
         case DWT.Deactivate:
-            dropDown (false);
+            /*
+             * Bug in GTK. When the arrow button is pressed the popup control receives a
+             * deactivate event and then the arrow button receives a selection event. If
+             * we hide the popup in the deactivate event, the selection event will show
+             * it again. To prevent the popup from showing again, we will let the selection
+             * event of the arrow button hide the popup.
+             */
+            if ("gtk".equals(DWT.getPlatform())) {
+                Point point = arrow.toControl(getDisplay().getCursorLocation());
+                Point size = arrow.getSize();
+                Rectangle rect = new Rectangle(0, 0, size.x, size.y);
+                if (!rect.contains(point)) dropDown (false);
+            } else {
+                dropDown(false);
+            }
             break;
         default:
     }
--- a/dwt/internal/Library.d	Wed Mar 19 20:14:48 2008 +0100
+++ b/dwt/internal/Library.d	Wed Mar 19 21:36:28 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
  * Copyright (c) 2000, 2007 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
@@ -33,7 +33,7 @@
     /**
      * DWT Minor version number (must be in the range 0..999)
      */
-    static const int MINOR_VERSION = 346;
+    static const int MINOR_VERSION = 349;
 
     /**
      * DWT revision number (must be >= 0)
--- a/dwt/internal/gtk/OS.d	Wed Mar 19 20:14:48 2008 +0100
+++ b/dwt/internal/gtk/OS.d	Wed Mar 19 21:36:28 2008 +0100
@@ -1730,6 +1730,7 @@
     mixin ForwardGtkOsCFunc!(.gtk_paper_size_get_width);
     mixin ForwardGtkOsCFunc!(.gtk_paper_size_get_height);
     mixin ForwardGtkOsCFunc!(.gtk_paper_size_is_custom);
+    mixin ForwardGtkOsCFunc!(.gtk_paper_size_free);
     mixin ForwardGtkOsCFunc!(.gtk_plug_get_id);
     mixin ForwardGtkOsCFunc!(.gtk_plug_new);
     mixin ForwardGtkOsCFunc!(.gtk_printer_get_backend);
--- a/dwt/printing/Printer.d	Wed Mar 19 20:14:48 2008 +0100
+++ b/dwt/printing/Printer.d	Wed Mar 19 21:36:28 2008 +0100
@@ -75,6 +75,8 @@
 
     static const char[] GTK_LPR_BACKEND = "GtkPrintBackendLpr"; //$NON-NLS-1$
 
+    static const bool disablePrinting = false;// System.getProperty("dwt.internal.gtk.disablePrinting") !is null; //$NON-NLS-1$
+
 /**
  * Returns an array of <code>PrinterData</code> objects
  * representing all available printers.
@@ -83,7 +85,7 @@
  */
 public static PrinterData[] getPrinterList() {
     printerList = new PrinterData [0];
-    if (OS.GTK_VERSION < OS.buildVERSION (2, 10, 0)) {
+    if (OS.GTK_VERSION < OS.buildVERSION (2, 10, 0) || disablePrinting) {
         return printerList;
     }
     OS.gtk_enumerate_printers(&GtkPrinterFunc_List, null, null, true);
@@ -119,7 +121,7 @@
  */
 public static PrinterData getDefaultPrinterData() {
     printerList = new PrinterData [1];
-    if (OS.GTK_VERSION < OS.buildVERSION (2, 10, 0)) {
+    if (OS.GTK_VERSION < OS.buildVERSION (2, 10, 0) || disablePrinting) {
         return null;
     }
     OS.gtk_enumerate_printers(&GtkPrinterFunc_Default, null, null, true);
@@ -632,7 +634,7 @@
  */
 protected override void create(DeviceData deviceData) {
     this.data = cast(PrinterData)deviceData;
-    if (OS.GTK_VERSION < OS.buildVERSION (2, 10, 0)) DWT.error(DWT.ERROR_NO_HANDLES);
+    if (OS.GTK_VERSION < OS.buildVERSION (2, 10, 0) || disablePrinting) DWT.error(DWT.ERROR_NO_HANDLES);
     printer = gtkPrinterFromPrinterData();
     if (printer is null) DWT.error(DWT.ERROR_NO_HANDLES);
 }
@@ -698,7 +700,7 @@
             paper_size = OS.gtk_paper_size_new(name.ptr);
         }
         OS.gtk_page_setup_set_paper_size(pageSetup, paper_size);
-        OS.g_free(paper_size);
+        OS.gtk_paper_size_free(paper_size);
     }
 
     /* Set values of settings from PrinterData. */
--- a/dwt/widgets/ToolTip.d	Wed Mar 19 20:14:48 2008 +0100
+++ b/dwt/widgets/ToolTip.d	Wed Mar 19 21:36:28 2008 +0100
@@ -677,6 +677,9 @@
     layoutMessage = null;
     if (message.length !is 0) {
         layoutMessage = OS.gtk_widget_create_pango_layout (handle, toStringz( message ));
+        if (OS.GTK_VERSION >= OS.buildVERSION (2, 4, 0)) {
+            OS.pango_layout_set_auto_dir (layoutMessage, false);
+        }
         OS.pango_layout_set_wrap (layoutMessage, OS.PANGO_WRAP_WORD_CHAR);
     }
     if (OS.GTK_WIDGET_VISIBLE (handle)) configure ();
@@ -704,6 +707,9 @@
     layoutText = null;
     if (text.length !is 0) {
         layoutText = OS.gtk_widget_create_pango_layout (handle, toStringz(text));
+        if (OS.GTK_VERSION >= OS.buildVERSION (2, 4, 0)) {
+            OS.pango_layout_set_auto_dir (layoutText, false);
+        }
         auto boldAttr = OS.pango_attr_weight_new (OS.PANGO_WEIGHT_BOLD);
         boldAttr.start_index = 0;
         boldAttr.end_index = text.length+1;
--- a/dwt/widgets/Tree.d	Wed Mar 19 20:14:48 2008 +0100
+++ b/dwt/widgets/Tree.d	Wed Mar 19 21:36:28 2008 +0100
@@ -2310,6 +2310,21 @@
     */
     auto selection = OS.gtk_tree_view_get_selection (handle);
     OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udCHANGED);
+    /*
+    * Bug in GTK.  In version 2.8, when gtk_tree_view_set_model() is called, GTK
+    * does not remove the timer used to show animation when expanding a node. This
+    * can cause two possible crashes. The first one happens when the timer expires and
+    * it accesses the expanding node which has been already destroyed. The second one
+    * happens if a new item is created and destroyed before the timer expires. The fix
+    * is to remove the timer by disposing the first item in the tree.
+    */
+    if (OS.GTK_VERSION < OS.buildVERSION(2, 10, 0)) {
+        if (OS.gtk_tree_model_iter_n_children (modelHandle, null) !is 0) {
+            GtkTreeIter iter;
+            OS.gtk_tree_model_iter_nth_child (modelHandle, &iter, null, 0);
+            OS.gtk_tree_store_remove (modelHandle, &iter);
+        }
+    }
     // TODO verify if true for tree store
     //OS.gtk_tree_store_clear (modelHandle);
     auto oldModel = modelHandle;