[haiku-development] Desbar patch
- From: Julun <HOST.HAIKU@xxxxxx>
- To: haiku-development@xxxxxxxxxxxxx
- Date: Fri, 19 Oct 2007 01:02:07 +0200
Hi,
i would like to ask if the Deskbar maintainer could review my patch, so
that there isn't an oversight before applying them to the code.
basically i added a 3rd time format to be consistent with Tracker +
handling the messages. because of the pixel exact laying out for
replicants, it can't show the proper short iso date.
otherwise it works fine so far, except saving the applied settings from
within time prefs...
thx,
Julun
Index: TimeView.h
===================================================================
--- TimeView.h (revision 22598)
+++ TimeView.h (working copy)
@@ -43,8 +43,10 @@
const uint32 kMsgMilTime = 'MilT';
const uint32 kMsgFullDate = 'FDat';
const uint32 kMsgEuroDate = 'EDat';
+#ifdef __HAIKU__
+const uint32 kMsgIsoDate = 'IDat';
+#endif
-
#ifdef AS_REPLICANT
class _EXPORT TTimeView;
#endif
@@ -83,6 +85,11 @@
bool ShowingEuroDate() {return fEuroDate; }
void ShowEuroDate(bool);
+#ifdef __HAIKU__
+ bool ShowingIsoDate() const { return fIsoDate; }
+ void ShowIsoDate(bool show);
+#endif
+
bool Orientation() const;
void SetOrientation(bool o);
@@ -123,6 +130,10 @@
bool fOrientation; // vertical = true
BPoint fTimeLocation;
BPoint fDateLocation;
+
+#ifdef __HAIKU__
+ bool fIsoDate;
+#endif
};
Index: BarApp.h
===================================================================
--- BarApp.h (revision 22598)
+++ BarApp.h (working copy)
@@ -111,6 +111,9 @@
bool superExpando; // version 9
bool expandNewTeams;
bool autoRaise; // version 10
+#ifdef __HAIKU__
+ bool timeIsoDate; // version 11
+#endif
};
// the following structures are defined to compute
@@ -126,6 +129,9 @@
const uint32 kValidSettingsSize8 = 2 * sizeof(bool) + kValidSettingsSize7;
const uint32 kValidSettingsSize9 = 2 * sizeof(bool) + kValidSettingsSize8;
const uint32 kValidSettingsSize10 = sizeof(bool) + kValidSettingsSize9;
+#ifdef __HAIKU__
+const uint32 kValidSettingsSize11 = sizeof(bool) + kValidSettingsSize10;
+#endif
class TBarView;
class BFile;
Index: BeMenu.cpp
===================================================================
--- BeMenu.cpp (revision 22598)
+++ BeMenu.cpp (working copy)
@@ -304,6 +304,8 @@
TReplicantTray *replicantTray = ((TBarApp
*)be_app)->BarView()->fReplicantTray;
+#ifndef __HAIKU__
+ // these are now handled in time prefs
item = new BMenuItem("24 Hour Clock", new BMessage(kMsgMilTime));
item->SetTarget(replicantTray);
item->SetEnabled(((TBarApp *)be_app)->BarView()->ShowingClock());
@@ -321,6 +323,7 @@
item->SetEnabled(((TBarApp *)be_app)->BarView()->ShowingClock());
item->SetMarked(replicantTray->ShowingEuroDate());
subMenu->AddItem(item);
+#endif
item = new BMenuItem("Full Date", new BMessage(kMsgFullDate));
item->SetTarget(replicantTray);
Index: StatusView.cpp
===================================================================
--- StatusView.cpp (revision 22598)
+++ StatusView.cpp (working copy)
@@ -178,6 +178,9 @@
settings->timeShowMil = fClock->ShowingMilTime();
settings->timeShowEuro = fClock->ShowingEuroDate();
settings->timeFullDate = fClock->ShowingFullDate();
+#ifdef __HAIKU__
+ settings->timeIsoDate = fClock->ShowingIsoDate();
+#endif
}
}
@@ -227,6 +230,17 @@
}
+#ifdef __HAIKU__
+bool
+TReplicantTray::ShowingIsoDate() const
+{
+ if (fClock)
+ return fClock->ShowingIsoDate();
+ return false;
+}
+#endif
+
+
void
TReplicantTray::DealWithClock(bool showClock)
{
@@ -241,6 +255,10 @@
settings->timeShowEuro, false);
AddChild(fClock);
+#ifdef __HAIKU__
+ fClock->ShowIsoDate(settings->timeIsoDate);
+#endif
+
fClock->MoveTo(Bounds().right -
fClock->Bounds().Width() - 1, 2);
fClock->AllowFullDate(!IsMultiRow());
}
@@ -363,6 +381,9 @@
case kMsgMilTime:
case kMsgEuroDate:
case kMsgFullDate:
+#ifdef __HAIKU__
+ case kMsgIsoDate:
+#endif
if (fClock != NULL)
Window()->PostMessage(message, fClock);
break;
Index: TimeView.cpp
===================================================================
--- TimeView.cpp (revision 22598)
+++ TimeView.cpp (working copy)
@@ -57,6 +57,12 @@
static const char * const kMinString = "99:99 AM";
+#ifdef __HAIKU__
+const char* kShortIsoDate = "%y/%m/%d";
+const char* kLongIsoDate = "%a, %Y, %B %d";
+#endif
+
+
static float
FontHeight(BView *target, bool full)
{
@@ -90,6 +96,9 @@
fCanShowFullDate(false),
fEuroDate(euroDate),
fOrientation(false)
+#ifdef __HAIKU__
+ , fIsoDate(false)
+#endif
{
fShowingDate = false;
fTime = fLastTime = time(NULL);
@@ -110,6 +119,9 @@
data->FindBool("fulldate", &fFullDate);
data->FindBool("eurodate", &fEuroDate);
data->FindBool("interval", &fInterval);
+#ifdef __HAIKU__
+ data->FindBool("isoDate", &fIsoDate);
+#endif
fShowingDate = false;
}
#endif
@@ -142,6 +154,10 @@
data->AddBool("interval", fInterval);
data->AddInt32("deskbar:private_align", B_ALIGN_RIGHT);
+#ifdef __HAIKU__
+ data->AddBool("isoDate", fIsoDate);
+#endif
+
return B_OK;
}
#endif
@@ -223,6 +239,9 @@
case kMsgEuroDate:
ShowEuroDate(!ShowingEuroDate());
+#ifdef __HAIKU__
+ ShowIsoDate(false);
+#endif
break;
case kMsgChangeClock:
@@ -234,6 +253,12 @@
Window()->PostMessage(message, Parent());
break;
+#ifdef __HAIKU__
+ case kMsgIsoDate:
+ ShowIsoDate(!ShowingIsoDate());
+ ShowEuroDate(false);
+ break;
+#endif
default:
BView::MessageReceived(message);
}
@@ -274,6 +299,7 @@
char tmp[64];
tm time = *localtime(&fTime);
+#ifndef __HAIKU__
if (fFullDate && CanShowFullDate())
strftime(tmp, 64, fEuroDate ? kLongEuroDateFormat :
kLongDateFormat, &time);
else
@@ -284,7 +310,34 @@
const char* str = tmp;
if (str[0] == '0')
str++;
+#else
+ const char* format = NULL;
+ if (fFullDate && CanShowFullDate()) {
+ if (fIsoDate)
+ format = kLongIsoDate;
+ else if (fEuroDate)
+ format = kLongEuroDateFormat;
+ else
+ format = kLongDateFormat;
+ } else {
+ if (fIsoDate)
+ format = kShortIsoDate;
+ else if (fEuroDate)
+ format = kShortEuroDateFormat;
+ else
+ format = kShortDateFormat;
+ }
+ strftime(tmp, sizeof(tmp), format, &time);
+ const char* str = tmp;
+ if (!fIsoDate) {
+ // don't do anything on short iso date YY/MM/DD
+ // remove leading 0 from date when month is less than 10
(MM/DD/YY)
+ // or remove leading 0 from date when day is less than 10
(DD/MM/YY)
+ if (str[0] == '0')
+ str++;
+ }
+#endif
strcpy(fDateStr, str);
}
@@ -453,7 +506,17 @@
}
+#ifdef __HAIKU__
void
+TTimeView::ShowIsoDate(bool show)
+{
+ fIsoDate = show;
+ Update();
+}
+#endif
+
+
+void
TTimeView::AllowFullDate(bool allow)
{
fCanShowFullDate = allow;
Index: BarView.cpp
===================================================================
--- BarView.cpp (revision 22598)
+++ BarView.cpp (working copy)
@@ -168,6 +168,18 @@
AddItem(new BMessage(*message), B_DESKBAR_TRAY, &id);
break;
}
+
+#ifdef __HAIKU__
+ case 'MilT':
+ case 'ShSc':
+ case 'EDat':
+ case 'IDat':
+ {
+ // these messages are send by time prefs
+ BMessenger msgr(fReplicantTray);
+ msgr.SendMessage(message);
+ } break;
+#endif
default:
BView::MessageReceived(message);
Index: BarApp.cpp
===================================================================
--- BarApp.cpp (revision 22598)
+++ BarApp.cpp (working copy)
@@ -205,6 +205,9 @@
fSettingsFile->Write(&fSettings.superExpando, sizeof(bool));
fSettingsFile->Write(&fSettings.expandNewTeams, sizeof(bool));
fSettingsFile->Write(&fSettings.autoRaise, sizeof(bool));
+#ifdef __HAIKU__
+ fSettingsFile->Write(&fSettings.timeIsoDate, sizeof(bool));
+#endif
}
}
@@ -234,6 +237,9 @@
settings.superExpando = false;
settings.expandNewTeams = false;
settings.autoRaise = true;
+#ifdef __HAIKU__
+ settings.timeIsoDate = false;
+#endif
BPath dirPath;
const char *settingsFileName = "Deskbar_settings";
@@ -293,6 +299,11 @@
}
if (size >= kValidSettingsSize10)
fSettingsFile->Read(&settings.autoRaise,
sizeof(bool));
+
+#ifdef __HAIKU__
+ if (size >= kValidSettingsSize11)
+ fSettingsFile->Read(&settings.timeIsoDate,
sizeof(bool));
+#endif
}
}
@@ -502,6 +513,16 @@
break;
}
+
+ case 'MilT':
+ case 'ShSc':
+ case 'EDat':
+ case 'IDat':
+ {
+ // these messages are send by time prefs
+ BMessenger msgr(BarView());
+ msgr.SendMessage(message);
+ } break;
#endif // __HAIKU__
// in case Tracker is not running
Index: StatusView.h
===================================================================
--- StatusView.h (revision 22598)
+++ StatusView.h (working copy)
@@ -116,7 +116,9 @@
bool ShowingEuroDate(void);
bool ShowingFullDate(void);
bool CanShowFullDate(void);
-
+#ifdef __HAIKU__
+ bool ShowingIsoDate() const;
+#endif
void RememberClockSettings();
void DealWithClock(bool);
- Follow-Ups:
- [haiku-development] Re: Desbar patch
- From: Frank Paul Silye
- [haiku-development] Re: Desbar patch
- From: Axel Dörfler
- [haiku-development] Re: Desbar patch
- From: Efthymios Georgiadis
- [haiku-development] Re: Desbar patch
- From: Efthymios Georgiadis
Other related posts:
- » [haiku-development] Desbar patch
- » [haiku-development] Re: Desbar patch
- » [haiku-development] Re: Desbar patch
- » [haiku-development] Re: Desbar patch
- » [haiku-development] Re: Desbar patch
- » [haiku-development] Desbar patch
- » [haiku-development] Re: Desbar patch
- » [haiku-development] Re: Desbar patch
- [haiku-development] Re: Desbar patch
- From: Frank Paul Silye
- [haiku-development] Re: Desbar patch
- From: Axel Dörfler
- [haiku-development] Re: Desbar patch
- From: Efthymios Georgiadis
- [haiku-development] Re: Desbar patch
- From: Efthymios Georgiadis