Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:GA
gnome-shell
gnome-shell-hostname-refresh.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File gnome-shell-hostname-refresh.patch of Package gnome-shell
diff -Npur gnome-shell-3.10.4/js/ui/aboutMenu.js gnome-shell-3.10.4-new/js/ui/aboutMenu.js --- gnome-shell-3.10.4/js/ui/aboutMenu.js 2014-08-01 05:46:06.211212081 +0800 +++ gnome-shell-3.10.4-new/js/ui/aboutMenu.js 2014-08-01 06:24:53.007267381 +0800 @@ -12,29 +12,21 @@ const AboutMenuButton = new Lang.Class({ Name: 'AboutMenuButton', Extends: PanelMenu.Button, _init: function() { - let command = 'hostname'; - let hostname_text; - try { - let [res, stdout, stderr, status] = GLib.spawn_command_line_sync(command); - hostname_text = String.fromCharCode.apply(null, stdout); - } catch (e) { - /* Donnot display the useless widget */ - this.parent(null, 'About Me'); - return; - } + this._hostname = null; + this._updateHostnameId = 0; + this._ticket = 1; let hbox; let vbox; - let menuAlignment = 0.25; + if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL) menuAlignment = 1.0 - menuAlignment; this.parent(menuAlignment, 'About Me'); this.about_hbox = new St.BoxLayout({ style_class: 'panel-status-menu-box' }); - this.about_hbox.add_child(new St.Label({ text: hostname_text, - y_align: Clutter.ActorAlign.CENTER - })); + this.hostname_label = new St.Label({y_align: Clutter.ActorAlign.CENTER}); + this.about_hbox.add_child(this.hostname_label); this.actor.add_child(this.about_hbox); hbox = new St.BoxLayout({ name: 'aboutArea' }); @@ -46,24 +38,69 @@ const AboutMenuButton = new Lang.Class({ this._os_release = Gio.File.new_for_path('/etc/os-release'); let success, contents, tag; try { - [success, contents, tag] = this._os_release.load_contents(null); + [success, contents, tag] = this._os_release.load_contents(null); } catch (e) { - this._sysinfo = new St.Label({ text: 'SUSE Linux Enterprise', - can_focus: true }); - vbox.add(this._sysinfo); - return; + contents = 'SUSE Linux Enterprise'; } let match = new RegExp('(.+)PRETTY_NAME=(.+)ID(.+)').exec(contents.toString().replace(/\n/g, ' ')); let sysinfo_text; if (!match) { - sysinfo_text = 'SUSE Linux Enterprise'; + sysinfo_text = 'SUSE Linux Enterprise'; } else { - sysinfo_text = match[2].toString().replace(/"/g, ' '); + sysinfo_text = match[2].toString().replace(/"/g, ' '); } this._sysinfo = new St.Label({ text: sysinfo_text, - can_focus: true }); + can_focus: true }); vbox.add(this._sysinfo); + this.actor.hide(); + + this._updateHostnameId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, + this._ticket, + Lang.bind(this, function() { + if (this._ticket < 60*60) + this._ticket *= 2; + this._updateHostnameId = 0; + this._updateHostname(); + return false; + })); + return; }, + + _updateHostname: function(){ + let command = 'hostname'; + let hostname_text; + try { + let [res, stdout, stderr, status] = GLib.spawn_command_line_sync(command); + hostname_text = String.fromCharCode.apply(null, stdout); + } catch (e) { + hostname_text = 'localhost'; + } + + if ((this._hostname == null) || (this._hostname != hostname_text)) { + this._ticket = 1; + this._hostname = hostname_text; + this.hostname_label.set_text(this._hostname); + this.actor.show(); + } + this._updateHostnameId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, + this._ticket, + Lang.bind(this, function() { + if (this._ticket < 60*60) + this._ticket *= 2; + this._updateHostnameId = 0; + this._updateHostname(); + return false; + })); + }, + + _destroy: function() { + this._ticket = 1; + if (this._updateHostnameId) { + GLib.source_remove (this._updateHostnameId); + this._updateHostnameId = 0; + } + }, + });
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor