[gnome-shell] Fixes for Calendar widget



commit afb3b1e7181b1d17c816d6ccad7629426667c099
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Thu Oct 1 16:14:50 2009 -0400

    Fixes for Calendar widget
    
    Miscellaneous fixes from review:
    
    - Distribute calendar.js and the interactive test
    - Make the pointless protection against leap seconds actually work
      by starting in the middle of the day so that forward/back always
      move a day.
    - Use a variable instead of an inline '8' to know where to start
      when removing old day actors.
    - Remove a stray comment from the test
    
    https://bugzilla.gnome.org/show_bug.cgi?id=596432

 js/ui/Makefile.am             |    1 +
 js/ui/calendar.js             |    9 +++++++--
 js/ui/panel.js                |    4 ++++
 tests/Makefile.am             |    3 ++-
 tests/interactive/calendar.js |    4 +---
 5 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/Makefile.am b/js/ui/Makefile.am
index 4f6490c..d4eccc3 100644
--- a/js/ui/Makefile.am
+++ b/js/ui/Makefile.am
@@ -5,6 +5,7 @@ dist_jsui_DATA =		\
 	appDisplay.js		\
 	appIcon.js		\
 	button.js		\
+	calendar.js		\
 	chrome.js		\
 	dash.js			\
 	dnd.js			\
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index de7f402..d8b380a 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -79,6 +79,7 @@ Calendar.prototype = {
         // them in the right cell in the table. It doesn't matter if we add them in order
         let iter = new Date(this.date);
         iter.setSeconds(0); // Leap second protection. Hah!
+        iter.setHours(12);
         for (let i = 0; i < 7; i++) {
             this.actor.add(new St.Label({ text: iter.toLocaleFormat("%a") }),
                            { row: 1,
@@ -87,6 +88,9 @@ Calendar.prototype = {
             iter.setTime(iter.getTime() + MSECS_IN_DAY);
         }
 
+        // All the children after this are days, and get removed when we update the calendar
+        this._firstDayIndex = this.actor.get_children().length;
+
         this._update();
     },
 
@@ -132,17 +136,18 @@ Calendar.prototype = {
     },
 
     _update: function() {
-        this._dateLabel.text = this.date.toLocaleFormat("%B %Y");
+        this._dateLabel.text = this.date.toLocaleFormat(this._headerFormat);
 
         // Remove everything but the topBox and the weekday labels
         let children = this.actor.get_children();
-        for (let i = 8; i < children.length; i++)
+        for (let i = this._firstDayIndex; i < children.length; i++)
             children[i].destroy();
 
         // Start at the beginning of the week before the start of the month
         let iter = new Date(this.date);
         iter.setDate(1);
         iter.setSeconds(0);
+        iter.setHours(12);
         iter.setTime(iter.getTime() - (iter.getDay() - this._weekStart) * MSECS_IN_DAY);
 
         let now = new Date();
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 92a1bf8..58803b3 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -518,6 +518,10 @@ CalendarPopup.prototype = {
         this.calendar = new Calendar.Calendar();
         this.actor.add(this.calendar.actor);
 
+        // Directly adding the actor to Main.chrome.actor is a hack to
+        // work around the fact that there is no way to add an actor that
+        // affects the input region but not the shape.
+        // See: https://bugzilla.gnome.org/show_bug.cgi?id=597044
         Main.chrome.actor.add_actor(this.actor);
         Main.chrome.addInputRegionActor(this.actor);
         this.actor.y = (panelActor.y + panelActor.height - this.actor.height);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 43bfbb5..49a15bb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,7 +3,8 @@ EXTRA_DIST = run-test.sh.in
 
 TEST_JS =					\
 	testcommon/ui.js			\
-	interactive/box-layout.js
+	interactive/box-layout.js		\
+	interactive/calendar.js
 EXTRA_DIST += $(TEST_JS)
 
 TEST_MISC =					\
diff --git a/tests/interactive/calendar.js b/tests/interactive/calendar.js
index 9336c95..f8f50b9 100644
--- a/tests/interactive/calendar.js
+++ b/tests/interactive/calendar.js
@@ -4,11 +4,9 @@ const Clutter = imports.gi.Clutter;
 const Lang = imports.lang;
 const St = imports.gi.St;
 
-const Calendar =imports.ui.calendar;
+const Calendar = imports.ui.calendar;
 const UI = imports.testcommon.ui;
 
-const Gettext_gtk20 = imports.gettext.domain('gtk20');
-
 UI.init();
 let stage = Clutter.Stage.get_default();
 stage.width = stage.height = 400;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]