[gnome-characters/bilelmoussaoui/gtk4: 2/7] drop font filter feature
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-characters/bilelmoussaoui/gtk4: 2/7] drop font filter feature
- Date: Wed, 24 Nov 2021 18:02:26 +0000 (UTC)
commit 89139607cacbe4496465a788b53dfae29e2af4dc
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Wed Nov 24 14:27:46 2021 +0100
drop font filter feature
Fitlering by font doesn't make much sense as pango can fallback to other fonts
Instead, display only the characters/emojies available in the currently selected font on
a system level
data/window.ui | 8 ---
src/charactersView.js | 110 +++--------------------------
src/main.js | 2 -
src/menu.js | 98 -------------------------
src/meson.build | 1 -
src/org.gnome.Characters.src.gresource.xml | 1 -
src/window.js | 39 ++--------
7 files changed, 15 insertions(+), 244 deletions(-)
---
diff --git a/data/window.ui b/data/window.ui
index 5cc9d48..08932e9 100644
--- a/data/window.ui
+++ b/data/window.ui
@@ -119,14 +119,6 @@
</child>
</object>
</child>
- <child type="end">
- <object class="GtkMenuButton" id="menu-button">
- <property name="icon-name">view-more-symbolic</property>
- <property name="popover">
- <object class="Gjs_MenuPopover" id="menuPopover" />
- </property>
- </object>
- </child>
</object>
</child>
<child>
diff --git a/src/charactersView.js b/src/charactersView.js
index bddb142..6700f41 100644
--- a/src/charactersView.js
+++ b/src/charactersView.js
@@ -1,4 +1,4 @@
-/* exported CharactersView FontFilter */
+/* exported CharactersView */
// -*- Mode: js; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*-
//
// Copyright (C) 2014-2015 Daiki Ueno <dueno src gnome org>
@@ -19,7 +19,6 @@
const { Gc, Gdk, GLib, Gio, GObject, Gtk, Pango, Graphene } = imports.gi;
-const Main = imports.main;
const Util = imports.util;
const BASELINE_OFFSET = 0.85;
@@ -173,87 +172,6 @@ const CharacterListRow = GObject.registerClass({
const MAX_SEARCH_RESULTS = 100;
-var FontFilter = GObject.registerClass({
- Properties: {
- 'font': GObject.ParamSpec.string(
- 'font', '', '',
- GObject.ParamFlags.READWRITE,
- 'Cantarell 50',
- ),
- },
- Signals: {
- 'filter-set': { param_types: [] },
- },
-}, class FontFilter extends GObject.Object {
- _init() {
- super._init({});
-
- this._fontDescription = null;
- this._filterFontDescription = null;
-
- Main.settings.bind('font', this, 'font', Gio.SettingsBindFlags.DEFAULT);
- }
-
- get font() {
- return this._font;
- }
-
- set font(v) {
- let fontDescription = Pango.FontDescription.from_string(v);
- if (fontDescription.get_size() === 0)
- fontDescription.set_size(CELL_SIZE * Pango.SCALE);
-
- if (this._fontDescription &&
- fontDescription.equal(this._fontDescription))
- return;
-
- this._font = v;
- this._fontDescription = fontDescription;
- }
-
- get fontDescription() {
- if (this._filterFontDescription)
- return this._filterFontDescription;
- return this._fontDescription;
- }
-
- setFilterFont(v) {
- let fontDescription;
- if (v === null) {
- fontDescription = null;
- } else {
- fontDescription = Pango.FontDescription.from_string(v);
- fontDescription.set_size(this._fontDescription.get_size());
- }
-
- if (this._filterFontDescription !== null && fontDescription === null ||
- this._filterFontDescription === null && fontDescription !== null ||
- this._filterFontDescription !== null && fontDescription !== null &&
- !fontDescription.equal(this._filterFontDescription)) {
- this._filterFontDescription = fontDescription;
- this.emit('filter-set');
- }
- }
-
- filter(widget, characters) {
- let fontDescription = this._fontDescription;
- if (this._filterFontDescription) {
- let context = widget.get_pango_context();
- let filterFont = context.load_font(this._filterFontDescription);
- let filteredCharacters = [];
- for (let index = 0; index < characters.length; index++) {
- let uc = characters[index];
- if (Gc.pango_context_font_has_glyph(context, filterFont, uc))
- filteredCharacters.push(uc);
- }
- characters = filteredCharacters;
- fontDescription = this._filterFontDescription;
- }
-
- return [fontDescription, characters];
- }
-});
-
var CharactersView = GObject.registerClass({
Signals: {
'character-selected': { param_types: [GObject.TYPE_STRING] },
@@ -273,6 +191,11 @@ var CharactersView = GObject.registerClass({
overflow: Gtk.Overflow.HIDDEN,
});
+ let context = this.get_pango_context();
+ this._fontDescription = context.get_font_description();
+ this._fontDescription.set_size(CELL_SIZE * Pango.SCALE);
+
+
this._selectedCharacter = null;
this._characters = [];
this._spinnerTimeoutId = 0;
@@ -282,7 +205,6 @@ var CharactersView = GObject.registerClass({
this._stopSpinner();
this._searchContext = null;
this._characters = [];
- this._updateCharacterList();
});
this._cellsPerRow = CELLS_PER_ROW;
@@ -300,6 +222,10 @@ var CharactersView = GObject.registerClass({
this.add_controller(gestureClick);
}
+ get fontDescription() {
+ return this._fontDescription;
+ }
+
get vadjustment() {
return this._vadjustment;
}
@@ -320,7 +246,6 @@ var CharactersView = GObject.registerClass({
this.queue_draw();
});
this._hadjustment = adj;
-
}
/*
@@ -466,12 +391,6 @@ var CharactersView = GObject.registerClass({
this.queue_draw();
}
- setFontFilter(fontFilter) {
- this.setFontDescription(fontFilter.fontDescription);
- fontFilter.connect('filter-set', () => this._updateCharacterList());
- this._fontFilter = fontFilter;
- }
-
_startSpinner() {
this._stopSpinner();
this._spinnerTimeoutId =
@@ -497,13 +416,6 @@ var CharactersView = GObject.registerClass({
this.setCharacters(characters);
}
- _updateCharacterList() {
- log('Updating characters list');
- const [fontDescription, characters] = this._fontFilter.filter(this, this._characters);
- this.setFontDescription(fontDescription);
- this.setCharacters(characters);
- }
-
get initialSearchCount() {
// Use our parents allocation; we aren't visible before we do the
// initial search, so our allocation is 1x1
@@ -512,7 +424,7 @@ var CharactersView = GObject.registerClass({
// Sometimes more MAX_SEARCH_RESULTS are visible on screen
// (eg. fullscreen at 1080p). We always present a over-full screen,
// otherwise the lazy loading gets broken
- let cellSize = getCellSize(this._fontFilter.fontDescription);
+ let cellSize = getCellSize(this._fontDescription);
let cellsPerRow = Math.floor(allocation.width / cellSize);
// Ensure the rows cause a scroll
let heightInRows = Math.ceil((allocation.height + 1) / cellSize);
diff --git a/src/main.js b/src/main.js
index 67b3e94..d2ffde7 100644
--- a/src/main.js
+++ b/src/main.js
@@ -41,7 +41,6 @@ const { GLib, Gio, GObject, Adw } = imports.gi;
const { CharactersView } = imports.charactersView;
const { Sidebar } = imports.sidebar;
-const { MenuPopover } = imports.menu;
const { MainWindow } = imports.window;
const Util = imports.util;
@@ -113,7 +112,6 @@ var MyApplication = GObject.registerClass({
function main(argv) {
GObject.type_ensure(CharactersView.$gtype);
GObject.type_ensure(Sidebar.$gtype);
- GObject.type_ensure(MenuPopover.$gtype);
return new MyApplication().run(argv);
}
diff --git a/src/meson.build b/src/meson.build
index 8e43f81..f9401a2 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -28,7 +28,6 @@ resource_data = common_resource_data + files(
'characterDialog.js',
'charactersView.js',
'main.js',
- 'menu.js',
'sidebar.js',
'sidebarRow.js',
'window.js'
diff --git a/src/org.gnome.Characters.src.gresource.xml b/src/org.gnome.Characters.src.gresource.xml
index 8b6eeef..17f3ef6 100644
--- a/src/org.gnome.Characters.src.gresource.xml
+++ b/src/org.gnome.Characters.src.gresource.xml
@@ -2,7 +2,6 @@
<gresources>
<gresource prefix="/org/gnome/Characters/js">
<file>main.js</file>
- <file>menu.js</file>
<file>sidebar.js</file>
<file>sidebarRow.js</file>
<file>util.js</file>
diff --git a/src/window.js b/src/window.js
index e1b5523..d2eb11f 100644
--- a/src/window.js
+++ b/src/window.js
@@ -28,7 +28,6 @@
const { Adw, Gio, GLib, GObject, Gtk } = imports.gi;
const { CharacterDialog } = imports.characterDialog;
-const { FontFilter } = imports.charactersView;
const { gettext } = imports.gettext;
const Main = imports.main;
@@ -39,7 +38,7 @@ var MainWindow = GObject.registerClass({
InternalChildren: [
'search-active-button',
'search-bar', 'search-entry', 'back-button',
- 'menuPopover', 'container', 'sidebar',
+ 'container', 'sidebar',
'leaflet', 'mainStack', 'windowTitle',
'charactersView', 'scrolledWindow',
],
@@ -59,16 +58,13 @@ var MainWindow = GObject.registerClass({
this._searchActive = false;
this._searchKeywords = [];
- this._fontFilter = new FontFilter();
- this._filterFontFamily = null;
this._characterLists = {};
this._recentCharacterLists = {};
- this._charactersView.setFontFilter(this._fontFilter);
+
this._charactersView.connect('character-selected', (widget, uc) => {
this._handleCharacterSelected(widget, uc);
});
-
this._sidebar.list.connect('row-selected', (sidebar, row) => {
const adj = this._scrolledWindow.get_vadjustment();
adj.set_value(0.0); // scroll back to the top
@@ -109,9 +105,6 @@ var MainWindow = GObject.registerClass({
{ name: 'character',
activate: this._character,
parameterType: new GLib.VariantType('s') },
- { name: 'filter-font',
- activate: this._filterFont,
- parameterType: new GLib.VariantType('s') },
{
name: 'show-primary-menu',
activate: this._togglePrimaryMenu,
@@ -188,8 +181,6 @@ var MainWindow = GObject.registerClass({
}
_handleKeyPress(self, event) {
- if (this._menuPopover.visible)
- return false;
return this._search_bar.handle_event(event);
}
@@ -221,11 +212,7 @@ var MainWindow = GObject.registerClass({
}
_updateTitle(title) {
- if (this.filterFontFamily)
- this._windowTitle.title = _('%s (%s only)').format(gettext(title), this.filterFontFamily);
- else
- this._windowTitle.title = gettext(title);
-
+ this._windowTitle.title = gettext(title);
}
_character(action, v) {
@@ -233,15 +220,6 @@ var MainWindow = GObject.registerClass({
this.addToRecent(uc);
}
- _filterFont(action, v) {
- let family = v.get_string()[0];
- if (family === 'None')
- family = null;
- this.filterFontFamily = family;
- this._updateTitle(this._windowTitle.title);
- this._menuPopover.hide();
- }
-
_find() {
this.searchActive = !this.searchActive;
}
@@ -263,15 +241,6 @@ var MainWindow = GObject.registerClass({
}
}
- get filterFontFamily() {
- return this._filterFontFamily;
- }
-
- set filterFontFamily(family) {
- this._filterFontFamily = family;
- this._fontFilter.setFilterFont(this._filterFontFamily);
- }
-
searchByKeywords(keywords) {
let totalResults = this._charactersView.searchByKeywords(keywords);
if (totalResults === 0)
@@ -314,7 +283,7 @@ var MainWindow = GObject.registerClass({
}
_handleCharacterSelected(widget, uc) {
- const dialog = new CharacterDialog(uc, this._fontFilter.fontDescription);
+ const dialog = new CharacterDialog(uc, this._charactersView.fontDescription);
dialog.set_modal(true);
dialog.set_transient_for(this.get_root());
dialog.connect('character-copied', (_widget, char) => {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]