dateMenu: Make "today" button more prominent
Split the weekday from the date and increase the latter's size to match the latest calendar mockups. https://bugzilla.gnome.org/show_bug.cgi?id=744817
This commit is contained in:
parent
26330fde7e
commit
33c5f5726e
@ -1 +1 @@
|
|||||||
Subproject commit 8409846c837c96f26533c7e9116c1009a4cc8bce
|
Subproject commit a1ea9bf18ae85deaffdedbf2f52c7c1a820086a9
|
@ -589,19 +589,28 @@ StScrollBar {
|
|||||||
padding: 0.75em 1.0em; }
|
padding: 0.75em 1.0em; }
|
||||||
|
|
||||||
.calendar {
|
.calendar {
|
||||||
margin: 0 1.5em;
|
|
||||||
margin-bottom: 1em; }
|
margin-bottom: 1em; }
|
||||||
|
|
||||||
|
.calendar,
|
||||||
|
.datemenu-today-button {
|
||||||
|
margin: 0 1.5em; }
|
||||||
|
|
||||||
.datemenu-calendar-column {
|
.datemenu-calendar-column {
|
||||||
spacing: 0.5em;
|
spacing: 0.5em;
|
||||||
padding-bottom: 3em; }
|
padding-bottom: 3em; }
|
||||||
|
|
||||||
.datemenu-date-label {
|
.datemenu-today-button {
|
||||||
padding: .4em 1.7em;
|
border-radius: 4px;
|
||||||
text-align: center;
|
padding: .4em; }
|
||||||
color: #eeeeec;
|
|
||||||
font-weight: bold;
|
.datemenu-today-button:hover, .datemenu-today-button:focus {
|
||||||
font-size: 110%; }
|
background-color: #454c4c; }
|
||||||
|
.datemenu-today-button:active {
|
||||||
|
color: white;
|
||||||
|
background-color: #215d9c; }
|
||||||
|
|
||||||
|
.datemenu-today-button .date-label {
|
||||||
|
font-size: 1.5em; }
|
||||||
|
|
||||||
.calendar-month-label {
|
.calendar-month-label {
|
||||||
color: #e2e2df;
|
color: #e2e2df;
|
||||||
|
@ -19,6 +19,65 @@ const PanelMenu = imports.ui.panelMenu;
|
|||||||
const PopupMenu = imports.ui.popupMenu;
|
const PopupMenu = imports.ui.popupMenu;
|
||||||
const Calendar = imports.ui.calendar;
|
const Calendar = imports.ui.calendar;
|
||||||
|
|
||||||
|
const TodayButton = new Lang.Class({
|
||||||
|
Name: 'TodayButton',
|
||||||
|
|
||||||
|
_init: function(calendar) {
|
||||||
|
// Having the ability to go to the current date if the user is already
|
||||||
|
// on the current date can be confusing. So don't make the button reactive
|
||||||
|
// until the selected date changes.
|
||||||
|
this.actor = new St.Button({ style_class: 'datemenu-today-button',
|
||||||
|
x_align: St.Align.START,
|
||||||
|
reactive: false
|
||||||
|
});
|
||||||
|
this.actor.connect('clicked', Lang.bind(this,
|
||||||
|
function() {
|
||||||
|
this._calendar.setDate(new Date(), false);
|
||||||
|
}));
|
||||||
|
|
||||||
|
let hbox = new St.BoxLayout({ vertical: true });
|
||||||
|
this.actor.add_actor(hbox);
|
||||||
|
|
||||||
|
this._dayLabel = new St.Label({ style_class: 'day-label',
|
||||||
|
x_align: Clutter.ActorAlign.START });
|
||||||
|
hbox.add_actor(this._dayLabel);
|
||||||
|
|
||||||
|
this._dateLabel = new St.Label({ style_class: 'date-label' });
|
||||||
|
hbox.add_actor(this._dateLabel);
|
||||||
|
|
||||||
|
this._calendar = calendar;
|
||||||
|
this._calendar.connect('selected-date-changed', Lang.bind(this,
|
||||||
|
function(calendar, date) {
|
||||||
|
// Make the button reactive only if the selected date is not the
|
||||||
|
// current date.
|
||||||
|
this.actor.can_focus = this.actor.reactive = !this._isToday(date)
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
setDate: function(date) {
|
||||||
|
this._dayLabel.set_text(date.toLocaleFormat('%A'));
|
||||||
|
|
||||||
|
/* Translators: This is the date format to use when the calendar popup is
|
||||||
|
* shown - it is shown just below the time in the shell (e.g. "Tue 9:29 AM").
|
||||||
|
*/
|
||||||
|
let dateFormat = Shell.util_translate_time_string (N_("%B %e %Y"));
|
||||||
|
this._dateLabel.set_text(date.toLocaleFormat(dateFormat));
|
||||||
|
|
||||||
|
/* Translators: This is the accessible name of the date button shown
|
||||||
|
* below the time in the shell; it should combine the weekday and the
|
||||||
|
* date, e.g. "Tuesday February 17 2015".
|
||||||
|
*/
|
||||||
|
let dateFormat = Shell.util_translate_time_string (N_("%A %B %e %Y"));
|
||||||
|
this.actor.accessible_name = date.toLocaleFormat(dateFormat);
|
||||||
|
},
|
||||||
|
|
||||||
|
_isToday: function(date) {
|
||||||
|
let now = new Date();
|
||||||
|
return now.getYear() == date.getYear() &&
|
||||||
|
now.getMonth() == date.getMonth() &&
|
||||||
|
now.getDate() == date.getDate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const DateMenuButton = new Lang.Class({
|
const DateMenuButton = new Lang.Class({
|
||||||
Name: 'DateMenuButton',
|
Name: 'DateMenuButton',
|
||||||
@ -46,9 +105,6 @@ const DateMenuButton = new Lang.Class({
|
|||||||
this._calendar.connect('selected-date-changed',
|
this._calendar.connect('selected-date-changed',
|
||||||
Lang.bind(this, function(calendar, date) {
|
Lang.bind(this, function(calendar, date) {
|
||||||
this._eventList.setDate(date);
|
this._eventList.setDate(date);
|
||||||
|
|
||||||
// Make the button reactive only if the selected date is not the current date.
|
|
||||||
this._date.can_focus = this._date.reactive = !this._isToday(date)
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Whenever the menu is opened, select today
|
// Whenever the menu is opened, select today
|
||||||
@ -56,12 +112,7 @@ const DateMenuButton = new Lang.Class({
|
|||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
this._calendar.setDate(now);
|
this._calendar.setDate(now);
|
||||||
|
this._date.setDate(now);
|
||||||
/* Translators: This is the date format to use when the calendar popup is
|
|
||||||
* shown - it is shown just below the time in the shell (e.g. "Tue 9:29 AM").
|
|
||||||
*/
|
|
||||||
let dateFormat = Shell.util_translate_time_string (N_("%A %B %e, %Y"));
|
|
||||||
this._date.set_label(now.toLocaleFormat(dateFormat));
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -74,18 +125,8 @@ const DateMenuButton = new Lang.Class({
|
|||||||
vertical: true });
|
vertical: true });
|
||||||
hbox.add(vbox);
|
hbox.add(vbox);
|
||||||
|
|
||||||
// Date
|
this._date = new TodayButton(this._calendar);
|
||||||
// Having the ability to go to the current date if the user is already
|
vbox.add_actor(this._date.actor);
|
||||||
// on the current date can be confusing. So don't make the button reactive
|
|
||||||
// until the selected date changes.
|
|
||||||
this._date = new St.Button({ style_class: 'datemenu-date-label',
|
|
||||||
reactive: false
|
|
||||||
});
|
|
||||||
this._date.connect('clicked',
|
|
||||||
Lang.bind(this, function() {
|
|
||||||
this._calendar.setDate(new Date(), false);
|
|
||||||
}));
|
|
||||||
vbox.add(this._date, { x_fill: false });
|
|
||||||
|
|
||||||
vbox.add(this._calendar.actor);
|
vbox.add(this._calendar.actor);
|
||||||
|
|
||||||
@ -120,13 +161,6 @@ const DateMenuButton = new Lang.Class({
|
|||||||
this._sessionUpdated();
|
this._sessionUpdated();
|
||||||
},
|
},
|
||||||
|
|
||||||
_isToday: function(date) {
|
|
||||||
let now = new Date();
|
|
||||||
return now.getYear() == date.getYear() &&
|
|
||||||
now.getMonth() == date.getMonth() &&
|
|
||||||
now.getDate() == date.getDate();
|
|
||||||
},
|
|
||||||
|
|
||||||
_appInstalledChanged: function() {
|
_appInstalledChanged: function() {
|
||||||
this._calendarApp = undefined;
|
this._calendarApp = undefined;
|
||||||
this._updateEventsVisibility();
|
this._updateEventsVisibility();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user