merge of '405ed6c43e365446c1163c52c1a434ed0a270e85'
[vuplus_openembedded] / packages / swt / files / swt-hildon.patch
1 Index: swt/swt-source/make_linux.mak
2 ===================================================================
3 --- swt.orig/swt-source/make_linux.mak  2007-06-20 12:01:22.000000000 +0200
4 +++ swt/swt-source/make_linux.mak       2008-02-14 11:32:49.000000000 +0100
5 @@ -45,8 +45,8 @@
6  CAIROLIBS = `pkg-config --libs-only-L cairo` -lcairo
7  
8  # Do not use pkg-config to get libs because it includes unnecessary dependencies (i.e. pangoxft-1.0)
9 -GTKCFLAGS = `pkg-config --cflags gtk+-2.0`
10 -GTKLIBS = `pkg-config --libs-only-L gtk+-2.0 gthread-2.0` -lgtk-x11-2.0 -lgthread-2.0 -L/usr/X11R6/lib $(XLIB64) -lXtst
11 +GTKCFLAGS = `pkg-config --cflags gtk+-2.0 hildon-1 hildon-fm-2`
12 +GTKLIBS = -lhildon-1 -lhildonfm `pkg-config --libs-only-L gtk+-2.0 gthread-2.0` -lgtk-x11-2.0 -lgthread-2.0 -L/usr/X11R6/lib $(XLIB64) -lXtst
13  
14  CDE_LIBS = -L$(CDE_HOME)/lib -R$(CDE_HOME)/lib -lXt -lX11 -lDtSvc
15  
16 @@ -74,8 +74,6 @@
17         -Wno-non-virtual-dtor \
18         -fPIC \
19         -I. \
20 -       -I$(JAVA_HOME)/include \
21 -       -I$(JAVA_HOME)/include/linux \
22         ${SWT_PTR_CFLAGS}
23  MOZILLALIBS = -shared -Wl,--version-script=mozilla_exports -Bsymbolic
24  MOZILLAEXCLUDES = -DNO_XPCOMGlueShutdown -DNO_XPCOMGlueStartup
25 @@ -96,8 +94,6 @@
26                 -DSWT_VERSION=$(SWT_VERSION) \
27                 $(NATIVE_STATS) \
28                 -DLINUX -DGTK \
29 -               -I$(JAVA_HOME)/include \
30 -               -I$(JAVA_HOME)/include/linux \
31                 -fPIC \
32                 ${SWT_PTR_CFLAGS}
33  LIBS = -shared -fPIC
34 Index: swt/swt-source/os.c
35 ===================================================================
36 --- swt.orig/swt-source/os.c    2007-10-30 16:24:28.000000000 +0100
37 +++ swt/swt-source/os.c 2008-02-14 09:32:49.000000000 +0100
38 @@ -17,6 +17,9 @@
39  #include "os_structs.h"
40  #include "os_stats.h"
41  
42 +#include <hildon/hildon-program.h>
43 +#include <hildon/hildon-window.h>
44 +
45  #define OS_NATIVE(func) Java_org_eclipse_swt_internal_gtk_OS_##func
46  
47  #ifndef NO_Call
48 @@ -7015,9 +7018,18 @@
49  JNIEXPORT void JNICALL OS_NATIVE(_1gtk_1container_1add)
50         (JNIEnv *env, jclass that, jint arg0, jint arg1)
51  {
52 +  GtkContainer *container = (GtkContainer *) arg0;
53 +  GtkWidget *widget = (GtkWidget *) arg1;
54         OS_NATIVE_ENTER(env, that, _1gtk_1container_1add_FUNC);
55 -       gtk_container_add((GtkContainer *)arg0, (GtkWidget *)arg1);
56 -       OS_NATIVE_EXIT(env, that, _1gtk_1container_1add_FUNC);
57 +  if (GTK_CHECK_TYPE (widget, GTK_TYPE_MENU)
58 +      && !strcmp(gtk_menu_get_title(GTK_MENU(widget)), "__main_menu__"))
59 +  {
60 +    hildon_window_set_menu(HILDON_WINDOW(container), GTK_MENU(widget));
61 +  }
62 +  else
63 +   gtk_container_add((GtkContainer *)arg0, (GtkWidget *)arg1);
64 +
65 +   OS_NATIVE_EXIT(env, that, _1gtk_1container_1add_FUNC);
66  }
67  #endif
68  
69 @@ -9121,9 +9133,12 @@
70  JNIEXPORT jint JNICALL OS_NATIVE(_1gtk_1menu_1bar_1new)
71         (JNIEnv *env, jclass that)
72  {
73 +  GtkWidget *menu;
74         jint rc = 0;
75         OS_NATIVE_ENTER(env, that, _1gtk_1menu_1bar_1new_FUNC);
76 -       rc = (jint)gtk_menu_bar_new();
77 +       menu = gtk_menu_new();
78 +  gtk_menu_set_title(menu, "__main_menu__");
79 +       rc = (jint) menu;
80         OS_NATIVE_EXIT(env, that, _1gtk_1menu_1bar_1new_FUNC);
81         return rc;
82  }
83 @@ -15464,8 +15479,23 @@
84         (JNIEnv *env, jclass that, jint arg0)
85  {
86         jint rc = 0;
87 +  HildonProgram *p;
88 +  GtkWidget *w;
89         OS_NATIVE_ENTER(env, that, _1gtk_1window_1new_FUNC);
90 -       rc = (jint)gtk_window_new((GtkWindowType)arg0);
91 +/*
92 +  if (GTK_WINDOW_TOPLEVEL == (GtkWindowType) arg0)
93 +  {
94 +*/
95 +    p = hildon_program_get_instance();
96 +    w = hildon_window_new();
97 +    hildon_program_add_window(p, HILDON_WINDOW(w));
98 +/*    gtk_window_fullscreen(GTK_WINDOW(w));*/
99 +/*
100 +  }
101 +  else
102 +    w = gtk_window_new(GTK_WINDOW_POPUP);
103 +*/
104 +       rc = (jint) w;
105         OS_NATIVE_EXIT(env, that, _1gtk_1window_1new_FUNC);
106         return rc;
107  }
108 Index: swt/swt-source/org/eclipse/swt/widgets/Menu.java
109 ===================================================================
110 --- swt.orig/swt-source/org/eclipse/swt/widgets/Menu.java       2007-05-31 18:03:50.000000000 +0200
111 +++ swt/swt-source/org/eclipse/swt/widgets/Menu.java    2008-02-14 09:05:04.000000000 +0100
112 @@ -259,9 +259,17 @@
113         if ((style & SWT.BAR) != 0) {
114                 handle = OS.gtk_menu_bar_new ();
115                 if (handle == 0) error (SWT.ERROR_NO_HANDLES);
116 +               if (parent instanceof Shell)
117 +               {
118 +               int /*long*/ shellHandle = ((Shell) parent).shellHandle;
119 +               OS.gtk_container_add (shellHandle, handle);
120 +               }
121 +               else
122 +               {
123                 int /*long*/ vboxHandle = parent.vboxHandle;
124                 OS.gtk_container_add (vboxHandle, handle);
125                 OS.gtk_box_set_child_packing (vboxHandle, handle, false, true, 0, OS.GTK_PACK_START);
126 +               }
127         } else {
128                 handle = OS.gtk_menu_new ();
129                 if (handle == 0) error (SWT.ERROR_NO_HANDLES);
130 Index: swt/swt-source/org/eclipse/swt/internal/gtk/OS.java
131 ===================================================================
132 --- swt.orig/swt-source/org/eclipse/swt/internal/gtk/OS.java    2007-10-30 16:06:36.000000000 +0100
133 +++ swt/swt-source/org/eclipse/swt/internal/gtk/OS.java 2008-02-14 09:05:04.000000000 +0100
134 @@ -471,6 +471,11 @@
135         public static final byte[] window_state_event = ascii("window-state-event");
136         
137         /** Properties */
138 +  /* Maemo hildon specific - border added due to toolbar */
139 +  public static final byte[] toolbar_borders = ascii("toolbar-borders");
140 +  /* Maemo hildon specific - border added due to skin graphics area */
141 +  public static final byte[] borders = ascii("borders");
142 +
143         public static final byte[] active = ascii("active");
144         public static final byte[] background_gdk = ascii("background-gdk");
145         public static final byte[] button_relief = ascii("button-relief");
146 Index: swt/swt-source/org/eclipse/swt/widgets/Shell.java
147 ===================================================================
148 --- swt.orig/swt-source/org/eclipse/swt/widgets/Shell.java      2007-11-01 11:31:12.000000000 +0100
149 +++ swt/swt-source/org/eclipse/swt/widgets/Shell.java   2008-02-14 10:51:37.000000000 +0100
150 @@ -1028,6 +1028,14 @@
151  int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) {
152         int width = OS.GTK_WIDGET_WIDTH (shellHandle);
153         int height = OS.GTK_WIDGET_HEIGHT (shellHandle);
154 +
155 +       if (!fullScreen)
156 +       {
157 +               GtkBorder b = getMaemoBorder(false);
158 +               width -= (b.left + b.right);
159 +               height -= (b.top + b.bottom);
160 +       }
161 +
162         if (!resized || oldWidth != width || oldHeight != height) {
163                 oldWidth = width;
164                 oldHeight = height;
165 @@ -1384,14 +1392,53 @@
166         if ((state & FOREIGN_HANDLE) != 0) return;
167         Monitor monitor = getMonitor ();
168         Rectangle rect = monitor.getClientArea ();
169 +/*
170         int width = rect.width * 5 / 8;
171         int height = rect.height * 5 / 8;
172 +*/
173 +
174 +       int width = rect.width;
175 +       int height = rect.height;
176 +
177 +  // Instead of some arbitrary defaults we can use the complete "application
178 +  // area" on the maemo platform.
179 +       if (!fullScreen)
180 +       {
181 +               GtkBorder b = getMaemoBorder(false);
182 +               width -= (b.left + b.right);
183 +               height -= (b.top + b.bottom);
184 +       }
185 +
186         if ((style & SWT.RESIZE) != 0) {
187                 OS.gtk_window_resize (shellHandle, width, height);
188         }
189         resizeBounds (width, height, false);
190  }
191  
192 +/**
193 + * Retrieves the "borders" or "toolbar-borders" property
194 + * from the Shell.
195 + *
196 + * That is neccessary to calculate correct Shell sizes on
197 + * the Maemo platform.
198 + *
199 + */
200 +private GtkBorder getMaemoBorder(boolean wantToolbarBorder)
201 +{
202 +  GtkBorder b = new GtkBorder();
203 +
204 +  int /*long*/ [] result = new int /*long*/[1];
205 +  OS.gtk_widget_style_get(shellHandle,
206 +                          (wantToolbarBorder ? OS.toolbar_borders
207 +                                             : OS.borders),
208 +                          result, 0);
209 +
210 +  if (result[0] != 0)
211 +    OS.memmove(b, result[0], GtkBorder.sizeof);
212 +
213 +  return b;
214 +}
215 +
216  public void setMaximized (boolean maximized) {
217         checkWidget();
218         super.setMaximized (maximized);
219 Index: swt/swt-source/os_custom.c
220 ===================================================================
221 --- swt.orig/swt-source/os_custom.c     2007-05-31 18:04:22.000000000 +0200
222 +++ swt/swt-source/os_custom.c  2008-02-14 13:55:49.000000000 +0100
223 @@ -13,6 +13,8 @@
224  *     IBM Corporation - initial API and implementation
225  *******************************************************************************/
226  
227 +#include <hildon/hildon-file-chooser-dialog.h>
228 +
229  #include "swt.h"
230  #include "os_structs.h"
231  #include "os_stats.h"
232 @@ -41,11 +43,22 @@
233  {
234         jbyte *lparg0=NULL;
235         SWT_PTR rc = 0;
236 +       GtkWidget *widget = NULL;
237         OS_NATIVE_ENTER(env, that, _1gtk_1file_1chooser_1dialog_1new_FUNC);
238         if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
239  /*
240         rc = (SWT_PTR)gtk_file_chooser_dialog_new(lparg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
241  */
242 +       /* Remaining arguments are thrown away as they cannot be used for the
243 +        * HildonFileChooserDialog anyways.
244 +        */
245 +       widget = (SWT_PTR) hildon_file_chooser_dialog_new(arg1, (GtkFileChooserAction) arg2);
246 +  gtk_window_set_title(GTK_WINDOW(widget), (const gchar *) lparg0);
247 +
248 +  rc = (SWT_PTR) widget;
249 +#if 0
250 +// The code is not supposed to run on AMD64.
251 +
252         {
253                 static int initialized = 0;
254                 static void *handle = NULL;
255 @@ -70,6 +83,8 @@
256                         rc = (SWT_PTR)(*fptr)(lparg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
257                 }
258         }
259 +#endif
260 +
261  fail:
262         if (arg0 && lparg0) (*env)->ReleaseByteArrayElements(env, arg0, lparg0, 0);
263         OS_NATIVE_EXIT(env, that, _1gtk_1file_1chooser_1dialog_1new_FUNC);