Commit 535194fb authored by Meg Ford's avatar Meg Ford

listview.js: special case startup with no files

parent 9ae5706e
......@@ -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
......@@ -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() {
......
......@@ -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();
......
......@@ -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();
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment