[gnome-shell/wip/fmuellner/notification-redux+sass: 142/207] dateMenu: Freeze popup size while browsing
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/fmuellner/notification-redux+sass: 142/207] dateMenu: Freeze popup size while browsing
- Date: Tue, 17 Feb 2015 17:05:56 +0000 (UTC)
commit e3b58a0b19c35d7a0cf4881431c7975b9253e05d
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Feb 13 16:25:21 2015 +0100
dateMenu: Freeze popup size while browsing
js/ui/dateMenu.js | 58 ++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 49 insertions(+), 9 deletions(-)
---
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 4fe679c..fbd1037 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -36,6 +36,13 @@ function _onVertSepRepaint(area) {
cr.$dispose();
}
+function _isToday(date) {
+ let now = new Date();
+ return now.getYear() == date.getYear() &&
+ now.getMonth() == date.getMonth() &&
+ now.getDate() == date.getDate();
+}
+
const TodayButton = new Lang.Class({
Name: 'TodayButton',
@@ -66,7 +73,7 @@ const TodayButton = new Lang.Class({
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)
+ this.actor.can_focus = this.actor.reactive = !_isToday(date)
}));
},
@@ -78,13 +85,6 @@ const TodayButton = new Lang.Class({
*/
let dateFormat = Shell.util_translate_time_string (N_("%B %e %Y"));
this._dateLabel.set_text(date.toLocaleFormat(dateFormat));
- },
-
- _isToday: function(date) {
- let now = new Date();
- return now.getYear() == date.getYear() &&
- now.getMonth() == date.getMonth() &&
- now.getDate() == date.getDate();
}
});
@@ -218,6 +218,40 @@ const WorldClocksSection = new Lang.Class({
}
});
+const FreezableBinLayout = new Lang.Class({
+ Name: 'FreezableBinLayout',
+ Extends: Clutter.BinLayout,
+
+ _init: function() {
+ this.parent();
+
+ this._frozen = false;
+ this._savedWidth = [NaN, NaN];
+ this._savedHeight = [NaN, NaN];
+ },
+
+ set frozen(v) {
+ if (this._frozen == v)
+ return;
+
+ this._frozen = v;
+ if (!this._frozen)
+ this.layout_changed();
+ },
+
+ vfunc_get_preferred_width: function(container, forHeight) {
+ if (!this._frozen || this._savedWidth.some(isNaN))
+ this._savedWidth = this.parent(container, forHeight);
+ return this._savedWidth;
+ },
+
+ vfunc_get_preferred_height: function(container, forWidth) {
+ if (!this._frozen || this._savedHeight.some(isNaN))
+ this._savedHeight = this.parent(container, forWidth);
+ return this._savedHeight;
+ }
+});
+
const DateMenuButton = new Lang.Class({
Name: 'DateMenuButton',
Extends: PanelMenu.Button,
@@ -237,8 +271,12 @@ const DateMenuButton = new Lang.Class({
this.actor.add_actor(this._clockDisplay);
this.actor.add_style_class_name ('clock-display');
+ let layout = new FreezableBinLayout();
+ let bin = new St.Widget({ layout_manager: layout });
+ this.menu.box.add_child(bin);
+
hbox = new St.BoxLayout({ name: 'calendarArea' });
- this.menu.box.add_child(hbox);
+ bin.add_actor(hbox);
// Fill up the first column
this._messageList = new Calendar.MessageList();
@@ -248,6 +286,7 @@ const DateMenuButton = new Lang.Class({
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
if (isOpen) {
let now = new Date();
+ layout.frozen = false;
this._calendar.setDate(now);
this._date.setDate(now);
}
@@ -270,6 +309,7 @@ const DateMenuButton = new Lang.Class({
this._calendar.connect('selected-date-changed',
Lang.bind(this, function(calendar, date) {
+ layout.frozen = !_isToday(date);
// we know this._messageList is defined here, because selected-data-changed
// only gets emitted when the user clicks a date in the calendar,
// and the calender makes those dates unclickable when instantiated with
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]