[gnome-characters/bilelmoussaoui/gtk4] couple of code fixes & remove dead code
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-characters/bilelmoussaoui/gtk4] couple of code fixes & remove dead code
- Date: Tue, 23 Nov 2021 07:58:49 +0000 (UTC)
commit 139fba20ab2b2941f8327100c929e1cb59dec075
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Tue Nov 23 08:58:43 2021 +0100
couple of code fixes & remove dead code
src/characterDialog.js | 5 ++---
src/charactersView.js | 15 ++++++-------
src/searchProvider.js | 20 ++++++++---------
src/service.js | 6 +++--
src/sidebar.js | 5 ++++-
src/util.js | 13 +++++------
src/window.js | 61 +++++++++++++++++++++-----------------------------
7 files changed, 57 insertions(+), 68 deletions(-)
---
diff --git a/src/characterDialog.js b/src/characterDialog.js
index 4837e54..795c535 100644
--- a/src/characterDialog.js
+++ b/src/characterDialog.js
@@ -112,9 +112,8 @@ var CharacterDialog = GObject.registerClass({
this._characterStack.visible_child_name = 'character';
} else {
var fontFamily = this._fontDescription.get_family();
- this._missingLabel.label =
- // TRANSLATORS: the first variable is a character, the second is a font
- _('%s is not included in %s').format(name, fontFamily);
+ // TRANSLATORS: the first variable is a character, the second is a font
+ this._missingLabel.label = _('%s is not included in %s').format(name, fontFamily);
this._characterStack.visible_child_name = 'missing';
}
diff --git a/src/charactersView.js b/src/charactersView.js
index e144eac..506806d 100644
--- a/src/charactersView.js
+++ b/src/charactersView.js
@@ -1,4 +1,4 @@
-/* exported CharactersView FontFilter RecentCharacterListView */
+/* exported CharactersView FontFilter */
// -*- Mode: js; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*-
//
// Copyright (C) 2014-2015 Daiki Ueno <dueno src gnome org>
@@ -17,7 +17,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-const { Adw, Gc, Gdk, GLib, Gio, GObject, Gtk, Pango, Graphene, PangoCairo } = imports.gi;
+const { Gc, Gdk, GLib, Gio, GObject, Gtk, Pango, Graphene, PangoCairo } = imports.gi;
const Main = imports.main;
const Util = imports.util;
@@ -43,7 +43,6 @@ const CharacterListRow = GObject.registerClass({
this._characters = characters;
this._fontDescription = fontDescription;
this._overlayFontDescription = overlayFontDescription;
- this._styleManager = Adw.StyleManager.get_default();
}
draw(cr, x, y, width, height, styleContext) {
@@ -188,8 +187,9 @@ var FontFilter = GObject.registerClass({
Properties: {
'font': GObject.ParamSpec.string(
'font', '', '',
- GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
- 'Cantarell 50'),
+ GObject.ParamFlags.READWRITE,
+ 'Cantarell 50',
+ ),
},
Signals: {
'filter-set': { param_types: [] },
@@ -297,8 +297,7 @@ var CharactersView = GObject.registerClass({
this._cellsPerRow = CELLS_PER_ROW;
this._numRows = NUM_ROWS;
this._rows = [];
- /* this.add_events(Gdk.EventMask.BUTTON_PRESS_MASK |
- Gdk.EventMask.BUTTON_RELEASE_MASK);
+ /*
this.drag_source_set(Gdk.ModifierType.BUTTON1_MASK,
null,
Gdk.DragAction.COPY);
@@ -354,7 +353,7 @@ var CharactersView = GObject.registerClass({
}
*/
- onButtonPress(gesture, nPress, x, y) {
+ onButtonPress(_gesture, _nPress, x, y) {
let hadj = this.get_hadjustment();
let vadj = this.get_vadjustment();
diff --git a/src/searchProvider.js b/src/searchProvider.js
index 910a1d6..2ec6634 100644
--- a/src/searchProvider.js
+++ b/src/searchProvider.js
@@ -52,12 +52,12 @@ var SearchProvider = GObject.registerClass({
let upper = keywords.map(x => x.toUpperCase());
let criteria = Gc.SearchCriteria.new_keywords(upper);
- let context = new Gc.SearchContext({ criteria,
- flags: Gc.SearchFlag.WORD });
+ let context = new Gc.SearchContext({ criteria, flags: Gc.SearchFlag.WORD });
+
context.search(
MAX_SEARCH_RESULTS,
this._cancellable,
- (sourceObject, res, _userData) => {
+ (_source, res, _userData) => {
let characters = [];
try {
let result = context.search_finish(res);
@@ -95,14 +95,15 @@ var SearchProvider = GObject.registerClass({
name = _('Unknown character name');
else
name = Util.capitalize(name);
- let summary = _('U+%s, %s: %s').format(codePointHex,
- character,
- name);
- ret.push({ name: new GLib.Variant('s', name),
+ let summary = _('U+%s, %s: %s').format(codePointHex, character, name);
+
+ ret.push({
+ name: new GLib.Variant('s', name),
id: new GLib.Variant('s', identifiers[i]),
description: new GLib.Variant('s', summary),
icon: new Gio.ThemedIcon({ name: Service.applicationId }).serialize(),
- clipboardText: new GLib.Variant('s', character) });
+ clipboardText: new GLib.Variant('s', character),
+ });
}
this._app.release();
@@ -152,7 +153,6 @@ var SearchProvider = GObject.registerClass({
}
LaunchSearch(terms, timestamp) {
- this._activateAction('search', new GLib.Variant('as', terms),
- timestamp);
+ this._activateAction('search', new GLib.Variant('as', terms), timestamp);
}
});
diff --git a/src/service.js b/src/service.js
index e66eb30..be1ff6b 100644
--- a/src/service.js
+++ b/src/service.js
@@ -39,9 +39,11 @@ const BackgroundService = GObject.registerClass({
// to get Gtk.Clipboard working.
}, class BackgroundService extends Gtk.Application {
_init() {
- super._init({ application_id: pkg.name,
+ super._init({
+ application_id: applicationId,
flags: Gio.ApplicationFlags.IS_SERVICE,
- inactivity_timeout: 30000 });
+ inactivity_timeout: 30000,
+ });
GLib.set_application_name(_('Characters'));
this._searchProvider = new SearchProvider.SearchProvider(this);
diff --git a/src/sidebar.js b/src/sidebar.js
index 4283bd5..48c613c 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -41,7 +41,10 @@ var Sidebar = GObject.registerClass({
this.lastSelectedRow = null;
}
- restorePreviousSelection() {
+ /**
+ * Restore the latest selected item
+ */
+ restoreSelection() {
if (this.lastSelectedRow)
this._list.select_row(this.lastSelectedRow);
}
diff --git a/src/util.js b/src/util.js
index e52f03c..45492f1 100644
--- a/src/util.js
+++ b/src/util.js
@@ -51,9 +51,7 @@ function getSettings(schemaId, path) {
if (!pkg.moduledir.startsWith('resource://')) {
// Running from the source tree
- schemaSource = GioSSS.new_from_directory(pkg.pkgdatadir,
- GioSSS.get_default(),
- false);
+ schemaSource = GioSSS.new_from_directory(pkg.pkgdatadir, GioSSS.get_default(), false);
} else {
schemaSource = GioSSS.get_default();
}
@@ -64,12 +62,11 @@ function getSettings(schemaId, path) {
System.exit(1);
}
- if (path === undefined) {
+ if (path === undefined)
return new Gio.Settings({ settings_schema: schemaObj });
- } else {
- return new Gio.Settings({ settings_schema: schemaObj,
- path });
- }
+ else
+ return new Gio.Settings({ settings_schema: schemaObj, path });
+
}
function capitalizeWord(w) {
diff --git a/src/window.js b/src/window.js
index cffeea3..e1b5523 100644
--- a/src/window.js
+++ b/src/window.js
@@ -28,8 +28,8 @@
const { Adw, Gio, GLib, GObject, Gtk } = imports.gi;
const { CharacterDialog } = imports.characterDialog;
-const { FontFilter, RecentCharacterListView } = imports.charactersView;
-const Gettext = imports.gettext;
+const { FontFilter } = imports.charactersView;
+const { gettext } = imports.gettext;
const Main = imports.main;
const Util = imports.util;
@@ -142,21 +142,16 @@ var MainWindow = GObject.registerClass({
vfunc_map() {
super.vfunc_map();
- this._selectFirstSubcategory();
- }
-
- _togglePrimaryMenu(action) {
- let state = action.get_state().get_boolean();
- action.set_state(GLib.Variant.new_boolean(!state));
- }
-
- // Select the first subcategory which contains at least one character.
- _selectFirstSubcategory() {
+ // Select the first subcategory which contains at least one character.
if (this.recentCharacters.length !== 0)
this._sidebar.selectRowByName('recent');
else
this._sidebar.selectRowByName('smileys');
+ }
+ _togglePrimaryMenu(action) {
+ let state = action.get_state().get_boolean();
+ action.set_state(GLib.Variant.new_boolean(!state));
}
get searchActive() {
@@ -173,7 +168,7 @@ var MainWindow = GObject.registerClass({
this._sidebar.list.unselect_all();
this._updateTitle(_('Search Result'));
} else {
- this._sidebar.restorePreviousSelection();
+ this._sidebar.restoreSelection();
}
this.notify('search-active');
@@ -199,11 +194,15 @@ var MainWindow = GObject.registerClass({
}
_about() {
- const aboutDialog = new Gtk.AboutDialog(
- { artists: ['Allan Day <allanpday gmail com>',
- 'Jakub Steiner <jimmac gmail com>'],
- authors: ['Daiki Ueno <dueno src gnome org>',
- 'Giovanni Campagna <scampa giovanni gmail com>'],
+ const aboutDialog = new Gtk.AboutDialog({
+ artists: [
+ 'Allan Day <allanpday gmail com>',
+ 'Jakub Steiner <jimmac gmail com>',
+ ],
+ authors: [
+ 'Daiki Ueno <dueno src gnome org>',
+ 'Giovanni Campagna <scampa giovanni gmail com>',
+ ],
// TRANSLATORS: put your names here, one name per line.
translator_credits: _('translator-credits'),
program_name: _('GNOME Characters'),
@@ -215,19 +214,18 @@ var MainWindow = GObject.registerClass({
website: 'https://wiki.gnome.org/Apps/Characters',
wrap_license: true,
modal: true,
- transient_for: this });
+ transient_for: this,
+ });
aboutDialog.show();
}
_updateTitle(title) {
- if (this.filterFontFamily) {
- this._windowTitle.title =
- _('%s (%s only)').format(Gettext.gettext(title),
- this.filterFontFamily);
- } else {
- this._windowTitle.title = Gettext.gettext(title);
- }
+ if (this.filterFontFamily)
+ this._windowTitle.title = _('%s (%s only)').format(gettext(title), this.filterFontFamily);
+ else
+ this._windowTitle.title = gettext(title);
+
}
_character(action, v) {
@@ -240,7 +238,7 @@ var MainWindow = GObject.registerClass({
if (family === 'None')
family = null;
this.filterFontFamily = family;
- // this._updateTitle(this._stack.visible_child.title);
+ this._updateTitle(this._windowTitle.title);
this._menuPopover.hide();
}
@@ -274,15 +272,6 @@ var MainWindow = GObject.registerClass({
this._fontFilter.setFilterFont(this._filterFontFamily);
}
- _createRecentCharacterList(name, accessibleName, category) {
- const characterList = new RecentCharacterListView(category, this._fontFilter);
- // characterList.get_accessible().accessible_name = accessibleName;
- characterList.connect('character-selected', (widget, uc) => this._handleCharacterSelected(widget,
uc));
-
- this._characterLists[name] = characterList;
- return characterList;
- }
-
searchByKeywords(keywords) {
let totalResults = this._charactersView.searchByKeywords(keywords);
if (totalResults === 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]