Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 394534 - Rewrite DateTime on top of GtkSpinButton
Summary: Rewrite DateTime on top of GtkSpinButton
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.3   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 4.5 M3   Edit
Assignee: Leo Ufimtsev CLA
QA Contact: Sravan Kumar Lakkimsetti CLA
URL:
Whiteboard:
Keywords:
: 399548 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-11-18 09:41 EST by Alexander Kurtakov CLA
Modified: 2018-07-25 04:28 EDT (History)
7 users (show)

See Also:


Attachments
SWT.DROP_DOWN button too big in new code. (8.05 KB, image/png)
2014-09-15 15:22 EDT, Leo Ufimtsev CLA
no flags Details
SWT.DROP_DOWN button size fix. Remaining issue is text field size. (69.64 KB, image/png)
2014-09-17 12:28 EDT, Leo Ufimtsev CLA
no flags Details
SWT.DROP_DOWN_BUTTON in text(entry) field. (80.64 KB, image/png)
2014-09-19 15:55 EDT, Leo Ufimtsev CLA
no flags Details
snippet (2.05 KB, text/x-java)
2014-10-07 08:14 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details
screenshot with the attached snippet in GTK3 (12.01 KB, image/png)
2014-10-07 08:15 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Kurtakov CLA 2012-11-18 09:41:48 EST
Rewriting DateTime on top of GtkSpinButton for the Date and Time (not Calendar) will allow to not taking care of creating buttons, managing them, manually adding accessibility and etc.
The key part will be to set gtk_spin_button_set_numeric(handle, false) so the spin button will not assume it deals with numeric data. Adapting the current listeners to become handlers for [key|button]_[press|release] events should be the other part. 
Silenio, should we go that route? This is provoked by the Gtk3 port where having the up and down arrows one above the other makes it look alien because the default spinners in gtk 3 use the one next to other arrangement of the buttons.
Comment 1 Silenio Quarti CLA 2012-11-20 11:18:32 EST
I like the idea. But it is quite a bit of work.

Carolyn, have we consider using GtkSpinButton before? Do you think there is any technical reason this would not work.
Comment 2 Carolyn MacLeod CLA 2012-11-20 12:02:50 EST
As far as I remember, we didn't try using GtkSpinButton for the GTK port of DateTime. I think it was probably because, at the time, it was easier to reuse completely emulated DateTime code for all platforms that did not have a native DateTime control (Motif, Carbon, GTK, Photon, ...)

Alexander, if you want to rewrite it, I would be happy to review and test it.
FYI, there are JUnit tests in org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_DateTime that you should run when you are ready. Feel free to add new JUnit tests as needed.
Comment 3 Anatoly Spektor CLA 2012-12-13 15:55:41 EST
(In reply to comment #2)
> As far as I remember, we didn't try using GtkSpinButton for the GTK port of
> DateTime. I think it was probably because, at the time, it was easier to
> reuse completely emulated DateTime code for all platforms that did not have
> a native DateTime control (Motif, Carbon, GTK, Photon, ...)
> 
> Alexander, if you want to rewrite it, I would be happy to review and test it.
> FYI, there are JUnit tests in
> org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_DateTime that you
> should run when you are ready. Feel free to add new JUnit tests as needed.

Hello Carolyn, Silenio and Alexander,

I've done some work on rewriting Datetime on top of GtkSpinButton.

I would be glad if you could take a look at my implementation and maybe, if you have time, help me to solve some issues that I am stuck with.

My implementation (work in progress) can be found here:

 http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=datetime_on_spinbutton

2 main issues I am facing right now are:

1. When spinning anything using ARROW KEYS (UP and DOWN) except first segment (hour or day)  - error-noise appears. When spinning with + - noise does not occur. From my findings I think that it could be connected with value of spin-button that does not change when you spin anything except the first segment. I have tried changing the value and changing the adjustment of spin_button when user spins other segments, it does not gave me the right results. If you could take a look and maybe propose something regarding this issue, I will appreciate it a lot !

Steps to Replicate:
a. Run Snippet 250
b. Using Up and Down arrows spin second or third field (day, year,seconds,minutes)
You should hear Error-sound.

2. When mouse clicking on the segment, it does not gets Selected right away and when one-digit value is currently selected, mouse selection  of other fields does not work at all. What I noticed is that my method getSelection(), which I replicated from Text.widget. in method "OS.gtk_editable_get_selection_bounds (handle, start, end);" (line 1608) produces different values then original DateTime widget (calling Text.widget). I think I am missing something crucial there, if you could take a look at this as well, I would highly appreciate it.

Steps to Replicate:
a. Run Snippet 250
b. Mouse click on the second or third field
In working DateTime its gets selected right away. 

I would be glad to get overall feedback from you regarding my solution.

Thanks for your time,

Anatoly
Comment 4 Alexander Kurtakov CLA 2013-01-15 09:44:50 EST
Carolyn, do you plan reviewing the patch ?
Comment 5 Grant Gayed CLA 2013-01-30 15:26:10 EST
*** Bug 399548 has been marked as a duplicate of this bug. ***
Comment 6 Carolyn MacLeod CLA 2013-02-07 14:25:04 EST
Arun is going to look at this.
Comment 7 Anatoly Spektor CLA 2013-04-09 08:53:50 EDT
(In reply to comment #6)
> Arun is going to look at this.

Cool, Arun, could you please provide me with the feedback when you will take a look at the code ?

Thanks
Comment 8 Anatoly Spektor CLA 2013-06-20 12:31:00 EDT
I have resolved "error-sound" issue in my patch. I have also re-based the patch, so it has all the changes that currently is in master. 


It still needs some work in regards to highlighting parts of the DateTime when mouse is clicked on it.

If you find any other issues please let me know.

Here is an updated patch:

http://fedorapeople.org/cgit/aspektor/public_git/eclipse.platform.swt.git/commit/?h=datetime_on_spinner_v2
Comment 9 Alexander Kurtakov CLA 2014-07-04 03:55:51 EDT
Work done for Red Hat rebased on current master is available in Gerrit now.
https://git.eclipse.org/r/#/c/29442/
Comment 10 Leo Ufimtsev CLA 2014-09-05 17:10:19 EDT
I tested things and found some issues. 

Also Sami suggested I should differentiate the behaviour depending on whether GTK2 & GTK3 is used by the environment.
If GTK2 is used, use old code.
If GTK3 is used, use new code.

I'll work on this. 

↓↓↓↓ Details ↓↓↓↓

No error sounds, but there were selection issues and a peculiar crash situation. 

With the Date/Time, there was issues selecting some fields with the mouse. (but things work well by keyboard). 

DateTime crashes upon style changes.  (SWT.DATE -> SWT.TIME). 


↓↓↓↓ The *gory* details ↓↓↓↓

#### DATE  (Mouse Selection Problem)
. Steps to reproduce:
  - Launch "Date" module 
  - click on 'month'
  - try clicking on 'year'
. Result:
  - Expected : 'year' should be selected
  - Actual : selection jumps to year and then flicks back to month

### TIME  (Mouse Selection Problem)
. Steps to reproduce:
   - Launch "time"
   - Select 'Hour' 
   - try to click seconds 
Result:
   - Expected: seconds are selected 
   - Acutal : seconds is briefly selected, then selection jumps back to hours.

### DATE/TIME Notes 
 - All of the above work without issues in current master
 - Missbehaving under both GTK2/GTK3 environment. 
 - No issues with keyboard navigation

Also... 
### SWT.DATE to SWT.TIME switch in ControlExample crashes under GTK3
. Steps to reproduce 
  - Configure launch to use Environmental Variable: "SWT_GTK3=1"
  - Launch ControlExample.java  (org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ControlExample.java)
  - Click on "DateTime" tab 
  - Change style from SWT.DATE to SWT.TIME
Result:
  - Expected: widget turns into a "Time" widget.
  - Actual: Crash: 
       Exception in thread "main" java.lang.NullPointerException
	  at org.eclipse.swt.widgets.DateTime.getHours(DateTime.java:577)
	  at org.eclipse.swt.widgets.DateTime.getArrow(DateTime.java:1539)
          ....
          at org.eclipse.swt.examples.controlexample.ControlExample.main(ControlExample.java:222)
Comment 11 Sravan Kumar Lakkimsetti CLA 2014-09-09 07:02:05 EDT
This feature requires more in-depth code changes and testing. in multiple GTK platforms like GTK2, GTK3.4, GTK3.8 and GTK3.10. It requires some more effort fixing this issue. So we are moving this to milestone 3.
Comment 12 Arun Thondapu CLA 2014-09-12 11:43:21 EDT
(In reply to Leo Ufimtsev from comment #10)
> I tested things and found some issues. 
> 
> Also Sami suggested I should differentiate the behaviour depending on
> whether GTK2 & GTK3 is used by the environment.
> If GTK2 is used, use old code.
> If GTK3 is used, use new code.
> 
> I'll work on this. 

Are you planning to submit a patch for this (just to confirm so that someone else is also not looking at it at the same time)?
Comment 13 Leo Ufimtsev CLA 2014-09-12 11:44:10 EDT
Yes, I'm working on a patch. 

I've fixed the selection issue, now I'm looking into the crash issue. 

Please hold on :-)
Comment 14 Leo Ufimtsev CLA 2014-09-15 15:22:37 EDT
Created attachment 247088 [details]
SWT.DROP_DOWN button too big in new code.

I fixed the selection issue and the crash issue, submitted new patch (#3):
https://git.eclipse.org/r/#/c/29442/

Now controlExample doesn't crash under no combination of selections. 

I also ran the JUnit test cases:
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_DateTime
They all worked. 


The current Open tasks are as following: 
1) Button Size:
Now I noticed that if you have SWT.DATE and SWT.DROP_DOWN as style, then the drop-down button is too large (see picture attached).
I'll investigate. 

2) Test under: 
GTK2, GTK3.4, GTK3.8 and GTK3.10
Comment 15 Leo Ufimtsev CLA 2014-09-17 12:28:28 EDT
Created attachment 247161 [details]
SWT.DROP_DOWN button size fix. Remaining issue is text field size.

I fixed the SWT.DROP_DOWN button size issue (see attached). 
The fix was to take into account gtk padding in gtk3.  
See patchset #6:
https://git.eclipse.org/r/#/c/29442/

With that and the crash issue fixed, I noticed that when SWT.DROP_DOWN is enabled, then the down.arrow is placed "on top" of the gtkSpinButton instead of next to it (as was the case before this patch). 
This creates the problem that when you select it, you can see that the blue boarder goes underneath the button. (please see attached picture)

If I move the button to the right:
#onResize():~1436 down.setBounds(width - buttonSize.x **+20**) ..... )
and shrink the text field size:
#computeSize(): ~296: width = trim.width + buttonSize.x **-20**;
Then the button is 'cut off' from view. (e.g only half of it is visible). 

I'm trying to figure out how to fix it. 
It might be some boundary is cutting it off or maybe the gtk margin. Still investigating. 


TODO SUMMARY:
1) Fix SWT.DROP_DOWN button placement.
2) Test on: GTK2, GTK3.4, GTK3.8 and GTK3.10
Comment 16 Leo Ufimtsev CLA 2014-09-19 15:55:06 EDT
Created attachment 247251 [details]
SWT.DROP_DOWN_BUTTON in text(entry) field.

Contrary to my comment above, I noticed that DatePickers often had the SWT.DROP_DOWN button inside the text field. 
However, the SWT.DROP_DOWN button was small enough so that the border was still visible when the control was selected. 

E.g Eclipse DateTime:
Ubuntu:  https://www.eclipse.org/swt/R3_7/images/gtk-datetime.png
Windows: https://www.eclipse.org/swt/R3_5/images/datetime-dropdown.png 

I liked this idea and implemented the code to mimic that look. (for both gtk2/gtk3).
Please see attached screen shot. 

TODO SUMMARY:
- Test on: GTK2, GTK3.10 GTK3.4, GTK3.8   (in progress)
Comment 17 Leo Ufimtsev CLA 2014-09-22 10:36:27 EDT
I found some more issues:
- Numberpad input does not work. 
  (This issue is specific to this patch. Works in master)

- Vertical Layout fill breaks in Gtk3
  I.e, when you run ControlExample and select "VerticalFill", 
  the button(s) become large but the entry field stays the same size. 
  (this issue is gtk3 specific. It works in gtk2 but not in gtk3 on both patch & master). 

TODO SUMMARY:
- Fix Numberpad input issue in patch      (in progress)
- Fix Vertical Layout issue in gtk3       (in progress)
- Test on: GTK2, GTK3.10 GTK3.4, GTK3.8   (in progress)
Comment 18 Leo Ufimtsev CLA 2014-09-22 14:58:31 EDT
Fixed numberpad digits input issue. #patchset 9

TODO SUMMARY:
- Fix Vertical Layout issue in gtk3       (in progress)
- Test on: GTK2, GTK3.10 GTK3.4, GTK3.8   (in progress)
Comment 19 Leo Ufimtsev CLA 2014-09-22 15:07:10 EDT
Also noticed numberpad Arrow-buttons didn't work (when numberpad lock is turned off). Patched that up along the way as well.  #Patch set 10.
Comment 20 Leo Ufimtsev CLA 2014-09-26 16:48:37 EDT
↓↓↓↓ SUMMARY  ↓↓↓↓
------------------
 - Fixed Drop_down button size if Vertical_fill enabled (gtk3)
 - Fixed popup calendar if vertical fill enabled (gtk3)

However, while testing under gtk2/3 I found selection and crash issues with SWT.Calendar.
I will work on this now.


↓↓↓↓ DETAILS ↓↓↓↓
-----------------
I investigated the vertical fill issue. 

In native Gtk3, GtkEntry and GtkSpinButton do not resize vertically if inside a container because they are not container derivatives. They don't have a 'vertical resize' method. It seems they are designed to be single-line fields.
Here is a screenshot of native C code to illustrate:
https://raw.githubusercontent.com/LeoUfimtsev/gitPicStore/master/ScreenShot_2014_09_24__17_00_47_gtk3_native_code.png

The same behaviour is observed in other SWT controls using GtkEntry or GtkSpinButton. For example in ControlExample's Spinner. 

Technically it's possible to hack-around this by overriding setBounds & calling OS.gtk_widget_set_size_request(..), but this causes the control to lose it's native 'preffered size' and causes issues with it shrinking when needed.

Based on the investigation above, I decided to keep it a one-liner when running in GTK3 as per GTK3's implementation of GtkEntry/GtkSpinButton.
When Vertical-Fill is enabled, the control is moved to the center of the container. 

However, I did fix the size of the Drop_down position and the position of the popup calendar.

Before:
https://raw.githubusercontent.com/LeoUfimtsev/gitPicStore/master/ScreenShot_2014_09_26__16_09_38_.png

After
https://raw.githubusercontent.com/LeoUfimtsev/gitPicStore/master/ScreenShot_2014_09_26__16_08_46_.png

---------------

I compiled GTK2.24/Gtk3.4/Gtk3.8/Gtk3.10 from sources and did some detailed testing. 
All JUnit tests pass so far.

However, I came across the following issues: 
 . Under GTK2: 
  - calendar crashes if horizontal_fill is enabled 
  - popup calendar (from SWT.DROP_DOWN) is not clickable 
    (It just goes away when hovering mouse over it).

 . Under GTK3:
  - Calendar is not clickable if Vertical_fill is enabled. 
    (days shift to the bottom and nothing happens when clicked on).
    (this is not related to this patch, it occurs in master also).

TODO SUMMARY (in Progress):
 - Fix Calendar Crash issue when horizontal fill is enabled (GTK2)
 - Fix Calendar popup disappearance with DROP_DOWN Button (GTK2)
 - Fix SWT.CALENDAR not-clickable with Vertical_fill (GTK3) 
 - Retest all GTK2.24, GTK3.4, GTK3.8, GTK3.10
Comment 21 Leo Ufimtsev CLA 2014-09-30 14:51:02 EDT
In regards to:
> "SWT.CALENDAR not-clickable with Vertical_fill GKT3"
This was caused by a native GTK3 problem. 
I.e, it occurs with native Gtk3 C code. 

I submitted a gtk3 bug with code to reproduce it:
https://bugzilla.gnome.org/show_bug.cgi?id=737670

In the mean time for versions (Gtk3.0 - Gtk3.fixed), I wrote a workaround. I overrode the setBounds(int,int,int,int) method and prevent the control from expanding beyond it's native-preferred size. 
https://git.eclipse.org/r/#/c/29442/    #patch set 12

I submitted an eclipse-bugzilla bug to have this workaround addressed once the gkt side of it is fixed:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=445539


TODO SUMMARY (in Progress):
 - Fix Calendar Crash issue when horizontal fill is enabled (GTK2)
 - Fix Calendar popup disappearance with DROP_DOWN Button (GTK2)
 - Retest all GTK2.24, GTK3.4, GTK3.8, GTK3.10
Comment 22 Leo Ufimtsev CLA 2014-09-30 15:34:36 EDT
I fixed the Calendar crash issue upon Horizontal stretching in GTK2. 

The computeTrim(..) method was overriden by the patch to compute trim for the Entry-Widget. 
However, it was also called if the 'calendar' style was used and crashed.

I added a guard to fix it.

TODO SUMMARY (in Progress):
 - Fix Calendar popup disappearance with DROP_DOWN Button (GTK2)
 - Retest all GTK2.24, GTK3.4, GTK3.8, GTK3.10
Comment 23 Leo Ufimtsev CLA 2014-10-01 14:09:47 EDT
Fixed the popup calendar disappearance issue in GTK2 and made the calendar actually disappear when mouse exit's it's surface area in GTK3. 

(There were broken focus-out handlers.)

This prevents the behavior of having the control be still visible if you click on another window.

However, I noticed this patch introduces some GLib warnings in the console that don't occur in the master branch. 

Warning on launch:
(SWT:29550): GLib-GObject-CRITICAL **: g_closure_add_invalidate_notifier: assertion 'closure->n_inotifiers < CLOSURE_MAX_N_INOTIFIERS' failed

Warning on Exit:
(SWT:29550): GLib-GObject-WARNING **: gclosure.c:697: unable to remove uninstalled invalidation notifier: 0x3b8bc20330 (0x7f2a4cf3d490)

I need to fix these.

TODO SUMMARY (in Progress):
 - Fix Glib warnings 
 - Retest all GTK2.24, GTK3.4, GTK3.8, GTK3.10
Comment 24 Leo Ufimtsev CLA 2014-10-02 11:51:16 EDT
I fixed the error messages that were popping up in the console. 

These were basically the same as:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=407077

I.e, change the hooks to match the new getClosure(..., ) call.

TODO SUMMARY (in Progress):
 - Retest all GTK2.24, GTK3.4, GTK3.8, GTK3.10
Comment 25 Leo Ufimtsev CLA 2014-10-03 14:57:13 EDT
I found issues with Right_to_left alignment when drop_down button is used. Been working on fixing it.

TODO SUMMARY (in Progress):
 - Fix right_to_left issue 
 - Re-factor for cleanliness 
 - Retest all GTK2.24, GTK3.4, GTK3.8, GTK3.10
Comment 26 Sravan Kumar Lakkimsetti CLA 2014-10-07 08:14:23 EDT
Created attachment 247674 [details]
snippet
Comment 27 Sravan Kumar Lakkimsetti CLA 2014-10-07 08:15:28 EDT
Created attachment 247675 [details]
screenshot with the attached snippet in GTK3
Comment 28 Sravan Kumar Lakkimsetti CLA 2014-10-07 08:15:58 EDT
Hi Leo,

I am testing on GTK3.10. Here are the problems I noticed
1. current date is not highlighted when the calendar is opened for the first time in both calendar style and dropdown style
2. there is no blue background for the selected date in both Calender syle and dropdown style
3. in GTK3 dropdown button doesnot have any icon
4. if the dropdown calendar window is opened the dropdown gets closed as soon as the mouse hovers over another widget. this doesnot happen in the previous version.

The following are not problems but kind of improvements. 
1. in date time field I fell it is better to pad day and month field to two digits. that is for september month instead of 9 I think it is better to show 09. same thing can be done for hours field
2. in GTK3 the date time widget with dropdown style is slightly lower in position

I am attaching the screenshot and the snippet I am using here

Thanks and Regards,
Sravan
Comment 29 Leo Ufimtsev CLA 2014-10-07 09:58:08 EDT
Hello Sravan, 

Thank you very much for taking the time to test things and write out the points you made. 

I will work on making the improvements.
Comment 30 Leo Ufimtsev CLA 2014-10-14 15:24:31 EDT
------ SUMMARY 
I rewrote the container logic for Date with SWT.DROP_DOWN. 
It now uses a native GTK container. 

To my knowledge, I addressed all the issues I was aware off (see below). 

As this is a relativley large change, I retested everytihng on various gtk versions (2.4, 3.8/3.10) and 
I ran all the unit tests in test_org_eclipse_swt_widgets_DateTime.java. All work. 
Unless more problems are disscovred, I think we're good to go?

@Sravan:
Would you have time to retest the latest and greatest? 

Gerrit review:
https://git.eclipse.org/r/#/c/29442/



------- DETAILS

Now the SWT.Drop_down button is once again *next* to the entry field. 
https://raw.githubusercontent.com/LeoUfimtsev/gitPicStore/master/ScreenShot_2014_10_14__10_37_58_.png
This fixes the Right_to_left issue and various other size/positioning issues.

> 4. if the dropdown calendar window is opened the dropdown gets closed as soon as the mouse hovers over another widget.
I removed the mouseExit filter that triggered this behavior. 

> 3. in GTK3 drop_down button does not have any icon
I think it did have an icon, but because the DROP_DOWN button was 
so small that the arrow was probably not visable. 
The re-write of the container logic expanded the button's vertical size
and the arrow is now visable again. Here is a screen shot of a compiled gtk3.10
https://raw.githubusercontent.com/LeoUfimtsev/gitPicStore/master/ScreenShot_2014_10_09__16_42_08_.png


@@@@ Sravan
>1. current date is not highlighted when the calendar is opened for the first time in both calendar style and dropdown style
>2. there is no blue background for the selected date in both Calender syle and dropdown style
I think this might be specific to the styling properties of a "compiled" GTK3.10 with no theaming. 

I can reproduce the behaviour on my machine. 
With a native Fedora 20 GTK3.10, the day is marked in blue, business as usual. 
With a compiled GTK3.10 the day is not 'visably marked as you described. 
Here is a screenshot. 
https://raw.githubusercontent.com/LeoUfimtsev/gitPicStore/master/ScreenShot_2014_10_09__17_04_05_.png

For comparison, this is what your snippet looks like with native Fedora GTK:
https://raw.githubusercontent.com/LeoUfimtsev/gitPicStore/master/ScreenShot_2014_10_09__17_22_43_.png

The same behaviour is observed in Master. With compiled GTK day is not visable, with OS-native GTK that has styling it is visable. 

I.e, if I am not mistaken, this is fixed by applying styling/theaming to gtk itself.
Thoughts? 

In theory, GTK's Calendar constructor marks the day upon calendar creation:
  https://developer.gnome.org/gtk3/stable/GtkCalendar.html#gtk-calendar-new
  "Creates a new calendar, with the current date being selected". 

But if you think this is not correct, please let me know. 


IMPROVEMENTS 
>1 - Add '0' padding. 
Yea, I noticed it looked a bit perculiar. I added padding to month/hour/day. Looks like this now:
https://raw.githubusercontent.com/LeoUfimtsev/gitPicStore/master/ScreenShot_2014_10_10__12_18_11_.png

> Position of spinner/drop_down entry 
Trim was not computed for spinButton thus it's position was different from entry with drop_down. 
I.e, it wasn't Entry/Drop_down that was out of place but the spinButton.
I added trim computation for SpinButton (for GTK3 only, in Gtk2 spinButton with trim looks broken). 
Now it looks ok:
https://raw.githubusercontent.com/LeoUfimtsev/gitPicStore/master/ScreenShot_2014_10_14__14_05_17_.png
Comment 31 Sravan Kumar Lakkimsetti CLA 2014-10-16 09:57:50 EDT
Hi Leo,

Thank you for padding the month, day, hours and minutes. This looks nice.

 There are some problems I noticed while testing the spinner for date.

1. Highlighting of the today's date is not happening. when you launch calendar widget, current day should be in bold. (please review my comment added to code in gerrit. that should solve this)

2. in date style when I am clicking on +/up button to increment day, it actually decrementing in some specific cases

Use case:
- using spinner buttons change the date to 10/31/2014
- decrement month to 09(september which has only 30 days). here the date becomes 09/31/2014 (actually this is invalid date. I think we should not allow this)
- Now try to increment day from 31. in the fist click nothing happens and from the second click onwards the date starts decrementing
- now try to decrent the day using the spinner controls. it will decrement by 2.


The other problems I noticed in GTK 3.10. these are not there in gtk 2.24

1. the blue background for selected day in the month in calendar and dropdown is not there
2. the icon on the dropdown button is showing up as a dot

Thanks
Sravan
Comment 32 Leo Ufimtsev CLA 2014-10-23 12:10:41 EDT
------ SUMMARY 
Hello Sravan, 

I've addressed the issues you've outlined. See patch-set #22.

Please let me know your thoughts, if you find any further issuer or wherther you think we're good to go.




------- DETAILS
>1) Day highlighting:
Thank you for your feedback and code review. I incorporated the fix.

>2) Date incorrect incrementation:
Thank you for finding such a perculiar bug. 
I rewrote the way the date is updated. It now writes into the java Calendar and then takes it's value to write back into entry field. 
Java's Calendar does date validation. (decrementing a 31 month to a 30 day month now resets the day). It also handles leap years correctly. 


## Gtk3.10 theme issues. 
>1) No background on selected day:
I've done some research on the matter.
From what I gather, this is dependent on the underlying gtk3 theme that you use.
There is a disscussion on the same problem here:
https://github.com/dmedvinsky/gsimplecal/issues/20

I've done some extra testing. 
First I've compiled gtk_3.10 without themeing like this:
  ./autogen.sh 
  ./configure --enable-x11-backend --enable-wayland-backend 
  make
As a result, the selected day on the calendar does not have a background.

Then I compiled gtk_3.10, but I set it to use my system gtk configuration which has themeing:
  ./autogen.sh 
  ./configure --prefix=/usr --sysconfdir=/etc --enable-broadway-backend --enable-x11-backend --disable-wayland-backend
  make
Then the calendar's day has a blue background. 
(left compiled with themeing, right compiled without themeing)
https://raw.githubusercontent.com/LeoUfimtsev/gitPicStore/master/ScreenShot_2014_10_23__09_48_06_.png

(I wrote a blog post on compiling gtk3 if of use:
http://coffeeorientedprogramming.wordpress.com/2014/09/29/how-to-compile-various-gtk3-versions-and-run-eclipse-apps-with-those/
)

As a note, on an unthemed gtk, there is still a dotted-box drawn around the selection:
https://raw.githubusercontent.com/LeoUfimtsev/gitPicStore/master/gtkCal_oct2014.png

Technically I could hard-code a color, or hard code a color if the color is white, 
but this would break themes like black and white and high contrast themes:
http://gnome-look.org/content/show.php/Black-n-White-GTK?content=149636

I.e, I think the solution is to apply themeing to gtk. 

Thoughts?

> 2) the icon on the dropdown button is showing up as a dot
I think it's not a dot, but a small down arrow.
This is gtk theme and size dependent. If you make DateTime bigger or use another theme, then the arrow is bigger. 
E.g Adwaita theme:
https://raw.githubusercontent.com/LeoUfimtsev/gitPicStore/master/ScreenShot_2014_10_23__12_03_35_DT_DD.png

Underneath I'm using a regular SWT button:
Button(shell, SWT.ARROW | SWT.DOWN);

Thoughts?
Comment 33 Sravan Kumar Lakkimsetti CLA 2014-10-28 08:29:47 EDT
the code has been pushed to master https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=358e077459326bfde3a675b949aa20349d21bc3d