[gnome-books/wip/hadess/gnome-books: 3/10] Remove isBooks variable, it's always true
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-books/wip/hadess/gnome-books: 3/10] Remove isBooks variable, it's always true
- Date: Fri, 25 Jan 2019 12:46:30 +0000 (UTC)
commit 3c9277d55e8fd4bf48ae2c9b9f8d4787c59a31f0
Author: Bastien Nocera <hadess hadess net>
Date: Thu Jan 24 12:47:54 2019 +0100
Remove isBooks variable, it's always true
src/application.js | 20 ++++------------
src/documents.js | 30 +++--------------------
src/epubview.js | 2 +-
src/evinceview.js | 62 +----------------------------------------------
src/lib/gd-utils.c | 20 ++++------------
src/lib/gd-utils.h | 3 +--
src/mainWindow.js | 4 ++--
src/overview.js | 43 +++------------------------------
src/preview.js | 2 +-
src/query.js | 6 +----
src/search.js | 70 ++++++++++++++----------------------------------------
src/selections.js | 27 +--------------------
12 files changed, 41 insertions(+), 248 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 5e063ad1..54ee1d33 100644
--- a/src/application.js
+++ b/src/application.js
@@ -96,22 +96,15 @@ var Application = new Lang.Class({
'miners-changed': {}
},
- _init: function(isBooks) {
+ _init: function() {
this.minersRunning = [];
this._activationTimestamp = Gdk.CURRENT_TIME;
this._extractPriority = null;
this._searchProvider = null;
- this.isBooks = isBooks;
-
let appid;
- if (this.isBooks) {
- GLib.set_application_name(_("Books"));
- appid = 'org.gnome.Books';
- } else {
- GLib.set_application_name(_("Documents"));
- appid = 'org.gnome.Documents';
- }
+ GLib.set_application_name(_("Books"));
+ appid = 'org.gnome.Books';
// needed by data/ui/view-menu.ui
GObject.type_ensure(Gio.ThemedIcon);
@@ -144,7 +137,7 @@ var Application = new Lang.Class({
},
_onActionAbout: function() {
- this._mainWindow.showAbout(this.isBooks);
+ this._mainWindow.showAbout();
},
_onActionHelp: function() {
@@ -187,10 +180,7 @@ var Application = new Lang.Class({
EvDoc.init();
application = this;
- if (application.isBooks)
- settings = new Gio.Settings({ schema_id: 'org.gnome.books' });
- else
- settings = new Gio.Settings({ schema_id: 'org.gnome.documents' });
+ settings = new Gio.Settings({ schema_id: 'org.gnome.books' });
let gtkSettings = Gtk.Settings.get_default();
gtkSettings.connect('notify::gtk-theme-name', Lang.bind(this, this._themeChanged));
diff --git a/src/documents.js b/src/documents.js
index 396243a1..31c0ed86 100644
--- a/src/documents.js
+++ b/src/documents.js
@@ -463,10 +463,6 @@ const DocCommon = new Lang.Class({
throw(new Error('DocCommon implementations must override canEdit'));
},
- canShare: function() {
- throw(new Error('DocCommon implementations must override canShare'));
- },
-
canTrash: function() {
throw(new Error('DocCommon implementations must override canTrash'));
},
@@ -717,18 +713,7 @@ const DocCommon = new Lang.Class({
return;
}
- if (LOKView.isOpenDocumentFormat(this.mimeType) && !Application.application.isBooks) {
- let exception = null;
- if (!LOKView.isAvailable()) {
- exception = new GLib.Error(Gio.IOErrorEnum,
- Gio.IOErrorEnum.NOT_SUPPORTED,
- "Internal error: LibreOffice isn't available");
- }
- callback (this, null, exception);
- return;
- }
-
- if (EPUBView.isEpub(this.mimeType) && Application.application.isBooks) {
+ if (EPUBView.isEpub(this.mimeType)) {
callback(this, null, null);
return;
}
@@ -922,10 +907,6 @@ var LocalDocument = new Lang.Class({
return this.collection;
},
- canShare: function() {
- return false;
- },
-
canTrash: function() {
return true;
},
@@ -1086,10 +1067,7 @@ var DocumentManager = new Lang.Class({
if (error.domain == Gio.IOErrorEnum) {
switch (error.code) {
case Gio.IOErrorEnum.NOT_SUPPORTED:
- if (Application.application.isBooks)
- message = _("You are using a preview of Books. Full viewing capabilities are coming
soon!");
- else
- message = _("LibreOffice support is not available. Please contact your system
administrator.");
+ message = _("You are using a preview of Books. Full viewing capabilities are coming soon!");
break;
default:
break;
@@ -1130,9 +1108,7 @@ var DocumentManager = new Lang.Class({
_requestPreview: function(doc) {
let windowMode;
- if (LOKView.isOpenDocumentFormat(doc.mimeType) && !Application.application.isBooks) {
- windowMode = WindowMode.WindowMode.PREVIEW_LOK;
- } else if (EPUBView.isEpub(doc.mimeType) && Application.application.isBooks) {
+ if (EPUBView.isEpub(doc.mimeType)) {
windowMode = WindowMode.WindowMode.PREVIEW_EPUB;
} else {
windowMode = WindowMode.WindowMode.PREVIEW_EV;
diff --git a/src/epubview.js b/src/epubview.js
index 6f347265..5000ff6d 100644
--- a/src/epubview.js
+++ b/src/epubview.js
@@ -169,7 +169,7 @@ var EPUBView = new Lang.Class({
},
set nightMode(v) {
- if (this.view && Application.application.isBooks) {
+ if (this.view) {
if (v)
this.view.get_user_content_manager().add_style_sheet(this.invertedStyle);
else
diff --git a/src/evinceview.js b/src/evinceview.js
index 4d077f69..d83772b5 100644
--- a/src/evinceview.js
+++ b/src/evinceview.js
@@ -33,7 +33,6 @@ const Mainloop = imports.mainloop;
const Application = imports.application;
const Documents = imports.documents;
const Places = imports.places;
-const Presentation = imports.presentation;
const Preview = imports.preview;
const Utils = imports.utils;
const WindowMode = imports.windowMode;
@@ -121,16 +120,6 @@ var EvinceView = new Lang.Class({
this._bookmarks.remove(bookmark);
},
- _presentStateChanged: function(action) {
- if (!this._model)
- return;
-
- if (action.state.get_boolean())
- this._promptPresentation();
- else
- this._hidePresentation();
- },
-
_edit: function() {
Application.modeController.setWindowMode(WindowMode.WindowMode.EDIT);
},
@@ -198,13 +187,6 @@ var EvinceView = new Lang.Class({
accels: ['Page_Down'] }
];
- if (!Application.application.isBooks)
- actions.push({ name: 'present-current',
- callback: Utils.actionToggleCallback,
- state: GLib.Variant.new('b', false),
- stateChanged: Lang.bind(this, this._presentStateChanged),
- accels: ['F5'] });
-
return actions;
},
@@ -261,10 +243,7 @@ var EvinceView = new Lang.Class({
this.parent(manager, doc, docModel);
- if (Application.application.isBooks)
- docModel.set_sizing_mode(EvView.SizingMode.FIT_PAGE);
- else
- docModel.set_sizing_mode(EvView.SizingMode.AUTOMATIC);
+ docModel.set_sizing_mode(EvView.SizingMode.FIT_PAGE);
docModel.set_continuous(false);
docModel.set_page_layout(EvView.PageLayout.AUTOMATIC);
@@ -339,40 +318,6 @@ var EvinceView = new Lang.Class({
this.getAction('bookmark-page').change_state(GLib.Variant.new('b', hasBookmark));
},
- _hidePresentation: function() {
- if (this._presentation) {
- this._presentation.close();
- this._presentation = null;
- }
-
- this.getAction('present-current').change_state(GLib.Variant.new('b', false));
- },
-
- _showPresentation: function(output) {
- this._presentation = new Presentation.PresentationWindow(this._model);
- this._presentation.connect('destroy', Lang.bind(this, this._hidePresentation));
- if (output)
- this._presentation.setOutput(output);
- },
-
- _promptPresentation: function() {
- let outputs = new Presentation.PresentationOutputs();
- if (outputs.list.length < 2) {
- this._showPresentation();
- } else {
- let chooser = new Presentation.PresentationOutputChooser(outputs);
- chooser.connect('output-activated', Lang.bind(this,
- function(chooser, output) {
- if (output) {
- this._showPresentation(output);
- } else {
- this._hidePresentation();
- }
- }));
-
- }
- },
-
_onViewSelectionChanged: function() {
let hasSelection = this._evView.get_has_selection();
this.getAction('copy').enabled = hasSelection;
@@ -568,11 +513,6 @@ var EvinceView = new Lang.Class({
get canFullscreen() {
return true;
},
-
- set nightMode(v) {
- if (this._model && !Application.application.isBooks)
- this._model.set_inverted_colors(v);
- }
});
const EvinceViewNavControls = new Lang.Class({
diff --git a/src/lib/gd-utils.c b/src/lib/gd-utils.c
index bc40059a..201888dd 100644
--- a/src/lib/gd-utils.c
+++ b/src/lib/gd-utils.c
@@ -300,8 +300,7 @@ gd_ev_view_find_changed (EvView *view,
}
void
-gd_show_about_dialog (GtkWindow *parent,
- gboolean is_books)
+gd_show_about_dialog (GtkWindow *parent)
{
GApplication *app;
@@ -318,29 +317,18 @@ gd_show_about_dialog (GtkWindow *parent,
NULL
};
- const char *app_id, *comments, *website;
+ const char *app_id;
app = g_application_get_default ();
app_id = g_application_get_application_id (app);
- if(!is_books)
- {
- comments = _("A document manager application");
- website = "https://wiki.gnome.org/Apps/Documents";
- }
- else
- {
- comments = _("An e-books manager application");
- website = "https://wiki.gnome.org/Apps/Books";
- }
-
gtk_show_about_dialog (parent,
"artists", artists,
"authors", authors,
"translator-credits", _("translator-credits"),
- "comments", comments,
+ "comments", _("An e-books manager application"),
"logo-icon-name", app_id,
- "website", website,
+ "website", "https://wiki.gnome.org/Apps/Books",
"copyright", "Copyright © 2011-2014 Red Hat, Inc.",
"license-type", GTK_LICENSE_GPL_2_0,
"version", PACKAGE_VERSION,
diff --git a/src/lib/gd-utils.h b/src/lib/gd-utils.h
index b05fcb3b..536a3b9f 100644
--- a/src/lib/gd-utils.h
+++ b/src/lib/gd-utils.h
@@ -44,8 +44,7 @@ void gd_ev_view_find_changed (EvView *view,
EvJobFind *job,
gint page);
-void gd_show_about_dialog (GtkWindow *parent,
- gboolean is_books);
+void gd_show_about_dialog (GtkWindow *parent);
#endif /* __GD_UTILS_H__ */
diff --git a/src/mainWindow.js b/src/mainWindow.js
index e984a4d2..505a91ea 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -163,7 +163,7 @@ var MainWindow = new Lang.Class({
return false;
},
- showAbout: function(isBooks) {
- GdPrivate.show_about_dialog(this, isBooks);
+ showAbout: function() {
+ GdPrivate.show_about_dialog(this);
}
});
diff --git a/src/overview.js b/src/overview.js
index 6ee5f5b1..8e361503 100644
--- a/src/overview.js
+++ b/src/overview.js
@@ -274,7 +274,7 @@ const EmptyResultsBox = new Lang.Class({
if (this._mode == WindowMode.WindowMode.COLLECTIONS)
text = _("No collections found");
else
- text = Application.application.isBooks ? _("No books found") : _("No documents found");
+ text = _("No books found");
this.add(new Gtk.Label({ label: '<b><span size="large">' + text + '</span></b>',
use_markup: true,
@@ -289,48 +289,11 @@ const EmptyResultsBox = new Lang.Class({
if (this._mode == WindowMode.WindowMode.COLLECTIONS) {
let label;
- if (Application.application.isBooks)
- label = _("You can create collections from the Books view");
- else
- label = _("You can create collections from the Documents view");
+ label = _("You can create collections from the Books view");
this.add(new Gtk.Label({ label: label }));
return;
}
-
- if (Application.application.isBooks)
- return;
-
- let documentsPath = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DOCUMENTS);
- let detailsStr = _("Documents from your <a href=\"system-settings\">Online Accounts</a> and " +
- "<a href=\"file://%s\">Documents folder</a> will appear
here.").format(documentsPath);
- let details = new Gtk.Label({ label: detailsStr,
- use_markup: true });
- this.add(details);
-
- details.connect('activate-link', Lang.bind(this,
- function(label, uri) {
- if (uri != 'system-settings')
- return false;
-
- try {
- let app = Gio.AppInfo.create_from_commandline(
- 'gnome-control-center online-accounts', null, 0);
-
- let screen = this.get_screen();
- let display = screen ? screen.get_display() : Gdk.Display.get_default();
- let ctx = display.get_app_launch_context();
-
- if (screen)
- ctx.set_screen(screen);
-
- app.launch([], ctx);
- } catch(e) {
- logError(e, 'Unable to launch gnome-control-center');
- }
-
- return true;
- }));
}
});
@@ -1052,7 +1015,7 @@ var OverviewStack = new Lang.Class({
// now create the actual content widgets
this._documents = new ViewContainer(this, WindowMode.WindowMode.DOCUMENTS);
- let label = Application.application.isBooks ? _('Books') : _("Documents");
+ let label = _('Books');
this._stack.add_titled(this._documents, 'documents', label);
this._collections = new ViewContainer(this, WindowMode.WindowMode.COLLECTIONS);
diff --git a/src/preview.js b/src/preview.js
index 707d6386..2e67be2a 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -418,7 +418,7 @@ var PreviewToolbar = new Lang.Class({
action_name: 'view.gear-menu' });
this.toolbar.pack_end(menuButton);
- if (this.preview.canFullscreen && Application.application.isBooks) {
+ if (this.preview.canFullscreen) {
this._addFullscreenButton();
this._addNightmodeButton();
}
diff --git a/src/query.js b/src/query.js
index 554ce135..ae694479 100644
--- a/src/query.js
+++ b/src/query.js
@@ -50,7 +50,6 @@ var QueryFlags = {
};
var LOCAL_BOOKS_COLLECTIONS_IDENTIFIER = 'gb:collection:local:';
-var LOCAL_DOCUMENTS_COLLECTIONS_IDENTIFIER = 'gd:collection:local:';
var QueryBuilder = new Lang.Class({
Name: 'QueryBuilder',
@@ -258,10 +257,7 @@ var QueryBuilder = new Lang.Class({
buildCreateCollectionQuery: function(name) {
let application = Gio.Application.get_default();
let collectionsIdentifier;
- if (application.isBooks)
- collectionsIdentifier = LOCAL_BOOKS_COLLECTIONS_IDENTIFIER;
- else
- collectionsIdentifier = LOCAL_DOCUMENTS_COLLECTIONS_IDENTIFIER;
+ collectionsIdentifier = LOCAL_BOOKS_COLLECTIONS_IDENTIFIER;
let time = GdPrivate.iso8601_from_timestamp(GLib.get_real_time() / GLib.USEC_PER_SEC);
let sparql = ('INSERT { _:res a nfo:DataContainer ; a nie:DataObject ; ' +
diff --git a/src/search.js b/src/search.js
index c574bac3..bff2748b 100644
--- a/src/search.js
+++ b/src/search.js
@@ -116,49 +116,25 @@ const SearchTypeManager = new Lang.Class({
_init: function(context) {
// Translators: "Type" refers to a search filter on the document type
- // (PDF, spreadsheet, ...)
+ // (e-Books, Comics, ...)
this.parent(C_("Search Filter", "Type"), 'search-type', context);
this.addItem(new SearchType({ id: SearchTypeStock.ALL,
name: _("All") }));
- if (Application.application.isBooks) {
- this.addItem(new SearchType({ id: SearchTypeStock.COLLECTIONS,
- name: _("Collections"),
- filter: 'fn:starts-with(nao:identifier(?urn), \"gb:collection\")',
- where: '?urn rdf:type nfo:DataContainer .' }));
- //FIXME we need to remove all the non-Comics PDFs here
- } else {
- this.addItem(new SearchType({ id: SearchTypeStock.COLLECTIONS,
- name: _("Collections"),
- filter: 'fn:starts-with(nao:identifier(?urn), \"gd:collection\")',
- where: '?urn rdf:type nfo:DataContainer .' }));
- this.addItem(new SearchType({ id: SearchTypeStock.PDF,
- name: _("PDF Documents"),
- filter: 'fn:contains(nie:mimeType(?urn), \"application/pdf\")',
- where: '?urn rdf:type nfo:PaginatedTextDocument .' }));
- }
-
- if (Application.application.isBooks) {
- this.addItem(new SearchType({ id: SearchTypeStock.EBOOKS,
- name: _("e-Books"),
- filter: '(nie:mimeType(?urn) IN (\"application/epub+zip\",
\"application/x-mobipocket-ebook\", \"application/x-fictionbook+xml\", \"application/x-zip-compressed-fb2\",
\"image/vnd.djvu+multipage\"))',
- where: '?urn rdf:type nfo:EBook .' }));
- this.addItem(new SearchType({ id: SearchTypeStock.COMICS,
- name: _("Comics"),
- filter: '(nie:mimeType(?urn) IN (\"application/x-cbr\",
\"application/x-cbz\", \"application/vnd.comicbook+zip\", \"application/x-cbt\", \"application/x-cb7\"))',
- where: '?urn rdf:type nfo:EBook .' }));
- } else {
- this.addItem(new SearchType({ id: SearchTypeStock.PRESENTATIONS,
- name: _("Presentations"),
- where: '?urn rdf:type nfo:Presentation .' }));
- this.addItem(new SearchType({ id: SearchTypeStock.SPREADSHEETS,
- name: _("Spreadsheets"),
- where: '?urn rdf:type nfo:Spreadsheet .' }));
- this.addItem(new SearchType({ id: SearchTypeStock.TEXTDOCS,
- name: _("Text Documents"),
- filter: 'NOT EXISTS { ?urn a nfo:EBook }',
- where: '?urn rdf:type nfo:PaginatedTextDocument .' }));
- }
+ this.addItem(new SearchType({ id: SearchTypeStock.COLLECTIONS,
+ name: _("Collections"),
+ filter: 'fn:starts-with(nao:identifier(?urn), \"gb:collection\")',
+ where: '?urn rdf:type nfo:DataContainer .' }));
+ //FIXME we need to remove all the non-Comics PDFs here
+
+ this.addItem(new SearchType({ id: SearchTypeStock.EBOOKS,
+ name: _("e-Books"),
+ filter: '(nie:mimeType(?urn) IN (\"application/epub+zip\",
\"application/x-mobipocket-ebook\", \"application/x-fictionbook+xml\", \"application/x-zip-compressed-fb2\",
\"image/vnd.djvu+multipage\"))',
+ where: '?urn rdf:type nfo:EBook .' }));
+ this.addItem(new SearchType({ id: SearchTypeStock.COMICS,
+ name: _("Comics"),
+ filter: '(nie:mimeType(?urn) IN (\"application/x-cbr\",
\"application/x-cbz\", \"application/vnd.comicbook+zip\", \"application/x-cbt\", \"application/x-cb7\"))',
+ where: '?urn rdf:type nfo:EBook .' }));
this.setActiveItemById(SearchTypeStock.ALL);
@@ -176,15 +152,8 @@ const SearchTypeManager = new Lang.Class({
getDocumentTypes: function() {
let types = [];
- if (Application.application.isBooks) {
- types.push(this.getItemById(SearchTypeStock.EBOOKS));
- types.push(this.getItemById(SearchTypeStock.COMICS));
- } else {
- types.push(this.getItemById(SearchTypeStock.PDF));
- types.push(this.getItemById(SearchTypeStock.PRESENTATIONS));
- types.push(this.getItemById(SearchTypeStock.SPREADSHEETS));
- types.push(this.getItemById(SearchTypeStock.TEXTDOCS));
- }
+ types.push(this.getItemById(SearchTypeStock.EBOOKS));
+ types.push(this.getItemById(SearchTypeStock.COMICS));
return types;
},
@@ -393,10 +362,7 @@ const Source = new Lang.Class({
filters.push('(fn:contains (nie:url(?urn), "%s"))'.format(location.get_uri()));
}));
- if (Application.application.isBooks)
- filters.push('(fn:starts-with (nao:identifier(?urn), "gb:collection:local:"))');
- else
- filters.push('(fn:starts-with (nao:identifier(?urn), "gd:collection:local:"))');
+ filters.push('(fn:starts-with (nao:identifier(?urn), "gb:collection:local:"))');
return '(' + filters.join(' || ') + ')';
},
diff --git a/src/selections.js b/src/selections.js
index 47cc96e2..bb75c2a3 100644
--- a/src/selections.js
+++ b/src/selections.js
@@ -155,10 +155,7 @@ const FetchCollectionStateForSelectionJob = new Lang.Class({
let application = Gio.Application.get_default();
let collectionsIdentifier;
- if (application.isBooks)
- collectionsIdentifier = Query.LOCAL_BOOKS_COLLECTIONS_IDENTIFIER;
- else
- collectionsIdentifier = Query.LOCAL_DOCUMENTS_COLLECTIONS_IDENTIFIER;
+ collectionsIdentifier = Query.LOCAL_BOOKS_COLLECTIONS_IDENTIFIER;
for (let itemIdx in this._collectionsForItems) {
let item = Application.documentManager.getItemById(itemIdx);
@@ -851,7 +848,6 @@ var SelectionToolbar = new Lang.Class({
InternalChildren: [ 'toolbarOpen',
'toolbarPrint',
'toolbarTrash',
- 'toolbarShare',
'toolbarProperties',
'toolbarCollection' ],
@@ -869,10 +865,6 @@ var SelectionToolbar = new Lang.Class({
this._toolbarPrint.connect('clicked', Lang.bind(this, this._onToolbarPrint));
this._toolbarTrash.connect('clicked', Lang.bind(this, this._onToolbarTrash));
- if (!Application.application.isBooks) {
- this._toolbarShare.connect('clicked', Lang.bind(this, this._onToolbarShare));
- this._toolbarShare.show();
- }
this._toolbarProperties.connect('clicked', Lang.bind(this, this._onToolbarProperties));
this._toolbarCollection.connect('clicked', Lang.bind(this, this._onToolbarCollection));
@@ -944,7 +936,6 @@ var SelectionToolbar = new Lang.Class({
let showPrint = false;
let showProperties = hasSelection;
let showOpen = hasSelection;
- let showShare = hasSelection;
let showCollection = hasSelection;
this._insideRefresh = true;
@@ -956,10 +947,6 @@ var SelectionToolbar = new Lang.Class({
if ((doc.defaultAppName) &&
(apps.indexOf(doc.defaultAppName) == -1))
apps.push(doc.defaultAppName);
- if (!doc.canShare() ||
- (doc.collection != false) ||
- (selection.length > 1))
- showShare = false;
showTrash &= doc.canTrash();
}));
@@ -994,8 +981,6 @@ var SelectionToolbar = new Lang.Class({
this._toolbarProperties.set_sensitive(showProperties);
this._toolbarTrash.set_sensitive(showTrash);
this._toolbarOpen.set_sensitive(showOpen);
- if (!Application.application.isBooks)
- this._toolbarShare.set_sensitive(showShare);
this._toolbarCollection.set_sensitive(showCollection);
this._insideRefresh = false;
@@ -1059,16 +1044,6 @@ var SelectionToolbar = new Lang.Class({
}));
},
- _onToolbarShare: function(widget) {
- let dialog = new Sharing.SharingDialog();
-
- dialog.connect('response', Lang.bind(this,
- function(widget, response) {
- dialog.destroy();
- this._selectionModeAction.change_state(GLib.Variant.new('b', false));
- }));
- },
-
_onToolbarPrint: function(widget) {
let selection = Application.selectionController.getSelection();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]