[gnome-shell/wip/fmuellner/notification-redux: 13/93] More messageList work



commit 2a9b968fbbb256a0ffbe4f8e1e737244946ca938
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Dec 11 18:29:17 2014 +0100

    More messageList work

 js/ui/calendar.js |   35 +++++++++++++++++++++++++++++------
 js/ui/dateMenu.js |   12 ++++++------
 2 files changed, 35 insertions(+), 12 deletions(-)
---
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index 8fb86bd..437e1d6 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -886,17 +886,40 @@ const EventsSection = new Lang.Class({
     }
 });
 
-const EventsList = new Lang.Class({
-    Name: 'EventsList',
+const MessageList = new Lang.Class({
+    Name: 'MessageList',
 
     _init: function() {
-        let layout = new Clutter.GridLayout({ orientation: Clutter.Orientation.VERTICAL });
         this.actor = new St.Widget({ style_class: 'events-table',
-                                     layout_manager: layout });
-        layout.hookup_style(this.actor);
+                                     layout_manager: new Clutter.BinLayout(),
+                                     x_expand: true, y_expand: true });
+
+        this._placeholder = new St.Icon({ icon_name: 'window-close-symbolic' });
+        this.actor.add_actor(this._placeholder);
+
+        this._scrollView = new St.ScrollView({ x_expand: true, y_expand: true,
+                                               y_align: Clutter.ActorAlign.START });
+        this.actor.add_actor(this._scrollView);
+
+        this._sectionList = new St.BoxLayout({ vertical: true });
+        this._scrollView.add_actor(this._sectionList);
 
         this._eventsSection = new EventsSection();
-        layout.attach(this._eventsSection.actor, 0, 0, 1, 1);
+        this._addSection(this._eventsSection);
+
+        this._sync();
+    },
+
+    _addSection: function(section) {
+        let id = section.actor.connect('notify::visible', Lang.bind(this, this._sync));
+        section.actor.connect('destroy', function(a) { a.disconnect(id); });
+        this._sectionList.add_actor(section.actor);
+    },
+
+    _sync: function() {
+        let visible = this._sectionList.get_children().some(function(a) { return a.visible });
+        this._scrollView.visible = visible;
+        this._placeholder.visible = !visible;
     },
 
     setEventSource: function(eventSource) {
diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js
index 0c63bbf..341c78f 100644
--- a/js/ui/dateMenu.js
+++ b/js/ui/dateMenu.js
@@ -114,7 +114,7 @@ const DateMenuButton = new Lang.Class({
         vbox = new St.BoxLayout({vertical: true});
         hbox.add(vbox);
 
-        this._eventList = new Calendar.EventsList();
+        this._messageList = new Calendar.MessageList();
         this._calendar = new Calendar.Calendar();
 
         // Date
@@ -123,11 +123,11 @@ const DateMenuButton = new Lang.Class({
 
         this._calendar.connect('selected-date-changed',
                                Lang.bind(this, function(calendar, date) {
-                                  // we know this._eventList is defined here, because selected-data-changed
+                                  // 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
                                   // a null event source
-                                   this._eventList.setDate(date);
+                                   this._messageList.setDate(date);
                                }));
         vbox.add(this._calendar.actor);
 
@@ -158,7 +158,7 @@ const DateMenuButton = new Lang.Class({
         hbox.add(this._separator);
 
         // Fill up the second column
-        hbox.add(this._eventList.actor, { expand: true, y_fill: false, y_align: St.Align.START });
+        hbox.add(this._messageList.actor, { expand: true, y_fill: false, y_align: St.Align.START });
 
         // Whenever the menu is opened, select today
         this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
@@ -190,7 +190,7 @@ const DateMenuButton = new Lang.Class({
         this._openClocksItem.actor.visible = visible &&
             (this._getClockApp() != null);
         this._separator.visible = visible;
-        this._eventList.actor.visible = visible;
+        this._messageList.actor.visible = visible;
         if (visible) {
             let alignment = 0.25;
             if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
@@ -210,7 +210,7 @@ const DateMenuButton = new Lang.Class({
             this._eventSource.destroy();
 
         this._calendar.setEventSource(eventSource);
-        this._eventList.setEventSource(eventSource);
+        this._messageList.setEventSource(eventSource);
 
         this._eventSource = eventSource;
         this._eventSource.connect('notify::has-calendars', Lang.bind(this, function() {


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