Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 17 Sep 2019, 15:04
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Gtkdialog calendar widget - sort of
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [12 Posts]  
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 1897
Location: Japan

PostPosted: Sun 13 Jan 2019, 05:55    Post subject:  Gtkdialog calendar widget - sort of  

Recent threads here and here covered the (busybox) cal command and attempts to replace this tool or find a meaningful purpose for it. I always wondered why this little tool even exists as I could never see a reason to use this CLI calendar. I finally do.

There are plenty of GUI based calendars and most of them use the GtkCalendar widget. Dialog programs like Xdialog and yad support it with their --calendar options. Not so gtkdialog. Though most standard dialogs like file chooser, font chooser and color picker are implemented, the calendar dialog is not.

I therefore tried to construct a gtkdialog based calendar, as a replacement for igucal, the program that pops up when I click on the clock in the JWM tray. Igucal is a variant of minixcal. Both are stable, simple and boring. I need a calendar that can be customized with additional functions.

Below is a barebone version of this exercise. The calendar does nothing more that show the current day and can be used as a first step for a more sophisticated version. It is designed to be opened and closed by clicking on the JWM clock but of course can be opened in any other way. It basically displays the output of the cal command. The script does not use tmp files. All tmp values are kept in hidden text widgets. The script also uses no button widgets, instead makes use of entry widgets and their primary/secondary buttons. Finally I restricted the mark for the current day on the current month/year. In GtkCalendar the day keeps marked even when month or year are changed. I find this odd.
mm_cal.gz
Description  Version 2019-01-30
To run script: Unzip script and make executable
gz

 Download 
Filename  mm_cal.gz 
Filesize  1.53 KB 
Downloaded  122 Time(s) 
tray_calendars.png
 Description   
 Filesize   43.58 KB
 Viewed   516 Time(s)

tray_calendars.png


Last edited by MochiMoppel on Wed 30 Jan 2019, 06:50; edited 1 time in total
Back to top
View user's profile Send private message 
some1

Joined: 17 Jan 2013
Posts: 100

PostPosted: Sun 13 Jan 2019, 08:00    Post subject:  

MM: I had a hunch/hope you would implement a calendar in GTKDIALOG. We need that.

Perhaps also a dropdown/notebook-calendar -variant.

I will take a look at the proto/barebone
---
Back to top
View user's profile Send private message 
goingnuts

Joined: 07 Dec 2008
Posts: 918

PostPosted: Sun 13 Jan 2019, 16:27    Post subject:  

For inspiration: I played with the calendar widget and posted source here.
Source is gtk1 though... Smile
Back to top
View user's profile Send private message Visit poster's website 
wiak

Joined: 11 Dec 2007
Posts: 1718
Location: not Bulgaria

PostPosted: Mon 14 Jan 2019, 01:06    Post subject:  

goingnuts wrote:
For inspiration: I played with the calendar widget and posted source here.
Source is gtk1 though... Smile


I wish I hadn't found myself just downloading that source code... I'm worried I will decide not to retire from further programming afterall. The problem is, I feel that Puppy Linux in particular tends to use little C programs that are not otherwise well-maintained or supported, or only by their sole authors (such as JWM, ROX-Filer etc, mtpaint, and gtkdialog). I feel therefore that the more Puppy members that take the time to learn a bit C programming (with some, but not a lot Gtk-related knowledge) the better - but... so much effort goes into bash-only (with gtkdialog/yad scripting for gui); if only some of these scripters would put in even a little of their time to mastering a bit C/gtk then they could help future-proof these efficient little C/gtk programs (I'm sure some of these quite expert scripters could be equally good at C/GTK fiddling). I did a little core C-related stuff, but could (should?) have done more, whilst I was able (in terms of maintaining the C skills required..., which I tend to forget over medium-short time alas). Still, I love seeing a bit activity in this C/gtk-related area continuing here on the forum; I notice from other post that work still being done on ROX-filer too, though only one contributer to that too it seems. Team projects naturally inspire more longterm confidence so many thanks to those Puppyists out their that keep the C-programming flags flying!

Anyway, I'm too happy to be out of the programming mindset - have much more time for other pursuits obviously; still, programming was a bit of a drug/stimulant (though feedback not always exactly complimentary or encouraging - some negative attitudes out there too sadly; why? Shouldn't really need encouragement, I suppose... Smile and some feedback very polite and encouraging anyway! Thanks, especially when my own efforts/results were often very much less than perfect... Wink ).

wiak
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1897
Location: Japan

PostPosted: Sun 27 Jan 2019, 04:46    Post subject:  

some1 wrote:
Perhaps also a dropdown/notebook-calendar -variant.

Frankly, I have no clue what you have in mind. Maybe you can explain.

Speaking of "dropdown": I just want to mention that the GtkCalendar widget (the one in Xdialog, yad, igucal etc.) allows drag&drop of dates. Don't know if many people have noticed that. Individual dates in the calendar can not only be clicked (which makes little sense for the current tray calendars), they can also be dragged out and dropped into another application. The dragged date is formatted according to the locale's date representation (e.g., 01/27/2019). This is a trick that my poor-man's calendar is unable to do.

Another feature not implement in mm_cal are the the grayed out dates of the preceding and following month. It wouldn't be impossible but I figured that the considerable amount of code required is not worth the result. I suspect that their main purpose is to fill the gaps rather than being useful. A full 2 months calendar may be more useful and probably easier to achieve.
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 6587
Location: Valåmoen, Norway

PostPosted: Sun 27 Jan 2019, 12:45    Post subject:  

Great stuff MochiMoppel!
I've made a link in the tips and tricks thread.

Thank you!

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1897
Location: Japan

PostPosted: Mon 28 Jan 2019, 23:44    Post subject:  

You're welcome and thanks for the link.

Now a shock Shocked : Today I discovered that I can't switch the calendar label to February. Now it's "Jan" and it is supposed to switch to "Feb" when I click on the arrow button, but it switches to "Mar". Calendar is updated correctly to February and other labels work fine, only "Feb" doesn't work. Strange because I swear it worked before. Is it only me?

The problem is the busybox date command. In line 39
It is supposed to convert a month number to the locale's abbreviated month name. Works for all numbers - except the number 2:
    # busybox date -d 1 -D %m +%b
    Jan
    # busybox date -d 2 -D %m +%b
    Mar
    # busybox date -d 3 -D %m +%b
    Mar
    # busybox date -d 4 -D %m +%b
    Apr

What's going on here?

Before someone asks: The reason why I use busybox date is the nice -D option, which is not available in the GNU date version. However it is possible to use GNU date and it even works correctly, so I will change the command once I have confirmed that it is indeed a busybox bug.

[Edit] With different options busybox seems to work fine:
    # busybox date -d 1999-1-1 -D %F +%b
    Jan
    # busybox date -d 1999-2-1 -D %F +%b
    Feb
    # busybox date -d 1999-3-1 -D %F +%b
    Mar
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1731

PostPosted: Tue 29 Jan 2019, 07:12    Post subject:  

It seems that when you're using %m alone, the day is automatically assumed to be today and since there is no 2019-02-29:
Quote:
# busybox date -d 1 -D %m
Tue Jan 29 00:00:00 CET 2019
#
# busybox date -d 2 -D %m
Fri Mar 1 00:00:00 CET 2019
#
# busybox date -d 3 -D %m
Fri Mar 29 00:00:00 CET 2019
#

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1897
Location: Japan

PostPosted: Tue 29 Jan 2019, 07:24    Post subject:  

Exclamation Thanks SFR.
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1897
Location: Japan

PostPosted: Tue 29 Jan 2019, 23:30    Post subject:  

The problem I see with busybox date is that it tends to convert unrecognized formats into unpredictable dates instead of honestly reporting an "invalid date" error:
    # date -d "1999-2-1"
    Mon Feb 1 00:00:00 JST 1999
    # busybox date -d "1999-2-1"
    Tue Oct 6 21:59:00 JST 2020
    # busybox date -d "1999-100"
    Tue Oct 6 23:00:00 JST 2020
    # busybox date -d "1999-99"
    date: invalid date '1999-99'


I think I'll settle for a format that is acceptable to busybox and GNU versions alike. This should work even in cases when date is symlinked to busybox:
    # date -d "1999-1-1 00:00" +%b
    Jan
    # date -d "1999-2-1 00:00" +%b
    Feb
    # date -d "1999-3-1 00:00" +%b
    Mar
I have updated the script accordingly (see initial post).
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 3667
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Sat 02 Feb 2019, 07:02    Post subject:  

Hello,
Thank you MochiMoppel!
Just for fun: displaying your calendar as desktop application using gtk2desklet...

Cordialement.
190202_120024_230x177_easyshot.jpg
 Description   
 Filesize   6.41 KB
 Viewed   155 Time(s)

190202_120024_230x177_easyshot.jpg


_________________

A second life for your PCs...
Back to top
View user's profile Send private message Visit poster's website 
don570


Joined: 10 Mar 2010
Posts: 5345
Location: Ontario

PostPosted: Mon 04 Feb 2019, 19:45    Post subject:  

mm_cal.gz worked in Tazpuppy beta19 with gtkdialog 0.8.4

________________________________________________
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [12 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0794s ][ Queries: 13 (0.0147s) ][ GZIP on ]