[gnome-characters/bilelmoussaoui/gtk4: 15/71] category list: drop the whole params mess
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-characters/bilelmoussaoui/gtk4: 15/71] category list: drop the whole params mess
- Date: Thu, 25 Nov 2021 11:03:10 +0000 (UTC)
commit 921dd2b84e88d007b32b7f0c9f4b69225c2641e0
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Fri Nov 19 12:41:03 2021 +0100
category list: drop the whole params mess
it's very old kind of api and makes the code unreadable for very little gain
data/menu.ui | 1 +
src/categoryList.js | 59 +++++++++++++++++++++-------------------------------
src/characterList.js | 2 --
src/menu.js | 2 +-
src/window.js | 2 +-
5 files changed, 27 insertions(+), 39 deletions(-)
---
diff --git a/data/menu.ui b/data/menu.ui
index 968e58e..1c2dab1 100644
--- a/data/menu.ui
+++ b/data/menu.ui
@@ -3,6 +3,7 @@
<template class="Gjs_MenuPopover" parent="GtkPopover">
<property name="vexpand">True</property>
<property name="width-request">250</property>
+ <property name="height-request">600</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
diff --git a/src/categoryList.js b/src/categoryList.js
index f05f928..127bb1d 100644
--- a/src/categoryList.js
+++ b/src/categoryList.js
@@ -20,7 +20,6 @@
const {Adw, Gc, GLib, GObject, Gtk, GnomeDesktop} = imports.gi;
const Gettext = imports.gettext;
-const Params = imports.params;
const Util = imports.util;
@@ -138,16 +137,14 @@ const EmojiCategoryList = [
const CategoryListRowWidget = GObject.registerClass({
}, class CategoryListRowWidget extends Gtk.ListBoxRow {
- _init (params, category) {
- params = Params.fill(params, {});
- super._init(params);
+ _init (category) {
+ super._init();
this.category = category;
/*this.get_accessible().accessible_name =
_('%s Category List Row').format(category.title);*/
let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL });
this.set_child(hbox);
-
let image = Gtk.Image.new_from_icon_name(category.icon_name);
image.set_icon_size(Gtk.IconSize.LARGE_TOOLBAR);
image.add_css_class('category-icon');
@@ -163,20 +160,17 @@ const CategoryListRowWidget = GObject.registerClass({
const CategoryListWidget = GObject.registerClass({
}, class CategoryListWidget extends Adw.Bin {
- _init(params) {
- const filtered = Params.filter(params, { categoryList: null });
- params = Params.fill(params, {});
- this.list = Gtk.ListBox.new();
- super._init(params);
-
+ _init(categories) {
+ super._init({});
- this._categoryList = filtered.categoryList;
+ this.list = Gtk.ListBox.new();
+ this._categories = categories;
this.populateCategoryList();
this._lastSelectedRow = null;
- for (let index in this._categoryList) {
- let category = this._categoryList[index];
- let rowWidget = new CategoryListRowWidget({}, category);
+ for (let index in this._categories) {
+ let category = this._categories[index];
+ let rowWidget = new CategoryListRowWidget(category);
rowWidget.add_css_class('category');
this.list.append(rowWidget);
}
@@ -195,12 +189,12 @@ const CategoryListWidget = GObject.registerClass({
}
getCategoryList() {
- return this._categoryList;
+ return this._categories;
}
getCategory(name) {
- for (let index in this._categoryList) {
- let category = this._categoryList[index];
+ for (let index in this._categories) {
+ let category = this._categories[index];
if (category.name == name)
return category;
}
@@ -344,9 +338,8 @@ const LetterCategoryListWidget = GObject.registerClass({
const EmojiCategoryListWidget = GObject.registerClass({
}, class EmojiCategoryListWidget extends CategoryListWidget {
- _init(params) {
- params = Params.fill(params, {});
- super._init(params);
+ _init(categories) {
+ super._init(categories);
}
getCategory(name) {
@@ -357,15 +350,15 @@ const EmojiCategoryListWidget = GObject.registerClass({
const RecentCategoryListWidget = GObject.registerClass({
}, class RecentCategoryListWidget extends CategoryListWidget {
- _init(params) {
- super._init(params);
+ _init(categories) {
+ super._init(categories);
this.recentCategory = {
name: 'recent',
category: Gc.Category.NONE,
title: N_('Recently Used'),
icon_name: 'document-open-recent-symbolic',
};
- this.recentRow = new CategoryListRowWidget({}, this.recentCategory);
+ this.recentRow = new CategoryListRowWidget(this.recentCategory);
this.recentRow.add_css_class('category');
this.recentRow.add_css_class('recent-category');
this.set_child(this.recentRow)
@@ -378,13 +371,13 @@ const RecentCategoryListWidget = GObject.registerClass({
var CategoryListView = GObject.registerClass({
}, class CategoryListView extends Gtk.Box {
- _init(params) {
- params = Params.fill(params, {
- hexpand: true, vexpand: true,
+ _init() {
+ this._lastSelectedList = null;
+ super._init({
+ hexpand: true,
+ vexpand: true,
orientation: Gtk.Orientation.VERTICAL,
});
- this._lastSelectedList = null;
- super._init(params);
this.add_css_class('categories-list');
this._recentCategoryList = new RecentCategoryListWidget();
@@ -408,9 +401,7 @@ var CategoryListView = GObject.registerClass({
emojis_label.add_css_class("heading");
this.append(emojis_label);
- this._emojiCategoryList = new EmojiCategoryListWidget({
- categoryList: EmojiCategoryList
- });
+ this._emojiCategoryList = new EmojiCategoryListWidget(EmojiCategoryList);
this._emojiCategoryList.list.connect('row-selected', (list, row) => {
this._letterCategoryList.unselect();
this._recentCategoryList.unselect();
@@ -430,9 +421,7 @@ var CategoryListView = GObject.registerClass({
letters_label.add_css_class("heading");
this.append(letters_label);
- this._letterCategoryList = new LetterCategoryListWidget({
- categoryList: LetterCategoryList
- });
+ this._letterCategoryList = new LetterCategoryListWidget(LetterCategoryList);
this._letterCategoryList.list.connect('row-selected', (list, row) => {
this._emojiCategoryList.unselect();
this._recentCategoryList.unselect();
diff --git a/src/characterList.js b/src/characterList.js
index 13bca2c..86a7176 100644
--- a/src/characterList.js
+++ b/src/characterList.js
@@ -537,7 +537,6 @@ var CharacterListView = GObject.registerClass({
} else {
this.visible_child_name = 'character-list';
}
- this.show_all();
}
_maybeLoadMore() {
@@ -666,6 +665,5 @@ var RecentCharacterListView = GObject.registerClass({
const [fontDescription, characters] = this._fontFilter.apply(this, this._characters);
this._characterList.setFontDescription(fontDescription);
this._characterList.setCharacters(characters);
- this.show_all();
}
});
diff --git a/src/menu.js b/src/menu.js
index 81388cc..52c94e4 100644
--- a/src/menu.js
+++ b/src/menu.js
@@ -75,7 +75,7 @@ var MenuPopover = GObject.registerClass({
_handleRowActivated(listBox, row) {
if (row != null) {
- let toplevel = this.get_toplevel();
+ let toplevel = this.get_root();
let action = toplevel.lookup_action('filter-font');
action.activate(new GLib.Variant('s', row._family));
}
diff --git a/src/window.js b/src/window.js
index 5861d9d..89fa040 100644
--- a/src/window.js
+++ b/src/window.js
@@ -101,7 +101,7 @@ var MainWindow = GObject.registerClass({
this._menu_button.set_popover(this._menu_popover);
this._categoryListView =
- new CategoryList.CategoryListView({ vexpand: true });
+ new CategoryList.CategoryListView();
let scroll = new Gtk.ScrolledWindow({
hscrollbar_policy: Gtk.PolicyType.NEVER,
hexpand: false,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]