[gnome-sound-recorder] listview.js: special case startup with no files



commit 535194fb9abf48debeb36c6c9816d1fcda075a1b
Author: Meg Ford <meg387 gmail com>
Date:   Mon Sep 30 14:39:41 2013 -0500

    listview.js: special case startup with no files

 data/org.gnome.SoundRecorder.desktop.in |    2 +-
 src/fileUtil.js                         |    8 ++++----
 src/listview.js                         |   18 +++++++++++-------
 src/mainWindow.js                       |   14 +++++---------
 4 files changed, 21 insertions(+), 21 deletions(-)
---
diff --git a/data/org.gnome.SoundRecorder.desktop.in b/data/org.gnome.SoundRecorder.desktop.in
index 9e78c0b..7b8168b 100644
--- a/data/org.gnome.SoundRecorder.desktop.in
+++ b/data/org.gnome.SoundRecorder.desktop.in
@@ -5,6 +5,6 @@ _Comment=Record sound via the microphone and play it back
 Icon=face-smile
 Categories=GNOME;GTK;
 _Keywords=Audio;Application;Record;
-Exec= GJS@ -c 'imports.package.start({ name: "gnome-sound-recorder", version: "@PACKAGE_VERSION@", prefix: 
"@prefix@" })'
+Exec=gnome-sound-recorder
 StartupNotify=true
 
diff --git a/src/fileUtil.js b/src/fileUtil.js
index 7b113c8..2d66711 100644
--- a/src/fileUtil.js
+++ b/src/fileUtil.js
@@ -89,16 +89,16 @@ const OffsetController = new Lang.Class({
     
     getEndIdx: function() {
         this.totItems = MainWindow.list.getItemCount();
- 
+ log(this.totItems + "totitems");
         if (CurrentEndIdx < this.totItems) {
             this.endIdx = CurrentEndIdx;
+            log("greater");
         } else {
             this.endIdx = this.totItems - 1;
+            log("less");
         }
-            
-        CurrentEndIdx = this.endIdx;
         
-        return CurrentEndIdx;
+        return this.endIdx;
     },
     
     increaseEndIdxStep: function() {
diff --git a/src/listview.js b/src/listview.js
index 53cd63e..e27a4a8 100644
--- a/src/listview.js
+++ b/src/listview.js
@@ -151,8 +151,16 @@ const Listview = new Lang.Class({
                     } else {
                         stopVal = EnumeratorState.CLOSED;
                         this._enumerator.close(null);
+                        
+                        if (MainWindow.offsetController.getEndIdx() == -1) {
+                            MainWindow.view.listBoxAdd();
+                            MainWindow.view.scrolledWinAdd();
+                            currentlyEnumerating = CurrentlyEnumerating.FALSE;
+                        } else {
+                            
                         this._setDiscover();
-                                                 
+                        log("set Discover");  
+                        }                       
                         return;
                    }                    
                 }));
@@ -201,7 +209,6 @@ const Listview = new Lang.Class({
                         
     _onDiscovererFinished: function(res, info, err) {
         this.result = res;
-        
         if (this.result == GstPbutils.DiscovererResult.OK) { 
             this.tagInfo = info.get_tags(info);
             let appString = "";
@@ -237,11 +244,9 @@ const Listview = new Lang.Class({
             // don't index files we can't play
             log("File cannot be played"); 
         }
-         
+        
         if (this.idx == this.endIdx) { 
             this._discoverer.stop();
-            log(this.idx + "index");
-           log(this.endIdx + "endIndex");
             if (listType == ListType.NEW) {
                 MainWindow.view.listBoxAdd();
                 MainWindow.view.scrolledWinAdd();
@@ -252,7 +257,7 @@ const Listview = new Lang.Class({
             }
             //return false; 
         }         
-        this.idx++;                              
+        this.idx++;                            
     },
     
     setListTypeNew: function() {
@@ -271,7 +276,6 @@ const Listview = new Lang.Class({
             fileInfo.length = 0;
             this.idx = 0;
             listType = ListType.REFRESH;
-            
             if (currentlyEnumerating == CurrentlyEnumerating.FALSE) {
                 currentlyEnumerating = CurrentlyEnumerating.TRUE;
                 MainWindow.view.listBoxRefresh();
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 226752b..0f51d03 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -96,7 +96,6 @@ const MainWindow = new Lang.Class({
         fileUtil = new FileUtil.FileUtil();
         offsetController = new FileUtil.OffsetController;
         view = new MainView();
-       log(view);
         play = new Play.Play();
         
         params = Params.fill(params, { title: GLib.get_application_name(), 
@@ -165,8 +164,6 @@ const MainView = new Lang.Class({
     _addListviewPage: function(name) {
         fileUtil = new FileUtil.FileUtil();
         list = new Listview.Listview();
-       log(list);
-       log(list.allFilesInfo);
         list.setListTypeNew();
         list.enumerateDirectory();
         this._record = new Record.Record(audioProfile);
@@ -305,8 +302,7 @@ const MainView = new Lang.Class({
         this.recordGrid.attach(this.toolbarStart, 5, 1, 1, 2);
     },
      
-    scrolledWinAdd: function() { 
-       log("Scrolled window added");      
+    scrolledWinAdd: function() {    
         this._scrolledWin = new Gtk.ScrolledWindow({ shadow_type: Gtk.ShadowType.IN,
                                                      margin_bottom: 3,
                                                      margin_top: 5,
@@ -334,7 +330,6 @@ const MainView = new Lang.Class({
         this._scrolledWin.show();
         
         this.listBox = Gtk.ListBox.new();
-       log(this.listBox);
         this._scrolledWin.add(this.listBox);
         this.listBox.set_selection_mode(Gtk.SelectionMode.SINGLE);
         this.listBox.set_header_func(null);
@@ -346,7 +341,7 @@ const MainView = new Lang.Class({
         this.listBox.show();
         
         this._startIdx = 0;
-        this._endIdx = offsetController.getcidx();
+        this._endIdx = offsetController.getEndIdx();
         this._files = [];
         this._files = list.getFilesInfoForList();
         
@@ -557,7 +552,8 @@ const MainView = new Lang.Class({
     listBoxRefresh: function() {
         this.destroyLoadMoreButton();        
         previousSelRow = null;
-        this.listBox.set_selection_mode(Gtk.SelectionMode.NONE);  
+        this.listBox.set_selection_mode(Gtk.SelectionMode.NONE);
+        list.setListTypeRefresh();  
         list.enumerateDirectory();         
     },
     
@@ -571,7 +567,7 @@ const MainView = new Lang.Class({
     },
     
     scrolledWinDelete: function() {
-        let w = this.rowGrid.get_allocated_width();
+        //let w = this.rowGrid.get_allocated_width();
         this._scrolledWin.destroy();
         this.scrolledWinAdd(); 
     },


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