[gnome-characters/bilelmoussaoui/shortcuts: 2/3] linter: automatically fix linting issues
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-characters/bilelmoussaoui/shortcuts: 2/3] linter: automatically fix linting issues
- Date: Fri, 19 Feb 2021 08:43:36 +0000 (UTC)
commit c0dc25aed5e4fb1413ed7a44f36ac51d525457ec
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Sat Feb 13 12:48:15 2021 +0100
linter: automatically fix linting issues
src/categoryList.js | 75 +++++++++++++-------------
src/characterDialog.js | 58 ++++++++++----------
src/characterList.js | 117 ++++++++++++++++++++--------------------
src/main.js | 44 +++++++--------
src/menu.js | 22 ++++----
src/params.js | 2 +-
src/searchProvider.js | 59 ++++++++++----------
src/service.js | 22 ++++----
src/util.js | 46 ++++++++--------
src/window.js | 143 +++++++++++++++++++++++++------------------------
10 files changed, 292 insertions(+), 296 deletions(-)
---
diff --git a/src/categoryList.js b/src/categoryList.js
index 5a6f27a..a78aa30 100644
--- a/src/categoryList.js
+++ b/src/categoryList.js
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-const {Gc, GLib, GObject, Gtk, GnomeDesktop} = imports.gi;
+const { Gc, GLib, GObject, Gtk, GnomeDesktop } = imports.gi;
const Gettext = imports.gettext;
const Params = imports.params;
@@ -36,7 +36,7 @@ const CategoryList = [
category: Gc.Category.LETTER,
title: N_('Letters & Symbols'),
icon_name: 'characters-latin-symbolic',
- }
+ },
];
const LetterCategoryList = [
@@ -81,7 +81,7 @@ const LetterCategoryList = [
category: Gc.Category.LETTER_LATIN,
title: N_('Letters'),
icon_name: 'characters-latin-symbolic',
- }
+ },
];
const EmojiCategoryList = [
@@ -132,13 +132,12 @@ const EmojiCategoryList = [
category: Gc.Category.EMOJI_FLAGS,
title: N_('Flags'),
icon_name: 'characters-emoji-flags',
- }
+ },
];
const CategoryListRowWidget = GObject.registerClass({
}, class CategoryListRowWidget extends Gtk.ListBoxRow {
-
- _init (params, category) {
+ _init(params, category) {
params = Params.fill(params, {});
super._init(params);
this.category = category;
@@ -153,10 +152,9 @@ const CategoryListRowWidget = GObject.registerClass({
hbox.pack_start(image, false, false, 2);
let label = new Gtk.Label({ label: Gettext.gettext(category.title),
- halign: Gtk.Align.START });
+ halign: Gtk.Align.START });
label.get_style_context().add_class('category-label');
hbox.pack_start(label, true, true, 0);
-
}
});
@@ -188,6 +186,7 @@ const CategoryListWidget = GObject.registerClass({
this._lastSelectedRow = row;
}
}
+
populateCategoryList() {
}
@@ -205,15 +204,14 @@ const CategoryListWidget = GObject.registerClass({
}
restorePreviousSelection() {
- if (this._lastSelectedRow) {
- this.select_row(this._lastSelectedRow)
- }
+ if (this._lastSelectedRow)
+ this.select_row(this._lastSelectedRow);
}
unselect() {
- let selected = this.get_selected_row()
+ let selected = this.get_selected_row();
if (selected)
- this.unselect_row(selected)
+ this.unselect_row(selected);
}
});
@@ -253,9 +251,9 @@ const LetterCategoryListWidget = GObject.registerClass({
ibus.init();
let bus = new ibus.Bus();
- if (bus.is_connected()) {
+ if (bus.is_connected())
bus.list_engines_async(-1, null, (sources, bus, res) => this._finishListEngines(sources, bus,
res));
- } else
+ else
this._finishBuildScriptList(sources);
}
@@ -324,10 +322,10 @@ const LetterCategoryListWidget = GObject.registerClass({
//
let settings =
Util.getSettings('org.gnome.desktop.input-sources',
- '/org/gnome/desktop/input-sources/');
+ '/org/gnome/desktop/input-sources/');
if (settings) {
let sources = settings.get_value('sources').deep_unpack();
- let hasIBus = sources.some(function(current, index, array) {
+ let hasIBus = sources.some((current, index, array) => {
return current[0] == 'ibus';
});
if (hasIBus)
@@ -365,7 +363,7 @@ const RecentCategoryListWidget = GObject.registerClass({
this.recentRow = new CategoryListRowWidget({}, this.recentCategory);
this.recentRow.get_style_context().add_class('category');
this.recentRow.get_style_context().add_class('recent-category');
- this.add(this.recentRow)
+ this.add(this.recentRow);
}
getCategory(name) {
@@ -391,22 +389,22 @@ var CategoryListView = GObject.registerClass({
this._lastSelectedList = list;
list.select_row(row);
});
- this.add(this._recentCategoryList)
- this.add(new Gtk.Separator({orientation: Gtk.Orientation.HORIZONTAL}));
-
- let emojis_label = new Gtk.Label ({
+ this.add(this._recentCategoryList);
+ this.add(new Gtk.Separator({ orientation: Gtk.Orientation.HORIZONTAL }));
+
+ let emojis_label = new Gtk.Label({
label: CategoryList[0].title,
halign: Gtk.Align.START,
margin_top: 12,
margin_start: 12,
margin_bottom: 12,
margin_end: 12,
- });
- emojis_label.get_style_context().add_class("heading");
+ });
+ emojis_label.get_style_context().add_class('heading');
this.add(emojis_label);
this._emojiCategoryList = new EmojiCategoryListWidget({
- categoryList: EmojiCategoryList
+ categoryList: EmojiCategoryList,
});
this._emojiCategoryList.connect('row-selected', (list, row) => {
this._letterCategoryList.unselect();
@@ -416,7 +414,7 @@ var CategoryListView = GObject.registerClass({
});
this.add(this._emojiCategoryList);
- let letters_label = new Gtk.Label ({
+ let letters_label = new Gtk.Label({
label: CategoryList[1].title,
halign: Gtk.Align.START,
margin_top: 12,
@@ -424,11 +422,11 @@ var CategoryListView = GObject.registerClass({
margin_bottom: 12,
margin_end: 12,
});
- letters_label.get_style_context().add_class("heading");
+ letters_label.get_style_context().add_class('heading');
this.add(letters_label);
this._letterCategoryList = new LetterCategoryListWidget({
- categoryList: LetterCategoryList
+ categoryList: LetterCategoryList,
});
this._letterCategoryList.connect('row-selected', (list, row) => {
this._emojiCategoryList.unselect();
@@ -443,12 +441,12 @@ var CategoryListView = GObject.registerClass({
getCategoryByName(name) {
switch (name) {
- case 'emojis':
- return this._emojiCategoryList
- case 'recent':
- return this._recentCategoryList
- default:
- return this._letterCategoryList
+ case 'emojis':
+ return this._emojiCategoryList;
+ case 'recent':
+ return this._recentCategoryList;
+ default:
+ return this._letterCategoryList;
}
}
@@ -457,13 +455,12 @@ var CategoryListView = GObject.registerClass({
}
get selectedList() {
- return this._lastSelectedList
+ return this._lastSelectedList;
}
-
+
restorePreviousSelection() {
- if (this._lastSelectedList) {
- this._lastSelectedList.restorePreviousSelection()
- }
+ if (this._lastSelectedList)
+ this._lastSelectedList.restorePreviousSelection();
}
});
diff --git a/src/characterDialog.js b/src/characterDialog.js
index 49f8139..5e2e25a 100644
--- a/src/characterDialog.js
+++ b/src/characterDialog.js
@@ -16,7 +16,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 {Gc, GLib, Gio,GObject,Gtk, Pango} = imports.gi;
+const { Gc, GLib, Gio, GObject, Gtk, Pango } = imports.gi;
const Params = imports.params;
@@ -25,19 +25,19 @@ const Util = imports.util;
var CharacterDialog = GObject.registerClass({
Signals: {
- 'character-copied': { param_types: [ GObject.TYPE_STRING ] }
+ 'character-copied': { param_types: [GObject.TYPE_STRING] },
},
Template: 'resource:///org/gnome/Characters/character.ui',
InternalChildren: ['main-stack', 'character-stack',
- 'character-label', 'missing-label', 'detail-label',
- 'copy-button', 'copy-revealer', 'related-listbox'],
+ 'character-label', 'missing-label', 'detail-label',
+ 'copy-button', 'copy-revealer', 'related-listbox'],
}, class CharacterDialog extends Gtk.Dialog {
_init(params) {
const filtered = Params.filter(params, { character: null,
- fontDescription: null });
+ fontDescription: null });
params = Params.fill(params, { use_header_bar: true,
- width_request: 400,
- height_request: 400 });
+ width_request: 400,
+ height_request: 400 });
super._init(params);
this._cancellable = new Gio.Cancellable();
@@ -46,16 +46,16 @@ var CharacterDialog = GObject.registerClass({
this._related_listbox.connect('row-selected', (listBox, row) => this._handleRowSelected(listBox,
row));
- this._relatedButton = new Gtk.ToggleButton({ label: _("See Also") });
+ this._relatedButton = new Gtk.ToggleButton({ label: _('See Also') });
this.add_action_widget(this._relatedButton, Gtk.ResponseType.HELP);
this._relatedButton.show();
this._relatedButton.connect('toggled', () => {
- if (this._main_stack.visible_child_name == 'character')
- this._main_stack.visible_child_name = 'related';
- else
- this._main_stack.visible_child_name = 'character';
- });
+ if (this._main_stack.visible_child_name == 'character')
+ this._main_stack.visible_child_name = 'related';
+ else
+ this._main_stack.visible_child_name = 'character';
+ });
this._fontDescription = filtered.fontDescription;
this._setCharacter(filtered.character);
@@ -77,15 +77,15 @@ var CharacterDialog = GObject.registerClass({
let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL });
let characterLabel = new Gtk.Label({ label: uc,
- valign: Gtk.Align.CENTER,
- halign: Gtk.Align.CENTER,
- width_request: 45 });
+ valign: Gtk.Align.CENTER,
+ halign: Gtk.Align.CENTER,
+ width_request: 45 });
characterLabel.get_style_context().add_class('character');
hbox.pack_start(characterLabel, false, false, 2);
let nameLabel = new Gtk.Label({ label: Util.capitalize(name),
- halign: Gtk.Align.START,
- ellipsize: Pango.EllipsizeMode.END });
+ halign: Gtk.Align.START,
+ ellipsize: Pango.EllipsizeMode.END });
hbox.pack_start(nameLabel, true, true, 0);
let row = new Gtk.ListBoxRow();
@@ -107,11 +107,11 @@ var CharacterDialog = GObject.registerClass({
let codePointHex = codePoint.toString(16).toUpperCase();
let name = Gc.character_name(this._character);
- if (name != null) {
+ if (name != null)
name = Util.capitalize(name);
- } else {
- name = _("Unicode U+%04s").format(codePointHex);
- }
+ else
+ name = _('Unicode U+%04s').format(codePointHex);
+
let headerBar = this.get_header_bar();
headerBar.title = name;
@@ -128,16 +128,16 @@ var CharacterDialog = GObject.registerClass({
var fontFamily = this._fontDescription.get_family();
this._missing_label.label =
// TRANSLATORS: the first variable is a character, the second is a font
- _("%s is not included in %s").format(name, fontFamily);
+ _('%s is not included in %s').format(name, fontFamily);
this._character_stack.visible_child_name = 'missing';
}
- this._detail_label.label = _("Unicode U+%04s").format(codePointHex);
+ this._detail_label.label = _('Unicode U+%04s').format(codePointHex);
this._cancellable.cancel();
this._cancellable.reset();
let criteria = Gc.SearchCriteria.new_related(this._character);
- let context = new Gc.SearchContext({ criteria: criteria });
+ let context = new Gc.SearchContext({ criteria });
context.search(
-1,
this._cancellable,
@@ -173,7 +173,7 @@ var CharacterDialog = GObject.registerClass({
if (this._clipboard == null) {
this._clipboard = Gc.gtk_clipboard_get();
let clipboardOwnerChanged =
- this._clipboard.connect('owner-change', (clipboard) =>
this._clipboardOwnerChanged(clipboard));
+ this._clipboard.connect('owner-change', clipboard => this._clipboardOwnerChanged(clipboard));
this.connect('destroy', () => this._clipboard.disconnect(clipboardOwnerChanged));
}
this._clipboard.set_text(this._character, -1);
@@ -187,9 +187,9 @@ var CharacterDialog = GObject.registerClass({
this._copyRevealerTimeoutId =
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 2000, () => this._hideCopyRevealer());
this.connect('destroy', () => {
- if (this._copyRevealerTimeoutId > 0)
- GLib.source_remove(this._copyRevealerTimeoutId);
- });
+ if (this._copyRevealerTimeoutId > 0)
+ GLib.source_remove(this._copyRevealerTimeoutId);
+ });
}
_handleRowSelected(listBox, row) {
diff --git a/src/characterList.js b/src/characterList.js
index 123ab22..ffb7ef0 100644
--- a/src/characterList.js
+++ b/src/characterList.js
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
const Params = imports.params;
-const {Gc, Gdk, GLib, Gio,GObject,Gtk, Pango, PangoCairo} = imports.gi;
+const { Gc, Gdk, GLib, Gio, GObject, Gtk, Pango, PangoCairo } = imports.gi;
const Cairo = imports.cairo;
@@ -40,8 +40,8 @@ const CharacterListRow = GObject.registerClass({
}, class CharacterListRow extends GObject.Object {
_init(params) {
const filtered = Params.filter(params, { characters: null,
- fontDescription: null,
- overlayFontDescription: null });
+ fontDescription: null,
+ overlayFontDescription: null });
params = Params.fill(params, {});
super._init(params);
this._characters = filtered.characters;
@@ -66,20 +66,20 @@ const CharacterListRow = GObject.registerClass({
let cellSize = getCellSize(this._fontDescription);
for (let i in this._characters) {
var cellRect = new Gdk.Rectangle({ x: x + cellSize * i,
- y: y,
- width: cellSize,
- height: cellSize });
+ y,
+ width: cellSize,
+ height: cellSize });
if (Gc.character_is_invisible(this._characters[i])) {
this._drawBoundingBox(cr, cellRect, this._characters[i]);
this._drawCharacterName(cr, cellRect, this._characters[i]);
} else {
layout.set_text(this._characters[i], -1);
- if (layout.get_unknown_glyphs_count () == 0) {
+ if (layout.get_unknown_glyphs_count() == 0) {
let layoutBaseline = layout.get_baseline();
let [logicalRect, inkRect] = layout.get_extents();
cr.moveTo(x + cellSize * i - logicalRect.x / Pango.SCALE +
(cellSize - logicalRect.width / Pango.SCALE) / 2,
- y + BASELINE_OFFSET * height -
+ y + BASELINE_OFFSET * height -
layoutBaseline / Pango.SCALE);
PangoCairo.show_layout(cr, layout);
} else {
@@ -116,9 +116,9 @@ const CharacterListRow = GObject.registerClass({
x: this._baseGlyphRect.x,
y: this._baseGlyphRect.y,
width: this._baseGlyphRect.width,
- height: this._baseGlyphRect.height
+ height: this._baseGlyphRect.height,
});
- let characterWidth = Gc.character_width (uc);
+ let characterWidth = Gc.character_width(uc);
if (characterWidth > 1)
shapeRect.width *= characterWidth;
}
@@ -127,8 +127,8 @@ const CharacterListRow = GObject.registerClass({
(cellRect.width - shapeRect.width / Pango.SCALE) / 2;
shapeRect.y = cellRect.y + BASELINE_OFFSET * cellRect.height -
layoutBaseline / Pango.SCALE;
- shapeRect.width = shapeRect.width / Pango.SCALE;
- shapeRect.height = shapeRect.height / Pango.SCALE;
+ shapeRect.width /= Pango.SCALE;
+ shapeRect.height /= Pango.SCALE;
return shapeRect;
}
@@ -144,9 +144,9 @@ const CharacterListRow = GObject.registerClass({
let borderWidth = 1;
cr.rectangle(shapeRect.x - borderWidth * 2,
- shapeRect.y - borderWidth * 2,
- shapeRect.width + borderWidth * 2,
- shapeRect.height + borderWidth * 2);
+ shapeRect.y - borderWidth * 2,
+ shapeRect.width + borderWidth * 2,
+ shapeRect.height + borderWidth * 2);
cr.setSourceRGBA(239.0 / 255.0, 239.0 / 255.0, 239.0 / 255.0, 1.0);
cr.fill();
@@ -171,7 +171,7 @@ const CharacterListRow = GObject.registerClass({
let [logicalRect, inkRect] = layout.get_extents();
cr.moveTo(cellRect.x - logicalRect.x / Pango.SCALE +
(cellRect.width - logicalRect.width / Pango.SCALE) / 2,
- cellRect.y - logicalRect.y / Pango.SCALE +
+ cellRect.y - logicalRect.y / Pango.SCALE +
(cellRect.height - logicalRect.height / Pango.SCALE) / 2);
cr.setSourceRGBA(0.0, 0.0, 0.0, 1.0);
PangoCairo.show_layout(cr, layout);
@@ -182,13 +182,13 @@ const CharacterListRow = GObject.registerClass({
const CharacterListWidget = GObject.registerClass({
Signals: {
- 'character-selected': { param_types: [ GObject.TYPE_STRING ] }
+ 'character-selected': { param_types: [GObject.TYPE_STRING] },
},
}, class CharacterListWidget extends Gtk.DrawingArea {
_init(params) {
const filtered = Params.filter(params, {
fontDescription: null,
- numRows: NUM_ROWS
+ numRows: NUM_ROWS,
});
params = Params.fill(params, {});
super._init(params);
@@ -204,16 +204,16 @@ const CharacterListWidget = GObject.registerClass({
Gdk.EventMask.BUTTON_RELEASE_MASK);
this._character = null;
this.drag_source_set(Gdk.ModifierType.BUTTON1_MASK,
- null,
- Gdk.DragAction.COPY);
+ null,
+ Gdk.DragAction.COPY);
this.drag_source_add_text_targets();
}
vfunc_drag_begin(context) {
let cellSize = getCellSize(this._fontDescription);
this._dragSurface = new Cairo.ImageSurface(Cairo.Format.ARGB32,
- cellSize,
- cellSize);
+ cellSize,
+ cellSize);
let cr = new Cairo.Context(this._dragSurface);
cr.setSourceRGBA(1.0, 1.0, 1.0, 1.0);
cr.paint();
@@ -290,9 +290,9 @@ const CharacterListWidget = GObject.registerClass({
var fontDescription = context.get_font_description();
fontDescription.set_size(fontDescription.get_size() * 0.8);
let row = new CharacterListRow({
- characters: characters,
+ characters,
fontDescription: this._fontDescription,
- overlayFontDescription: fontDescription
+ overlayFontDescription: fontDescription,
});
return row;
}
@@ -346,7 +346,7 @@ const CharacterListWidget = GObject.registerClass({
let end = Math.min(this._rows.length, Math.ceil(y2 / cellSize));
for (let index = start; index < end; index++) {
this._rows[index].draw(cr, 0, index * cellSize,
- allocation.width, cellSize);
+ allocation.width, cellSize);
}
}
});
@@ -358,10 +358,10 @@ var FontFilter = GObject.registerClass({
'font': GObject.ParamSpec.string(
'font', '', '',
GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
- 'Cantarell 50')
+ 'Cantarell 50'),
},
Signals: {
- 'filter-set': { param_types: [] }
+ 'filter-set': { param_types: [] },
},
}, class FontFilter extends GObject.Object {
get font() {
@@ -438,7 +438,7 @@ var CharacterListView = GObject.registerClass({
Template: 'resource:///org/gnome/Characters/characterlist.ui',
InternalChildren: ['loading-spinner'],
Signals: {
- 'character-selected': { param_types: [ GObject.TYPE_STRING ] }
+ 'character-selected': { param_types: [GObject.TYPE_STRING] },
},
}, class CharacterListView extends Gtk.Stack {
_init(params) {
@@ -447,7 +447,7 @@ var CharacterListView = GObject.registerClass({
});
params = Params.fill(params, {
hexpand: true, vexpand: true,
- transition_type: Gtk.StackTransitionType.CROSSFADE
+ transition_type: Gtk.StackTransitionType.CROSSFADE,
});
super._init(params);
@@ -455,12 +455,12 @@ var CharacterListView = GObject.registerClass({
this._characterList = new CharacterListWidget({
hexpand: true,
vexpand: true,
- fontDescription: this._fontFilter.fontDescription
+ fontDescription: this._fontFilter.fontDescription,
});
this._characterList.connect('character-selected', (w, c) => this.emit('character-selected', c));
let scroll = new Gtk.ScrolledWindow({
hscrollbar_policy: Gtk.PolicyType.NEVER,
- visible: true
+ visible: true,
});
scroll.add(this._characterList);
@@ -491,10 +491,10 @@ var CharacterListView = GObject.registerClass({
this._stopSpinner();
this._spinnerTimeoutId =
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, () => {
- this._loading_spinner.start();
- this.visible_child_name = 'loading';
- this.show_all();
- });
+ this._loading_spinner.start();
+ this.visible_child_name = 'loading';
+ this.show_all();
+ });
}
_stopSpinner() {
@@ -522,24 +522,22 @@ var CharacterListView = GObject.registerClass({
const [fontDescription, characters] = this._fontFilter.apply(this, this._characters);
this._characterList.setFontDescription(fontDescription);
this._characterList.setCharacters(characters);
- if (characters.length == 0) {
+ if (characters.length == 0)
this.visible_child_name = 'unavailable';
- } else {
+ else
this.visible_child_name = 'character-list';
- }
+
this.show_all();
}
_maybeLoadMore() {
- if (this._searchContext != null && !this._searchContext.is_finished()) {
+ if (this._searchContext != null && !this._searchContext.is_finished())
this._searchWithContext(this._searchContext, MAX_SEARCH_RESULTS);
- }
}
_onEdgeReached(scrolled, pos) {
- if (pos == Gtk.PositionType.BOTTOM) {
+ if (pos == Gtk.PositionType.BOTTOM)
this._maybeLoadMore();
- }
}
get initialSearchCount() {
@@ -559,9 +557,8 @@ var CharacterListView = GObject.registerClass({
}
_onSizeAllocate(scrolled, allocation) {
- if (this._characters.length < this.initialSearchCount) {
+ if (this._characters.length < this.initialSearchCount)
this._maybeLoadMore();
- }
}
_addSearchResult(result) {
@@ -572,14 +569,14 @@ var CharacterListView = GObject.registerClass({
_searchWithContext(context, count) {
this._startSpinner();
context.search(count, this._cancellable, (context, res, user_data) => {
- this._stopSpinner();
- try {
- let result = context.search_finish(res);
- this._addSearchResult(result);
- } catch (e) {
- log(`Failed to search: ${e.message}`);
- }
- });
+ this._stopSpinner();
+ try {
+ let result = context.search_finish(res);
+ this._addSearchResult(result);
+ } catch (e) {
+ log(`Failed to search: ${e.message}`);
+ }
+ });
}
searchByCategory(category) {
@@ -590,22 +587,22 @@ var CharacterListView = GObject.registerClass({
}
let criteria = Gc.SearchCriteria.new_category(category.category);
- this._searchContext = new Gc.SearchContext({ criteria: criteria });
+ this._searchContext = new Gc.SearchContext({ criteria });
this._searchWithContext(this._searchContext, this.initialSearchCount);
}
searchByKeywords(keywords) {
const criteria = Gc.SearchCriteria.new_keywords(keywords);
this._searchContext = new Gc.SearchContext({
- criteria: criteria,
- flags: Gc.SearchFlag.WORD
+ criteria,
+ flags: Gc.SearchFlag.WORD,
});
this._searchWithContext(this._searchContext, this.initialSearchCount);
}
searchByScripts(scripts) {
var criteria = Gc.SearchCriteria.new_scripts(scripts);
- this._searchContext = new Gc.SearchContext({ criteria: criteria });
+ this._searchContext = new Gc.SearchContext({ criteria });
this._searchWithContext(this._searchContext, this.initialSearchCount);
}
@@ -617,16 +614,16 @@ var CharacterListView = GObject.registerClass({
var RecentCharacterListView = GObject.registerClass({
Signals: {
- 'character-selected': { param_types: [ GObject.TYPE_STRING ] },
+ 'character-selected': { param_types: [GObject.TYPE_STRING] },
},
}, class RecentCharacterListView extends Gtk.Bin {
_init(params) {
const filtered = Params.filter(params, {
category: null,
- fontFilter: null
+ fontFilter: null,
});
params = Params.fill(params, {
- hexpand: true, vexpand: false
+ hexpand: true, vexpand: false,
});
super._init(params);
@@ -635,7 +632,7 @@ var RecentCharacterListView = GObject.registerClass({
hexpand: true,
vexpand: true,
fontDescription: this._fontFilter.fontDescription,
- numRows: 0
+ numRows: 0,
});
this._characterList.connect('character-selected', (w, c) => this.emit('character-selected', c));
this.add(this._characterList);
diff --git a/src/main.js b/src/main.js
index b18b325..c8cb7da 100644
--- a/src/main.js
+++ b/src/main.js
@@ -26,7 +26,7 @@
pkg.initGettext();
pkg.initFormat();
-pkg.require({
+pkg.require({
'Gdk': '3.0',
'Gio': '2.0',
'GLib': '2.0',
@@ -35,7 +35,7 @@ pkg.require({
'Handy': '1',
});
-const {GLib, Gio, GObject, Gtk, Handy} = imports.gi;
+const { GLib, Gio, GObject, Gtk, Handy } = imports.gi;
const Util = imports.util;
const Window = imports.window;
@@ -44,31 +44,31 @@ var settings = null;
var application_id = pkg.name;
function initEnvironment() {
- window.getApp = function() {
+ window.getApp = function () {
return Gio.Application.get_default();
};
}
var MyApplication = GObject.registerClass({
-},class MyApplication extends Gtk.Application {
- _init () {
- super._init({ application_id: application_id,
- flags: Gio.ApplicationFlags.FLAGS_NONE });
+}, class MyApplication extends Gtk.Application {
+ _init() {
+ super._init({ application_id,
+ flags: Gio.ApplicationFlags.FLAGS_NONE });
GLib.set_application_name(_('Characters'));
}
- _onQuit () {
+ _onQuit() {
this.quit();
}
- _onSearch (action, parameter) {
+ _onSearch(action, parameter) {
const window = new Window.MainWindow({ application: this });
window.setSearchKeywords(parameter.get_strv());
window.show();
}
- vfunc_startup () {
+ vfunc_startup() {
super.vfunc_startup();
let theme = Gtk.IconTheme.get_default();
@@ -77,31 +77,31 @@ var MyApplication = GObject.registerClass({
Util.loadStyleSheet('/org/gnome/Characters/application.css');
Util.initActions(this,
- [{ name: 'quit',
- activate: this._onQuit },
- { name: 'search',
- activate: this._onSearch,
- parameter_type: new GLib.VariantType('as') }]);
+ [{ name: 'quit',
+ activate: this._onQuit },
+ { name: 'search',
+ activate: this._onSearch,
+ parameter_type: new GLib.VariantType('as') }]);
this.set_accels_for_action('app.quit', ['<Primary>q']);
settings = Util.getSettings('org.gnome.Characters',
- '/org/gnome/Characters/');
+ '/org/gnome/Characters/');
- log("Characters Application started");
+ log('Characters Application started');
}
vfunc_activate() {
- if (!this._appwindow) {
+ if (!this._appwindow)
this._appwindow = new Window.MainWindow({ application: this });
- }
+
Handy.init();
this._appwindow.present();
- log("Characters Application activated");
+ log('Characters Application activated');
}
vfunc_shutdown() {
- log("Characters Application exiting");
+ log('Characters Application exiting');
super.vfunc_shutdown();
}
@@ -110,5 +110,5 @@ var MyApplication = GObject.registerClass({
function main(argv) {
initEnvironment();
- return (new MyApplication()).run(argv);
+ return new MyApplication().run(argv);
}
diff --git a/src/menu.js b/src/menu.js
index d5bef92..16f7ab7 100644
--- a/src/menu.js
+++ b/src/menu.js
@@ -16,7 +16,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 {GLib, GObject, Gtk} = imports.gi;
+const { GLib, GObject, Gtk } = imports.gi;
const Params = imports.params;
@@ -29,8 +29,8 @@ var MenuPopover = GObject.registerClass({
row.get_style_context().add_class('font');
row._family = family;
let label = new Gtk.Label({ label: title,
- visible: true,
- halign: Gtk.Align.START });
+ visible: true,
+ halign: Gtk.Align.START });
label.get_style_context().add_class('font-label');
row.add(label);
return row;
@@ -39,28 +39,28 @@ var MenuPopover = GObject.registerClass({
_init(params) {
params = Params.fill(params, {});
super._init(params);
- let row = this._createFontListRow(_("None"), 'None');
+ let row = this._createFontListRow(_('None'), 'None');
this._font_listbox.add(row);
let context = this.get_pango_context();
let families = context.list_families();
- families = families.sort(function(a, b) {
+ families = families.sort((a, b) => {
return a.get_name().localeCompare(b.get_name());
});
for (let index in families) {
row = this._createFontListRow(families[index].get_name(),
- families[index].get_name());
+ families[index].get_name());
this._font_listbox.add(row);
}
this._keywords = [];
- this._search_entry.connect('search-changed', (entry) => this._handleSearchChanged(entry));
+ this._search_entry.connect('search-changed', entry => this._handleSearchChanged(entry));
this._font_listbox.connect('row-activated', (listBox, row) => this._handleRowActivated(listBox,
row));
- this._font_listbox.set_filter_func((row) => this._filterFunc(row));
+ this._font_listbox.set_filter_func(row => this._filterFunc(row));
// This silents warning at Characters exit about this widget being
// visible but not mapped. Borrowed from Maps.
- this.connect('unmap', function(popover) {
+ this.connect('unmap', popover => {
popover._font_listbox.unselect_all();
popover.hide();
});
@@ -89,8 +89,8 @@ var MenuPopover = GObject.registerClass({
return true;
let nameWords = row._family.split(/\s+/).map(x => x.toLowerCase());
- return this._keywords.every(function(keyword, index, array) {
- return nameWords.some(function(nameWord, index, array) {
+ return this._keywords.every((keyword, index, array) => {
+ return nameWords.some((nameWord, index, array) => {
return nameWord.indexOf(keyword) >= 0;
});
});
diff --git a/src/params.js b/src/params.js
index ee45c81..a3dc761 100644
--- a/src/params.js
+++ b/src/params.js
@@ -49,7 +49,7 @@ function parse(params, defaults) {
for (prop in params) {
if (!(prop in defaults))
- throw new Error('Unrecognized parameter "' + prop + '"');
+ throw new Error(`Unrecognized parameter "${prop}"`);
ret[prop] = params[prop];
}
diff --git a/src/searchProvider.js b/src/searchProvider.js
index 5b50864..2f09844 100644
--- a/src/searchProvider.js
+++ b/src/searchProvider.js
@@ -17,7 +17,7 @@
// with Gnome Weather; if not, write to the Free Software Foundation,
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-const {Gc, Gdk, Gio, GLib, GObject} = imports.gi;
+const { Gc, Gdk, Gio, GLib, GObject } = imports.gi;
const ByteArray = imports.byteArray;
const Service = imports.service;
@@ -51,8 +51,8 @@ var SearchProvider = GObject.registerClass({
let upper = keywords.map(x => x.toUpperCase());
let criteria = Gc.SearchCriteria.new_keywords(upper);
- let context = new Gc.SearchContext({ criteria: criteria,
- flags: Gc.SearchFlag.WORD });
+ let context = new Gc.SearchContext({ criteria,
+ flags: Gc.SearchFlag.WORD });
context.search(
MAX_SEARCH_RESULTS,
this._cancellable,
@@ -91,18 +91,17 @@ var SearchProvider = GObject.registerClass({
let codePointHex = codePoint.toString(16).toUpperCase();
let name = Gc.character_name(character);
if (name == null)
- name = _("Unknown character name");
+ name = _('Unknown character name');
else
name = Util.capitalize(name);
- let summary = _("U+%s, %s: %s").format(codePointHex,
- character,
- 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.application_id })).serialize(),
- clipboardText: new GLib.Variant('s', character)
- });
+ id: new GLib.Variant('s', identifiers[i]),
+ description: new GLib.Variant('s', summary),
+ icon: new Gio.ThemedIcon({ name: Service.application_id }).serialize(),
+ clipboardText: new GLib.Variant('s', character) });
}
this._app.release();
@@ -122,7 +121,7 @@ var SearchProvider = GObject.registerClass({
let app = Gio.DesktopAppInfo.new('org.gnome.Characters.desktop');
let id = context.get_startup_notify_id(app, []);
- return {'desktop-startup-id': new GLib.Variant('s', id) };
+ return { 'desktop-startup-id': new GLib.Variant('s', id) };
}
_activateAction(action, parameter, timestamp) {
@@ -133,26 +132,26 @@ var SearchProvider = GObject.registerClass({
wrappedParam = [];
Gio.DBus.session.call('org.gnome.Characters',
- '/org/gnome/Characters',
- 'org.freedesktop.Application',
- 'ActivateAction',
- new GLib.Variant('(sava{sv})', [action, wrappedParam,
- this._getPlatformData(timestamp)]),
- null,
- Gio.DBusCallFlags.NONE,
- -1, null, (connection, result) => {
- try {
- connection.call_finish(result);
- } catch(e) {
- log(`Failed to launch application: ${e.message}`);
- }
-
- this._app.release();
- });
+ '/org/gnome/Characters',
+ 'org.freedesktop.Application',
+ 'ActivateAction',
+ new GLib.Variant('(sava{sv})', [action, wrappedParam,
+ this._getPlatformData(timestamp)]),
+ null,
+ Gio.DBusCallFlags.NONE,
+ -1, null, (connection, result) => {
+ try {
+ connection.call_finish(result);
+ } catch (e) {
+ log(`Failed to launch application: ${e.message}`);
+ }
+
+ this._app.release();
+ });
}
LaunchSearch(terms, timestamp) {
this._activateAction('search', new GLib.Variant('as', terms),
- timestamp);
+ timestamp);
}
});
diff --git a/src/service.js b/src/service.js
index 087d86d..c536930 100644
--- a/src/service.js
+++ b/src/service.js
@@ -20,9 +20,9 @@
pkg.initGettext();
pkg.initFormat();
pkg.require({ 'Gio': '2.0',
- 'GLib': '2.0',
- 'GObject': '2.0',
- 'Gtk': '3.0' });
+ 'GLib': '2.0',
+ 'GObject': '2.0',
+ 'Gtk': '3.0' });
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
@@ -35,7 +35,7 @@ const SearchProvider = imports.searchProvider;
var application_id = pkg.name;
function initEnvironment() {
- window.getApp = function() {
+ window.getApp = function () {
return Gio.Application.get_default();
};
}
@@ -46,9 +46,9 @@ const BackgroundService = GObject.registerClass({
}, class BackgroundService extends Gtk.Application {
_init() {
super._init({ application_id: pkg.name,
- flags: Gio.ApplicationFlags.IS_SERVICE,
- inactivity_timeout: 30000 });
- GLib.set_application_name(_("Characters"));
+ flags: Gio.ApplicationFlags.IS_SERVICE,
+ inactivity_timeout: 30000 });
+ GLib.set_application_name(_('Characters'));
this._searchProvider = new SearchProvider.SearchProvider(this);
}
@@ -64,7 +64,7 @@ const BackgroundService = GObject.registerClass({
return true;
}
-/*
+ /*
Can't do until GApplication is fixed.
vfunc_dbus_unregister(connection, path) {
@@ -78,8 +78,8 @@ const BackgroundService = GObject.registerClass({
super.vfunc_startup();
Util.initActions(this,
- [{ name: 'quit',
- activate: this._onQuit }]);
+ [{ name: 'quit',
+ activate: this._onQuit }]);
}
vfunc_activate() {
@@ -90,5 +90,5 @@ const BackgroundService = GObject.registerClass({
function main(argv) {
initEnvironment();
- return (new BackgroundService()).run(argv);
+ return new BackgroundService().run(argv);
}
diff --git a/src/util.js b/src/util.js
index fe222ea..8e26b73 100644
--- a/src/util.js
+++ b/src/util.js
@@ -24,7 +24,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-const {Gc, Gdk, Gio, GObject, Gtk} = imports.gi;
+const { Gc, Gdk, Gio, GObject, Gtk } = imports.gi;
const Lang = imports.lang;
const Params = imports.params;
@@ -44,17 +44,17 @@ function loadUI(resourcePath, objects) {
function loadStyleSheet(resource) {
let provider = new Gtk.CssProvider();
- provider.load_from_file(Gio.File.new_for_uri('resource://' + resource));
+ provider.load_from_file(Gio.File.new_for_uri(`resource://${resource}`));
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),
- provider,
- Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
+ provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}
function initActions(actionMap, simpleActionEntries, context) {
- simpleActionEntries.forEach(function(entry) {
+ simpleActionEntries.forEach(entry => {
let filtered = Params.filter(entry, { activate: null,
- state_changed: null,
- context: null });
+ state_changed: null,
+ context: null });
let action = new Gio.SimpleAction(entry);
let context = filtered.context || actionMap;
@@ -71,9 +71,10 @@ function arrayEqual(one, two) {
if (one.length != two.length)
return false;
- for (let i = 0; i < one.length; i++)
+ for (let i = 0; i < one.length; i++) {
if (one[i] != two[i])
return false;
+ }
return true;
}
@@ -85,47 +86,48 @@ 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);
+ GioSSS.get_default(),
+ false);
} else {
schemaSource = GioSSS.get_default();
}
let schemaObj = schemaSource.lookup(schemaId, true);
if (!schemaObj) {
- log('Missing GSettings schema ' + schemaId);
+ log(`Missing GSettings schema ${schemaId}`);
System.exit(1);
}
- if (path === undefined)
+ if (path === undefined) {
return new Gio.Settings({ settings_schema: schemaObj });
- else
+ } else {
return new Gio.Settings({ settings_schema: schemaObj,
- path: path });
+ path });
+ }
}
function assertEqual(one, two) {
if (one != two)
- throw Error('Assertion failed: ' + one + ' != ' + two);
+ throw Error(`Assertion failed: ${one} != ${two}`);
}
function assertNotEqual(one, two) {
if (one == two)
- throw Error('Assertion failed: ' + one + ' == ' + two);
+ throw Error(`Assertion failed: ${one} == ${two}`);
}
function capitalizeWord(w) {
if (w.length > 0)
- return w[0].toUpperCase() + w.slice(1).toLowerCase()
+ return w[0].toUpperCase() + w.slice(1).toLowerCase();
return w;
}
function capitalize(s) {
- return s.split(/\s+/).map(function(w) {
- let acronyms = ["CJK"];
+ return s.split(/\s+/).map(w => {
+ let acronyms = ['CJK'];
if (acronyms.indexOf(w) > -1)
return w;
- let prefixes = ["IDEOGRAPH-", "SELECTOR-"];
+ let prefixes = ['IDEOGRAPH-', 'SELECTOR-'];
for (let index in prefixes) {
let prefix = prefixes[index];
if (w.startsWith(prefix))
@@ -148,8 +150,8 @@ function toCodePoint(s) {
function searchResultToArray(result) {
let characters = [];
- for (let index = 0; index < result.len; index++) {
+ for (let index = 0; index < result.len; index++)
characters.push(Gc.search_result_get(result, index));
- }
+
return characters;
}
diff --git a/src/window.js b/src/window.js
index bcee339..2a53413 100644
--- a/src/window.js
+++ b/src/window.js
@@ -24,7 +24,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-const {Gio, GLib, GObject, Gtk, Handy } = imports.gi;
+const { Gio, GLib, GObject, Gtk, Handy } = imports.gi;
const Params = imports.params;
const CategoryList = imports.categoryList;
@@ -42,12 +42,12 @@ var MainWindow = GObject.registerClass({
'main-headerbar', 'search-active-button',
'search-bar', 'search-entry', 'back-button',
'menu-button', 'container', 'sidebar',
- 'leaflet'
+ 'leaflet',
],
Properties: {
'search-active': GObject.ParamSpec.boolean(
'search-active', '', '',
- GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE, false)
+ GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE, false),
},
}, class MainWindow extends Handy.ApplicationWindow {
_init(params) {
@@ -58,37 +58,37 @@ var MainWindow = GObject.registerClass({
this._searchKeywords = [];
Util.initActions(this,
- [{ name: 'about',
- activate: this._about },
- { name: 'search-active',
- activate: this._toggleSearch,
- parameter_type: new GLib.VariantType('b'),
- state: new GLib.Variant('b', false) },
- { name: 'find',
- activate: this._find },
- { name: 'category',
- activate: this._category,
- parameter_type: new GLib.VariantType('s'),
- state: new GLib.Variant('s', 'emoji-smileys') },
- { name: 'character',
- activate: this._character,
- parameter_type: new GLib.VariantType('s') },
- { name: 'filter-font',
- activate: this._filterFont,
- parameter_type: new GLib.VariantType('s') }]);
+ [{ name: 'about',
+ activate: this._about },
+ { name: 'search-active',
+ activate: this._toggleSearch,
+ parameter_type: new GLib.VariantType('b'),
+ state: new GLib.Variant('b', false) },
+ { name: 'find',
+ activate: this._find },
+ { name: 'category',
+ activate: this._category,
+ parameter_type: new GLib.VariantType('s'),
+ state: new GLib.Variant('s', 'emoji-smileys') },
+ { name: 'character',
+ activate: this._character,
+ parameter_type: new GLib.VariantType('s') },
+ { name: 'filter-font',
+ activate: this._filterFont,
+ parameter_type: new GLib.VariantType('s') }]);
this.application.set_accels_for_action('win.find', ['<Primary>F']);
this.bind_property('search-active', this._search_active_button, 'active',
- GObject.BindingFlags.SYNC_CREATE |
+ GObject.BindingFlags.SYNC_CREATE |
GObject.BindingFlags.BIDIRECTIONAL);
this.bind_property('search-active',
- this._search_bar,
- 'search-mode-enabled',
- GObject.BindingFlags.SYNC_CREATE |
+ this._search_bar,
+ 'search-mode-enabled',
+ GObject.BindingFlags.SYNC_CREATE |
GObject.BindingFlags.BIDIRECTIONAL);
this._search_bar.connect_entry(this._search_entry);
- this._search_entry.connect('search-changed', (entry) => this._handleSearchChanged(entry));
+ this._search_entry.connect('search-changed', entry => this._handleSearchChanged(entry));
this._back_button.connect('clicked', () => {
this._leaflet.navigate(Handy.NavigationDirection.BACK);
@@ -109,7 +109,7 @@ var MainWindow = GObject.registerClass({
this._sidebar.add(scroll);
this._mainView = new MainView({
- categoryListView: this._categoryListView
+ categoryListView: this._categoryListView,
});
this._container.pack_start(this._mainView, true, true, 0);
@@ -127,11 +127,11 @@ var MainWindow = GObject.registerClass({
// Select the first subcategory which contains at least one character.
_selectFirstSubcategory() {
let categoryList;
- if (this._mainView.recentCharacters.length !== 0) {
+ if (this._mainView.recentCharacters.length !== 0)
categoryList = this._categoryListView.getCategoryByName('recent');
- } else {
+ else
categoryList = this._categoryListView.getCategoryByName('emojis');
- }
+
categoryList.select_row(categoryList.get_row_at_index(0));
}
@@ -148,7 +148,7 @@ var MainWindow = GObject.registerClass({
if (this._searchActive) {
let categoryList = this._categoryListView.selectedList;
categoryList.unselect_all();
- this._updateTitle(_("Search Result"));
+ this._updateTitle(_('Search Result'));
} else {
this._categoryListView.restorePreviousSelection();
}
@@ -177,26 +177,25 @@ 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>' ],
- // TRANSLATORS: put your names here, one name per line.
- translator_credits: _("translator-credits"),
- program_name: _("GNOME Characters"),
- comments: _("Character Map"),
- copyright: 'Copyright 2014-2018 Daiki Ueno',
- license_type: Gtk.License.GPL_2_0,
- logo_icon_name: Main.application_id,
- version: pkg.version,
- website: 'https://wiki.gnome.org/Apps/Characters',
- wrap_license: true,
- modal: true,
- transient_for: this
- });
+ { 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'),
+ comments: _('Character Map'),
+ copyright: 'Copyright 2014-2018 Daiki Ueno',
+ license_type: Gtk.License.GPL_2_0,
+ logo_icon_name: Main.application_id,
+ version: pkg.version,
+ website: 'https://wiki.gnome.org/Apps/Characters',
+ wrap_license: true,
+ modal: true,
+ transient_for: this });
aboutDialog.show();
- aboutDialog.connect('response', function() {
+ aboutDialog.connect('response', () => {
aboutDialog.destroy();
});
}
@@ -204,8 +203,8 @@ var MainWindow = GObject.registerClass({
_updateTitle(title) {
if (this._mainView.filterFontFamily) {
this._main_headerbar.title =
- _("%s (%s only)").format(Gettext.gettext(title),
- this._mainView.filterFontFamily);
+ _('%s (%s only)').format(Gettext.gettext(title),
+ this._mainView.filterFontFamily);
} else {
this._main_headerbar.title = Gettext.gettext(title);
}
@@ -216,13 +215,13 @@ var MainWindow = GObject.registerClass({
let [name, length] = v.get_string();
let categoryName;
- if(name.startsWith("emoji")) {
- categoryName = "emojis";
- } else if(name === "recent") {
- categoryName = "recent";
- } else {
- categoryName = "letters";
- }
+ if (name.startsWith('emoji'))
+ categoryName = 'emojis';
+ else if (name === 'recent')
+ categoryName = 'recent';
+ else
+ categoryName = 'letters';
+
let categoryList = this._categoryListView.getCategoryByName(categoryName);
let category = categoryList.getCategory(name);
if (category) {
@@ -262,7 +261,7 @@ const MainView = GObject.registerClass({
'max-recent-characters': GObject.ParamSpec.uint(
'max-recent-characters', '', '',
GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
- 0, GLib.MAXUINT32, 100)
+ 0, GLib.MAXUINT32, 100),
},
}, class MainView extends Gtk.Stack {
get max_recent_characters() {
@@ -271,9 +270,10 @@ const MainView = GObject.registerClass({
set max_recent_characters(v) {
this._maxRecentCharacters = v;
- if (this.recentCharacters.length > this._maxRecentCharacters)
+ if (this.recentCharacters.length > this._maxRecentCharacters) {
this.recentCharacters = this.recentCharacters.slice(
0, this._maxRecentCharacters);
+ }
}
get filterFontFamily() {
@@ -289,7 +289,7 @@ const MainView = GObject.registerClass({
const filtered = Params.filter(params, { categoryListView: null });
params = Params.fill(params, {
hexpand: true, vexpand: true,
- transition_type: Gtk.StackTransitionType.CROSSFADE
+ transition_type: Gtk.StackTransitionType.CROSSFADE,
});
super._init(params);
@@ -302,7 +302,7 @@ const MainView = GObject.registerClass({
let characterList;
let categories = this._categoryListView.getCategoryList();
let recentBox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL,
- hexpand: true, vexpand: false });
+ hexpand: true, vexpand: false });
for (let i in categories) {
let category = categories[i];
@@ -343,7 +343,7 @@ const MainView = GObject.registerClass({
characterList = this._createCharacterList(
'search-result', _('Search Result Character List'));
// FIXME: Can't use GtkContainer.child_get_property.
- characterList.title = _("Search Result");
+ characterList.title = _('Search Result');
this.add_named(characterList, 'search-result');
// FIXME: Can't use GSettings.bind with 'as' from Gjs
@@ -351,8 +351,8 @@ const MainView = GObject.registerClass({
this.recentCharacters = recentCharacters.get_strv();
this._maxRecentCharacters = 100;
Main.settings.bind('max-recent-characters', this,
- 'max-recent-characters',
- Gio.SettingsBindFlags.DEFAULT);
+ 'max-recent-characters',
+ Gio.SettingsBindFlags.DEFAULT);
}
_createCharacterList(name, accessible_name) {
@@ -369,7 +369,7 @@ const MainView = GObject.registerClass({
_createRecentCharacterList(name, accessible_name, category) {
const characterList = new CharacterList.RecentCharacterListView({
fontFilter: this._fontFilter,
- category: category
+ category,
});
characterList.get_accessible().accessible_name = accessible_name;
characterList.connect('character-selected', (widget, uc) => this._handleCharacterSelected(widget,
uc));
@@ -390,9 +390,9 @@ const MainView = GObject.registerClass({
setPage(category) {
if (category.name === 'recent') {
- if (this.recentCharacters.length === 0)
+ if (this.recentCharacters.length === 0) {
this.visible_child_name = 'empty-recent';
- else {
+ } else {
let categories = this._categoryListView.getCategoryList();
for (let i in categories) {
let category = categories[i];
@@ -411,9 +411,10 @@ const MainView = GObject.registerClass({
addToRecent(uc) {
if (this.recentCharacters.indexOf(uc) < 0) {
this.recentCharacters.unshift(uc);
- if (this.recentCharacters.length > this._maxRecentCharacters)
+ if (this.recentCharacters.length > this._maxRecentCharacters) {
this.recentCharacters = this.recentCharacters.slice(
0, this._maxRecentCharacters);
+ }
Main.settings.set_value(
'recent-characters',
GLib.Variant.new_strv(this.recentCharacters));
@@ -429,12 +430,12 @@ const MainView = GObject.registerClass({
character: uc,
modal: true,
transient_for: this.get_toplevel(),
- fontDescription: this._fontFilter.fontDescription
+ fontDescription: this._fontFilter.fontDescription,
});
dialog.show();
dialog.connect('character-copied', (widget, uc) => this._addToRecent(widget, uc));
- dialog.connect('response', function(self, response_id) {
+ dialog.connect('response', (self, response_id) => {
if (response_id == Gtk.ResponseType.CLOSE)
dialog.destroy();
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]