[gnome-shell/gbsneto/icon-grid-part4: 2/2] folderIcon: Use editable label
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/icon-grid-part4: 2/2] folderIcon: Use editable label
- Date: Thu, 8 Aug 2019 19:55:22 +0000 (UTC)
commit 6f19270be3ebcfeffb8d63ad2c49bc77aff653ba
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Aug 8 16:52:54 2019 -0300
folderIcon: Use editable label
Use an editable label to allow editing the folder
name. When a name is set, make sure that the folder
is not translatable anymore.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/675
js/ui/appDisplay.js | 14 ++++++++++++++
js/ui/iconGrid.js | 13 ++++++++++++-
2 files changed, 26 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index a0537803e7..9457568a54 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -1434,6 +1434,7 @@ var FolderIcon = class FolderIcon {
this.icon = new IconGrid.BaseIcon('', {
createIcon: this._createIcon.bind(this),
+ editable: true,
setSizeManually: true
});
this.actor.set_child(this.icon);
@@ -1455,6 +1456,9 @@ var FolderIcon = class FolderIcon {
this._folder.connect('changed', this._redisplay.bind(this));
this._redisplay();
+
+ this.icon.label.connect('label-edit-update', this._onLabelUpdate.bind(this));
+ this.icon.label.connect('label-edit-cancel', this._onLabelCancel.bind(this));
}
onDestroy() {
@@ -1550,6 +1554,16 @@ var FolderIcon = class FolderIcon {
return true;
}
+ _onLabelUpdate(label, newText) {
+ this._folder.set_boolean('translatable', false);
+ this._folder.set_string('name', newText);
+ this._updateName();
+ }
+
+ _onLabelCancel() {
+ this.icon.sync_hover();
+ }
+
_updateName() {
let name = _getFolderName(this._folder);
if (this.name == name)
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index bb6829673e..5a3a157ef6 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -3,6 +3,7 @@
const { Clutter, GLib, GObject, Meta, St } = imports.gi;
+const EditableLabel = imports.ui.editableLabel;
const Params = imports.misc.params;
const Main = imports.ui.main;
@@ -33,6 +34,7 @@ class BaseIcon extends St.Bin {
_init(label, params) {
params = Params.parse(params, { createIcon: null,
setSizeManually: false,
+ editable: false,
showLabel: true });
let styleClass = 'overview-icon';
@@ -55,7 +57,16 @@ class BaseIcon extends St.Bin {
this._box.add_actor(this._iconBin);
if (params.showLabel) {
- this.label = new St.Label({ text: label });
+ let labelParams = {
+ text: label,
+ style_class: 'overview-icon-label'
+ };
+
+ if (params.editable)
+ this.label = new EditableLabel.EditableLabel(labelParams);
+ else
+ this.label = new St.Label(labelParams);
+
this.label.clutter_text.set({
x_align: Clutter.ActorAlign.CENTER,
y_align: Clutter.ActorAlign.CENTER
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]