Skip to content

Commit

Permalink
add setting for desktop name text
Browse files Browse the repository at this point in the history
  • Loading branch information
jonian committed Oct 30, 2018
1 parent 9caed5f commit bd5244c
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 2 deletions.
17 changes: 16 additions & 1 deletion [email protected]/modules/desktopName.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@ var DesktopName = new Lang.Class({
this._sdnHandlerID = this._settings.connect(
'changed::show-desktop-name', Lang.bind(this, this._toggle)
);

this._dntHandlerID = this._settings.connect(
'changed::desktop-name-text', Lang.bind(this, this._setLabelText)
);
},

_disconnectSettings: function() {
if (this._sdnHandlerID) {
this._settings.disconnect(this._sdnHandlerID);
delete this._sdnHandlerID;
}

if (this._dntHandlerID) {
this._settings.disconnect(this._dntHandlerID);
delete this._dntHandlerID;
}
},

_connectSignals: function () {
Expand Down Expand Up @@ -95,7 +104,7 @@ var DesktopName = new Lang.Class({
this._labelActor = new St.Bin({ style_class: 'desktop-name' });
this._labelBox.add_actor(this._labelActor);

this._labelText = new St.Label({ text: 'GNOME Desktop' });
this._labelText = new St.Label();
this._labelActor.add_actor(this._labelText);

let activities = Panel.statusArea.activities.actor.get_parent();
Expand All @@ -116,6 +125,11 @@ var DesktopName = new Lang.Class({
}
},

_setLabelText: function () {
let text = this._settings.get_string('desktop-name-text');
this._labelText.set_text(text);
},

_toggle: function() {
this._deactivate();
this._activate();
Expand All @@ -126,6 +140,7 @@ var DesktopName = new Lang.Class({

if (this._enabled) {
this._createLabel();
this._setLabelText();
this._updateVisibility();
this._connectSignals();
}
Expand Down
24 changes: 23 additions & 1 deletion [email protected]/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var PrefsWidget = new GObject.Class({
this.add(prefsWidget);

this._settings = Convenience.getSettings();
this._bindStrings();
this._bindBooleans();
this._bindEnumerations();
},
Expand All @@ -30,6 +31,27 @@ var PrefsWidget = new GObject.Class({
return this._buildable.get_object(wname);
},

_getStrings: function () {
let items = [
'desktop-name-text'
];

return items;
},

_bindString: function (setting) {
let widget = this._getWidget(setting);
widget.set_text(this._settings.get_string(setting));

widget.connect('changed', Lang.bind(this, function(entry) {
this._settings.set_string(setting, entry.get_text());
}));
},

_bindStrings: function () {
this._getStrings().forEach(Lang.bind(this, this._bindString));
},

_getBooleans: function () {
let items = [
'extend-left-box',
Expand Down Expand Up @@ -68,7 +90,7 @@ var PrefsWidget = new GObject.Class({
let widget = this._getWidget(setting);
widget.set_active(this._settings.get_enum(setting));

widget.connect('changed', Lang.bind (this, function(combobox) {
widget.connect('changed', Lang.bind(this, function(combobox) {
this._settings.set_enum(setting, combobox.get_active());
}));
},
Expand Down
Binary file modified [email protected]/schemas/gschemas.compiled
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
<summary>Show desktop name in top bar.</summary>
</key>

<key name="desktop-name-text" type="s">
<default>"GNOME Desktop"</default>
<summary>Set the top bar desktop name text.</summary>
</key>

<key name="show-window-title" enum="org.gnome.shell.extensions.unite.showTitle">
<default>"maximized"</default>
<summary>Use window title to replace the app-menu label.</summary>
Expand Down
39 changes: 39 additions & 0 deletions [email protected]/settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,45 @@
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkBox" id="desktop_name_text_section">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">50</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Top bar desktop name text</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="desktop_name_text">
<property name="width_request">170</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">GNOME Desktop</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkBox" id="hide_activities_button_section">
<property name="visible">True</property>
Expand Down

0 comments on commit bd5244c

Please sign in to comment.