Morning devs, I implemented this patchsome days ago and tested it.
It is a complete rewrite of the -updateClock method for the ClockMenulet. Basically it does the same things of the old code, but in a cleaner way (12 effective lines of code), easiest and updated to the recent gnustep-base code; it also add the short name of the actual week day to the menu in the right (calendar zone) the format is: <week day name> <number of the month day> <HH:mm> If you like this patch and accept it, I can patch the code and commit to the svn. Cheers, Alex -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Index: ClockMenulet.m =================================================================== --- ClockMenulet.m (revisione 8406) +++ ClockMenulet.m (copia locale) @@ -130,47 +130,20 @@ - (void) updateClock { - NSCalendarDate * date; - int newHour, newMinute, newDay; - - date = [NSCalendarDate calendarDate]; - - // only redraw every minute - newHour = [date hourOfDay]; - newMinute = [date minuteOfHour]; - newDay = [date dayOfWeek]; - if (hour != newHour || minute != newMinute || day != newDay) - { - BOOL useAmPmTime = [[NSUserDefaults standardUserDefaults] - boolForKey: @"UseAMPMTimeIndication"]; - - hour = newHour; - minute = newMinute; - day = newDay; - - if (useAmPmTime) - { - int h = hour; - - if (h == 0) - { - h = 12; - } - else if (h > 12) - { - h -= 12; - } - - [view setTitle: [NSString stringWithFormat: - _(@"%@ %d:%02d %@"), ShortNameOfDay(day), h, minute, - AMPMStringForHour(hour)]]; - } - else - { - [view setTitle: [NSString stringWithFormat: _(@"%@ %d:%02d"), - ShortNameOfDay(day), hour, minute]]; - } - } + NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; + NSDateFormatter *form = [[NSDateFormatter alloc] init]; + NSDate * date = [NSDate date]; + NSDateComponents *dateComponents = [gregorian components:NSWeekdayCalendarUnit fromDate:date]; + + NSInteger weekDayNum = [dateComponents weekday]; + [form setDateFormat:@"dd/MM/yyyy HH:mm"]; + NSArray *shortDayName = [form shortWeekdaySymbols]; + NSString *strDate = [NSDateFormatter localizedStringFromDate:date dateStyle:NSDateFormatterNoStyle timeStyle:NSDateFormatterShortStyle]; + NSString *dayNum = [form stringFromDate:date]; + [view setTitle: [NSString stringWithFormat:@"%@ %@ %@", [shortDayName objectAtIndex:weekDayNum], [dayNum substringToIndex:2], strDate]]; + + [gregorian release]; + [form release]; } - (NSView *) menuletView
clock_menulet.patch
Description: Binary data
_______________________________________________ Etoile-dev mailing list Etoile-dev@gna.org https://mail.gna.org/listinfo/etoile-dev