### Eclipse Workspace Patch 1.0 #P org.eclipse.swt Index: Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java,v retrieving revision 1.549 diff -u -r1.549 OS.java --- Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java 2 Feb 2010 10:56:40 -0000 1.549 +++ Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java 24 Feb 2010 14:35:35 -0000 @@ -2058,6 +2058,16 @@ lock.unlock(); } } +/** @param time cast=(GTimeVal *) */ +public static final native void _g_get_current_time(int[] /*long*/ time); +public static final void g_get_current_time (int[] /*long*/ time) { + lock.lock(); + try { + _g_get_current_time(time); + } finally { + lock.unlock(); + } +} /** @method flags=dynamic */ public static final native int /*long*/ _g_icon_to_string(int /*long*/ icon); public static final int /*long*/ g_icon_to_string (int /*long*/ icon) { @@ -14924,4 +14934,14 @@ lock.unlock(); } } +/** @param time cast=(const time_t *) */ +public static final native int _localtime(int[] /*long*/ time); +public static final int localtime(int[] /*long*/ time) { + lock.lock(); + try { + return _localtime(time); + } finally { + lock.unlock(); + } +} } Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java,v retrieving revision 1.42 diff -u -r1.42 DateTime.java --- Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java 23 Oct 2009 19:36:54 -0000 1.42 +++ Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java 24 Feb 2010 14:35:35 -0000 @@ -252,6 +252,7 @@ } else { OS.gtk_calendar_display_options(handle, OS.GTK_CALENDAR_SHOW_HEADING | OS.GTK_CALENDAR_SHOW_DAY_NAMES); } + hours = minutes = seconds = -1; } else { super.createHandle(index); } @@ -382,7 +383,13 @@ public int getHours () { checkWidget (); if ((style & SWT.CALENDAR) != 0) { - return hours; + if (hours != -1) return hours; + int[] t_time = new int[2]; + OS.g_get_current_time (t_time); + int /*long*/ time = OS.localtime (t_time); + int[] dest = new int[9]; + OS.memmove(dest, time, 9 * 4); + return dest[2]; } else { return calendar.get(Calendar.HOUR_OF_DAY); } @@ -404,7 +411,13 @@ public int getMinutes () { checkWidget (); if ((style & SWT.CALENDAR) != 0) { - return minutes; + if (minutes != -1) return minutes; + int[] t_time = new int[2]; + OS.g_get_current_time (t_time); + int /*long*/ time = OS.localtime (t_time); + int[] dest = new int[9]; + OS.memmove(dest, time, 9 * 4); + return dest[1]; } else { return calendar.get(Calendar.MINUTE); } @@ -454,7 +467,13 @@ public int getSeconds () { checkWidget (); if ((style & SWT.CALENDAR) != 0) { - return seconds; + if (seconds != -1) return seconds; + int[] t_time = new int[2]; + OS.g_get_current_time (t_time); + int /*long*/ time = OS.localtime (t_time); + int[] dest = new int[9]; + OS.memmove(dest, time, 9 * 4); + return dest[0]; } else { return calendar.get(Calendar.SECOND); } Index: Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java,v retrieving revision 1.46 diff -u -r1.46 DateTime.java --- Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java 23 Oct 2009 19:24:37 -0000 1.46 +++ Eclipse SWT/win32/org/eclipse/swt/widgets/DateTime.java 24 Feb 2010 14:35:35 -0000 @@ -186,6 +186,7 @@ TCHAR lpszFormat = new TCHAR (0, buffer, true); OS.SendMessage (handle, OS.DTM_SETFORMAT, 0, lpszFormat); } + if ((this.style & SWT.CALENDAR) != 0) time.wHour = time.wMinute = time.wSecond = -1; } /** @@ -568,10 +569,9 @@ */ public int getHours () { checkWidget (); - if ((style & SWT.CALENDAR) != 0) return time.wHour; + if ((style & SWT.CALENDAR) != 0 && time.wHour != -1) return time.wHour; SYSTEMTIME systime = new SYSTEMTIME (); - int msg = (style & SWT.CALENDAR) != 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, OS.DTM_GETSYSTEMTIME, 0, systime); return systime.wHour; } @@ -590,10 +590,9 @@ */ public int getMinutes () { checkWidget (); - if ((style & SWT.CALENDAR) != 0) return time.wMinute; + if ((style & SWT.CALENDAR) != 0 && time.wMinute != -1) return time.wMinute; SYSTEMTIME systime = new SYSTEMTIME (); - int msg = (style & SWT.CALENDAR) != 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, OS.DTM_GETSYSTEMTIME, 0, systime); return systime.wMinute; } @@ -638,10 +637,9 @@ */ public int getSeconds () { checkWidget (); - if ((style & SWT.CALENDAR) != 0) return time.wSecond; + if ((style & SWT.CALENDAR) != 0 && time.wSecond != -1) return time.wSecond; SYSTEMTIME systime = new SYSTEMTIME (); - int msg = (style & SWT.CALENDAR) != 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; - OS.SendMessage (handle, msg, 0, systime); + OS.SendMessage (handle, OS.DTM_GETSYSTEMTIME, 0, systime); return systime.wSecond; }