[gnome-sound-recorder] Remove the LoadMore button Fixes #66
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-sound-recorder] Remove the LoadMore button Fixes #66
- Date: Sat, 28 Mar 2020 12:21:01 +0000 (UTC)
commit 5b30808c4c02fb47d5cc6f1eae49b8ccc4a28cb2
Author: Kavan Mevada <kavanmevada gmail com>
Date: Sat Mar 28 01:30:14 2020 +0530
Remove the LoadMore button
Fixes #66
src/fileUtil.js | 38 --------------------------
src/listview.js | 4 +--
src/mainWindow.js | 80 +++++++------------------------------------------------
3 files changed, 11 insertions(+), 111 deletions(-)
---
diff --git a/src/fileUtil.js b/src/fileUtil.js
index 4eaf48a..e77e9be 100644
--- a/src/fileUtil.js
+++ b/src/fileUtil.js
@@ -21,44 +21,6 @@
const Gettext = imports.gettext;
const GLib = imports.gi.GLib;
-const MainWindow = imports.mainWindow;
-
-const _OFFSET_STEP = 20;
-let CurrentEndIdx;
-let totItems;
-
-var OffsetController = class OffsetController {
- constructor(context) {
- this._offset = 0;
- this._itemCount = 0;
- this._context = context;
- CurrentEndIdx = _OFFSET_STEP;
- }
-
- getOffset() {
- return this._offset;
- }
-
- getEndIdx() {
- totItems = MainWindow.list.getItemCount();
- if (CurrentEndIdx < totItems)
- this.endIdx = CurrentEndIdx - 1;
- else
- this.endIdx = totItems - 1;
-
-
- return this.endIdx;
- }
-
- increaseEndIdxStep() {
- CurrentEndIdx += _OFFSET_STEP;
- }
-
- getcidx() {
- return CurrentEndIdx;
- }
-};
-
var DisplayTime = class DisplayTime {
getDisplayTime(mtime) {
let text = '';
diff --git a/src/listview.js b/src/listview.js
index 2447b44..f12c61e 100644
--- a/src/listview.js
+++ b/src/listview.js
@@ -140,7 +140,7 @@ var Listview = class Listview {
stopVal = EnumeratorState.CLOSED;
this._enumerator.close(null);
- if (MainWindow.offsetController.getEndIdx() === -1) {
+ if (this.getItemCount() === 0) {
if (listType === ListType.NEW) {
MainWindow.view.listBoxAdd();
MainWindow.view.scrolledWinAdd();
@@ -176,7 +176,7 @@ var Listview = class Listview {
_setDiscover() {
this._controller = MainWindow.offsetController;
- this.endIdx = this._controller.getEndIdx();
+ this.endIdx = this.getItemCount() - 1;
this.idx = 0;
this._discoverer = new GstPbutils.Discoverer();
this._discoverer.start();
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 2ae4494..2a2d16f 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -41,13 +41,10 @@ let activeProfile = null;
var audioProfile = null;
var displayTime = null;
var list = null;
-let loadMoreButton = null;
-var offsetController = null;
var play = null;
let previousSelRow = null;
var recordPipeline = null;
let setVisibleID = null;
-let UpperBoundVal = 182;
var view = null;
var volumeValue = [];
var wave = null;
@@ -57,7 +54,6 @@ var ActiveArea = {
PLAY: 1,
};
-
const PipelineStates = {
PLAYING: 0,
PAUSED: 1,
@@ -80,7 +76,6 @@ var MainWindow = GObject.registerClass({
_init(params) {
audioProfile = new AudioProfile.AudioProfile();
- offsetController = new FileUtil.OffsetController();
displayTime = new FileUtil.DisplayTime();
view = this;
this._addListviewPage();
@@ -104,7 +99,6 @@ var MainWindow = GObject.registerClass({
}
_onRecord() {
- view.destroyLoadMoreButton();
view.hasPreviousSelRow();
if (view.listBox)
@@ -283,25 +277,12 @@ var MainWindow = GObject.registerClass({
this._scrolledWin.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
this.scrollbar = this._scrolledWin.get_vadjustment();
- this.scrollbar.connect('value_changed', () => {
- this.currentBound = this.scrollbar.get_value();
- UpperBoundVal = this.scrollbar.upper - this.scrollbar.page_size;
- if (UpperBoundVal === this.currentBound && loadMoreButton === null) {
- this.addLoadMoreButton();
- } else if (UpperBoundVal !== this.currentBound && loadMoreButton) {
- loadMoreButton.destroy();
- loadMoreButton = null;
- }
- });
-
this._mainView.add(this._scrolledWin);
this._scrolledWin.show();
this.listBox = null;
- this._startIdx = 0;
- this._endIdx = offsetController.getEndIdx();
- if (this._endIdx === -1) {
+ if (list.getItemCount() === 0) {
this._scrolledWin.get_style_context().add_class('emptyGrid');
this._addEmptyPage();
} else {
@@ -318,8 +299,9 @@ var MainWindow = GObject.registerClass({
this._files = [];
this._files = list.getFilesInfoForList();
- for (let i = this._startIdx; i <= this._endIdx; i++) {
- this.rowGrid = new Gtk.Grid({ name: i.toString(),
+ this._files.forEach((file, index) => {
+
+ this.rowGrid = new Gtk.Grid({ name: index.toString(),
height_request: 45,
orientation: Gtk.Orientation.VERTICAL,
hexpand: true,
@@ -342,9 +324,6 @@ var MainWindow = GObject.registerClass({
let row = button.get_parent().get_parent();
this.listBox.select_row(row);
play.passSelected(row);
- let gridForName = row.get_child();
- let idx = parseInt(gridForName.name);
- let file = this._files[idx];
this.onPlayPauseToggled(row, file);
});
@@ -373,7 +352,7 @@ var MainWindow = GObject.registerClass({
use_markup: true,
width_chars: 35,
xalign: 0 });
- let markup = `<b>${this._files[i].fileName}</b>`;
+ let markup = `<b>${file.fileName}</b>`;
this._fileName.label = markup;
this._fileName.set_no_show_all(true);
this.rowGrid.attach(this._fileName, 3, 0, 10, 3);
@@ -389,7 +368,7 @@ var MainWindow = GObject.registerClass({
valign: Gtk.Align.END,
margin_start: 15,
margin_top: 5 });
- this.fileDuration = this._formatTime(this._files[i].duration / Gst.SECOND);
+ this.fileDuration = this._formatTime(file.duration / Gst.SECOND);
this.playDurationLabel.label = this.fileDuration;
this._playLabelBox.pack_start(this.playDurationLabel, false, true, 0);
this.playDurationLabel.show();
@@ -417,7 +396,7 @@ var MainWindow = GObject.registerClass({
valign: Gtk.Align.END,
margin_start: 15,
margin_top: 5 });
- this.dateModifiedLabel.label = this._files[i].dateModified;
+ this.dateModifiedLabel.label = file.dateModified;
this.dateModifiedLabel.get_style_context().add_class('dim-label');
this.dateModifiedLabel.set_no_show_all(true);
this.rowGrid.attach(this.dateModifiedLabel, 3, 1, 6, 1);
@@ -441,9 +420,6 @@ var MainWindow = GObject.registerClass({
this._info.connect('clicked', button => {
let row = button.get_parent().get_parent();
this.listBox.select_row(row);
- let gridForName = row.get_child();
- let idx = parseInt(gridForName.name);
- let file = this._files[idx];
this._onInfoButton(file);
});
this._info.set_tooltip_text(_('Info'));
@@ -463,27 +439,13 @@ var MainWindow = GObject.registerClass({
this._delete.set_tooltip_text(_('Delete'));
this.rowGrid.attach(this._delete, 28, 0, 1, 2);
this._delete.hide();
- }
- }
- list.monitorListview();
- }
- addLoadMoreButton() {
- loadMoreButton = new LoadMoreButton();
- loadMoreButton.connect('clicked', () => loadMoreButton.onLoadMore());
- this._mainView.add(loadMoreButton);
- loadMoreButton.show();
- }
-
- destroyLoadMoreButton() {
- if (loadMoreButton !== null) {
- loadMoreButton.destroy();
- loadMoreButton = null;
+ });
}
+ list.monitorListview();
}
listBoxRefresh() {
- this.destroyLoadMoreButton();
previousSelRow = null;
if (this.listBox)
@@ -494,22 +456,12 @@ var MainWindow = GObject.registerClass({
list.enumerateDirectory();
}
- listBoxLoadMore() {
- this.destroyLoadMoreButton();
- previousSelRow = null;
- this.listBox.set_selection_mode(Gtk.SelectionMode.NONE);
- offsetController.increaseEndIdxStep();
- list.setListTypeRefresh();
- list._setDiscover();
- }
-
scrolledWinDelete() {
this._scrolledWin.destroy();
this.scrolledWinAdd();
}
hasPreviousSelRow() {
- this.destroyLoadMoreButton();
if (previousSelRow !== null) {
let rowGrid = previousSelRow.get_child();
rowGrid.foreach(child => {
@@ -550,7 +502,6 @@ var MainWindow = GObject.registerClass({
rowGridCallback() {
let selectedRow = this.listBox.get_selected_row();
- this.destroyLoadMoreButton();
if (selectedRow) {
if (previousSelRow !== null)
@@ -744,16 +695,3 @@ var ChannelsComboBox = GObject.registerClass(class ChannelsComboBox extends Gtk.
Application.application.setChannelsPreferences(channelProfile);
}
});
-
-const LoadMoreButton = GObject.registerClass(class LoadMoreButton extends Gtk.Button {
- _init() {
- super._init();
- this._block = false;
- this.label = _('Load More');
- this.get_style_context().add_class('documents-load-more');
- }
-
- onLoadMore() {
- view.listBoxLoadMore();
- }
-});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]