2010-05-19 17:26:41 +00:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
|
|
|
2010-05-05 21:05:42 +00:00
|
|
|
const Gio = imports.gi.Gio;
|
2010-02-26 00:03:06 +00:00
|
|
|
const GLib = imports.gi.GLib;
|
|
|
|
const Gtk = imports.gi.Gtk;
|
|
|
|
|
|
|
|
const Lang = imports.lang;
|
|
|
|
const Signals = imports.signals;
|
|
|
|
|
2010-05-17 12:03:47 +00:00
|
|
|
const Gettext = imports.gettext;
|
|
|
|
|
2010-05-05 21:05:42 +00:00
|
|
|
const FORMAT_KEY = 'format';
|
|
|
|
const SHOW_DATE_KEY = 'show-date';
|
|
|
|
const SHOW_SECONDS_KEY = 'show-seconds';
|
2010-02-26 00:03:06 +00:00
|
|
|
|
2010-10-13 21:36:52 +00:00
|
|
|
const SHOW_WEEKDATE_KEY = 'show-weekdate';
|
2010-02-26 00:03:06 +00:00
|
|
|
|
|
|
|
function ClockPreferences(uiFile) {
|
|
|
|
this._init(uiFile);
|
|
|
|
};
|
|
|
|
|
|
|
|
ClockPreferences.prototype = {
|
|
|
|
_init: function(uiFile) {
|
|
|
|
let builder = new Gtk.Builder();
|
|
|
|
builder.add_from_file(uiFile);
|
|
|
|
|
|
|
|
this._dialog = builder.get_object('prefs-dialog');
|
|
|
|
this._dialog.connect('response', Lang.bind(this, this._onResponse));
|
|
|
|
|
|
|
|
this._12hrRadio = builder.get_object('12hr_radio');
|
|
|
|
this._24hrRadio = builder.get_object('24hr_radio');
|
|
|
|
this._dateCheck = builder.get_object('date_check');
|
|
|
|
this._secondsCheck = builder.get_object('seconds_check');
|
2010-10-13 21:36:52 +00:00
|
|
|
this._weekCheck = builder.get_object('week_check');
|
2010-02-26 00:03:06 +00:00
|
|
|
|
|
|
|
delete builder;
|
|
|
|
|
2010-05-05 21:05:42 +00:00
|
|
|
this._settings = new Gio.Settings({ schema: 'org.gnome.shell.clock' });
|
|
|
|
this._notifyId = this._settings.connect('changed',
|
2010-02-26 00:03:06 +00:00
|
|
|
Lang.bind(this,
|
|
|
|
this._updateDialog));
|
2010-10-13 21:36:52 +00:00
|
|
|
this._calendar_settings = new Gio.Settings({ schema: 'org.gnome.shell.calendar' });
|
|
|
|
this._calendar_notifyId = this._calendar_settings.connect('changed',
|
|
|
|
Lang.bind(this,
|
|
|
|
this._updateDialog));
|
2010-02-26 00:03:06 +00:00
|
|
|
|
|
|
|
this._12hrRadio.connect('toggled', Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
let format = this._12hrRadio.active ? '12-hour' : '24-hour';
|
2010-05-05 21:05:42 +00:00
|
|
|
this._settings.set_string(FORMAT_KEY, format);
|
2010-02-26 00:03:06 +00:00
|
|
|
}));
|
|
|
|
this._dateCheck.connect('toggled', Lang.bind(this,
|
|
|
|
function() {
|
2010-05-05 21:05:42 +00:00
|
|
|
this._settings.set_boolean(SHOW_DATE_KEY,
|
|
|
|
this._dateCheck.active);
|
2010-02-26 00:03:06 +00:00
|
|
|
}));
|
|
|
|
this._secondsCheck.connect('toggled', Lang.bind(this,
|
|
|
|
function() {
|
2010-05-05 21:05:42 +00:00
|
|
|
this._settings.set_boolean(SHOW_SECONDS_KEY,
|
|
|
|
this._secondsCheck.active);
|
2010-02-26 00:03:06 +00:00
|
|
|
}));
|
2010-10-13 21:36:52 +00:00
|
|
|
this._weekCheck.connect('toggled', Lang.bind(this,
|
|
|
|
function() {
|
|
|
|
this._calendar_settings.set_boolean(SHOW_WEEKDATE_KEY,
|
|
|
|
this._weekCheck.active);
|
|
|
|
}));
|
2010-02-26 00:03:06 +00:00
|
|
|
|
|
|
|
this._updateDialog();
|
|
|
|
},
|
|
|
|
|
|
|
|
show: function() {
|
|
|
|
this._dialog.show_all();
|
|
|
|
},
|
|
|
|
|
|
|
|
_updateDialog: function() {
|
2010-05-05 21:05:42 +00:00
|
|
|
let format = this._settings.get_string(FORMAT_KEY);
|
2010-02-26 00:03:06 +00:00
|
|
|
this._12hrRadio.active = (format == "12-hour");
|
|
|
|
this._24hrRadio.active = (format == "24-hour");
|
|
|
|
|
2010-05-05 21:05:42 +00:00
|
|
|
this._dateCheck.active = this._settings.get_boolean(SHOW_DATE_KEY);
|
|
|
|
this._secondsCheck.active = this._settings.get_boolean(SHOW_SECONDS_KEY);
|
2010-10-13 21:36:52 +00:00
|
|
|
this._weekCheck.active = this._calendar_settings.get_boolean(SHOW_WEEKDATE_KEY);
|
2010-02-26 00:03:06 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onResponse: function() {
|
|
|
|
this._dialog.destroy();
|
2010-05-05 21:05:42 +00:00
|
|
|
this._settings.disconnect(this._notifyId);
|
2010-10-13 21:36:52 +00:00
|
|
|
this._calendar_settings.disconnect(this._calendar_notifyId);
|
2010-02-26 00:03:06 +00:00
|
|
|
this.emit('destroy');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
Signals.addSignalMethods(ClockPreferences.prototype);
|
|
|
|
|
|
|
|
function main(params) {
|
|
|
|
if ('progName' in params)
|
|
|
|
GLib.set_prgname(params['progName']);
|
2010-05-17 12:03:47 +00:00
|
|
|
if ('localeDir' in params)
|
|
|
|
Gettext.bindtextdomain('gnome-shell', params['localeDir']);
|
|
|
|
|
2010-02-26 00:03:06 +00:00
|
|
|
Gtk.init(null, null);
|
|
|
|
|
|
|
|
let clockPrefs = new ClockPreferences(params['uiFile']);
|
|
|
|
clockPrefs.connect('destroy',
|
|
|
|
function() {
|
|
|
|
Gtk.main_quit();
|
|
|
|
});
|
|
|
|
clockPrefs.show();
|
|
|
|
|
|
|
|
Gtk.main();
|
|
|
|
}
|