From 24f1e87813cf516b8151cc6112cee03dacbe9d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 2 Dec 2010 17:28:06 +0100 Subject: [PATCH] clock: Use settings from gsettings-desktop-schemas A key for 12hr/24hr clock format has been added to gsettings-desktop-schemas, so use that instead of the one from the shell clock schema. As the setting can be controlled from the Date and Time panel of gnome-control-center now, drop the temporary preference dialog as well. https://bugzilla.gnome.org/show_bug.cgi?id=633200 --- .gitignore | 3 - data/Makefile.am | 6 +- data/clock-preferences.ui | 188 ------------------ ...nome-shell-clock-preferences.desktop.in.in | 15 -- data/org.gnome.shell.gschema.xml.in | 37 +--- js/Makefile.am | 1 - js/prefs/clockPreferences.js | 97 --------- js/ui/panel.js | 65 ++---- po/POTFILES.in | 2 - src/Makefile.am | 11 +- src/gnome-shell-clock-preferences.in | 24 --- 11 files changed, 23 insertions(+), 426 deletions(-) delete mode 100644 data/clock-preferences.ui delete mode 100644 data/gnome-shell-clock-preferences.desktop.in.in delete mode 100644 js/prefs/clockPreferences.js delete mode 100644 src/gnome-shell-clock-preferences.in diff --git a/.gitignore b/.gitignore index c3669d44c..e043cb850 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,6 @@ config configure data/gnome-shell.desktop data/gnome-shell.desktop.in -data/gnome-shell-clock-preferences.desktop -data/gnome-shell-clock-preferences.desktop.in data/gschemas.compiled data/org.gnome.shell.gschema.xml data/org.gnome.shell.gschema.valid @@ -46,7 +44,6 @@ src/Makefile src/Makefile.in src/gnomeshell-taskpanel src/gnome-shell -src/gnome-shell-clock-preferences src/run-js-test src/test-recorder src/test-recorder.ogg diff --git a/data/Makefile.am b/data/Makefile.am index d8cb9064c..ece423d24 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,5 +1,5 @@ desktopdir=$(datadir)/applications -desktop_DATA = gnome-shell.desktop gnome-shell-clock-preferences.desktop +desktop_DATA = gnome-shell.desktop # We substitute in bindir so it works as an autostart # file when built in a non-system prefix @@ -12,8 +12,6 @@ desktop_DATA = gnome-shell.desktop gnome-shell-clock-preferences.desktop %.desktop:%.desktop.in $(AM_V_GEN) sed s/^_// < $< > $@ || rm $@ -dist_pkgdata_DATA = clock-preferences.ui - imagesdir = $(pkgdatadir)/images dist_images_DATA = \ close-black.svg \ @@ -88,7 +86,6 @@ install-data-local: EXTRA_DIST = \ gnome-shell.desktop.in.in \ - gnome-shell-clock-preferences.desktop.in.in \ $(menu_DATA) \ $(gconfschema_DATA) \ $(shaders_DATA) \ @@ -97,7 +94,6 @@ EXTRA_DIST = \ CLEANFILES = \ gnome-shell.desktop.in \ - gnome-shell-clock-preferences.desktop.in \ $(desktop_DATA) \ $(gsettings_SCHEMAS) \ gschemas.compiled diff --git a/data/clock-preferences.ui b/data/clock-preferences.ui deleted file mode 100644 index 2e22d9aa9..000000000 --- a/data/clock-preferences.ui +++ /dev/null @@ -1,188 +0,0 @@ - - - - - - 5 - Clock Preferences - center - normal - False - - - True - vertical - 2 - - - True - vertical - 18 - - - True - 0 - none - - - True - 6 - 12 - 6 - - - True - 12 - - - _12 hour format - True - True - False - True - True - - - False - False - 0 - - - - - _24 hour format - True - True - False - True - True - 12hr_radio - - - False - False - 1 - - - - - - - - - True - Clock Format - - - - - - - - False - False - 0 - - - - - True - 0 - none - - - True - 6 - 12 - - - True - vertical - 6 - - - Show the _date - True - True - False - True - True - - - 0 - - - - - Show seco_nds - True - True - False - True - True - - - 1 - - - - - - - - - True - Panel Display - - - - - - - - False - False - 1 - - - - - 6 - 1 - - - - - True - end - - - - - - gtk-close - True - True - True - True - - - False - False - 1 - - - - - False - end - 0 - - - - - - prefs_close_button - - - diff --git a/data/gnome-shell-clock-preferences.desktop.in.in b/data/gnome-shell-clock-preferences.desktop.in.in deleted file mode 100644 index 5886dd509..000000000 --- a/data/gnome-shell-clock-preferences.desktop.in.in +++ /dev/null @@ -1,15 +0,0 @@ -[Desktop Entry] -_Name=Clock -_Comment=Customize the panel clock -Exec=@bindir@/gnome-shell-clock-preferences -Icon=gnome-panel-clock -Terminal=false -Type=Application -StartupNotify=true -Categories=GNOME;GTK;Settings;DesktopSettings; -OnlyShowIn=GNOME; -X-GNOME-ShellOnly=true -X-GNOME-Bugzilla-Bugzilla=GNOME -X-GNOME-Bugzilla-Product=gnome-shell -X-GNOME-Bugzilla-Component=general -X-GNOME-Bugzilla-Version=@VERSION@ diff --git a/data/org.gnome.shell.gschema.xml.in b/data/org.gnome.shell.gschema.xml.in index 031930a4b..843426853 100644 --- a/data/org.gnome.shell.gschema.xml.in +++ b/data/org.gnome.shell.gschema.xml.in @@ -59,51 +59,18 @@ - - - - "12-hour" - - <_summary>Hour format - <_description> - This key specifies the hour format used by the panel clock. - Possible values are "12-hour", "24-hour", "unix" and "custom". If set - to "unix", the clock will display time in seconds since Epoch, - i.e. 1970-01-01. If set to "custom", the clock will display time - according to the format specified in the custom_format key. Note that - if set to either "unix" or "custom", the show_date and show_seconds - keys are ignored. - - - - - - - - - - '' - <_summary>Custom format of the clock - <_description> - This key specifies the format used by the panel clock when the format - key is set to "custom". You can use conversion specifiers understood - by strftime() to obtain a specific format. See the strftime() manual - for more information. - - false <_summary>Show time with seconds <_description> - If true and format is either "12-hour" or "24-hour", display seconds in time. + If true, display seconds in time. false <_summary>Show date in clock <_description> - If true and format is either "12-hour" or "24-hour", - display date in the clock, in addition to time. + If true, display date in the clock, in addition to time. diff --git a/js/Makefile.am b/js/Makefile.am index 462f81b9b..555be7b19 100644 --- a/js/Makefile.am +++ b/js/Makefile.am @@ -11,7 +11,6 @@ nobase_dist_js_DATA = \ misc/telepathy.js \ misc/utils.js \ perf/core.js \ - prefs/clockPreferences.js \ ui/altTab.js \ ui/appDisplay.js \ ui/appFavorites.js \ diff --git a/js/prefs/clockPreferences.js b/js/prefs/clockPreferences.js deleted file mode 100644 index f35d8e250..000000000 --- a/js/prefs/clockPreferences.js +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ - -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; -const Gtk = imports.gi.Gtk; - -const Lang = imports.lang; -const Signals = imports.signals; - -const Gettext = imports.gettext; - -const FORMAT_KEY = 'format'; -const SHOW_DATE_KEY = 'show-date'; -const SHOW_SECONDS_KEY = 'show-seconds'; - - -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'); - - delete builder; - - this._settings = new Gio.Settings({ schema: 'org.gnome.shell.clock' }); - this._notifyId = this._settings.connect('changed', - Lang.bind(this, - this._updateDialog)); - - this._12hrRadio.connect('toggled', Lang.bind(this, - function() { - let format = this._12hrRadio.active ? '12-hour' : '24-hour'; - this._settings.set_string(FORMAT_KEY, format); - })); - this._dateCheck.connect('toggled', Lang.bind(this, - function() { - this._settings.set_boolean(SHOW_DATE_KEY, - this._dateCheck.active); - })); - this._secondsCheck.connect('toggled', Lang.bind(this, - function() { - this._settings.set_boolean(SHOW_SECONDS_KEY, - this._secondsCheck.active); - })); - - this._updateDialog(); - }, - - show: function() { - this._dialog.show_all(); - }, - - _updateDialog: function() { - let format = this._settings.get_string(FORMAT_KEY); - this._12hrRadio.active = (format == "12-hour"); - this._24hrRadio.active = (format == "24-hour"); - - this._dateCheck.active = this._settings.get_boolean(SHOW_DATE_KEY); - this._secondsCheck.active = this._settings.get_boolean(SHOW_SECONDS_KEY); - }, - - _onResponse: function() { - this._dialog.destroy(); - this._settings.disconnect(this._notifyId); - this.emit('destroy'); - } -}; -Signals.addSignalMethods(ClockPreferences.prototype); - -function main(params) { - if ('progName' in params) - GLib.set_prgname(params['progName']); - if ('localeDir' in params) - Gettext.bindtextdomain('gnome-shell', params['localeDir']); - - Gtk.init(null, null); - - let clockPrefs = new ClockPreferences(params['uiFile']); - clockPrefs.connect('destroy', - function() { - Gtk.main_quit(); - }); - clockPrefs.show(); - - Gtk.main(); -} diff --git a/js/ui/panel.js b/js/ui/panel.js index e797a36f9..eb994d172 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -40,8 +40,10 @@ const STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION = { if (Config.HAVE_BLUETOOTH) STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION['bluetooth'] = imports.ui.status.bluetooth.Indicator; -const CLOCK_FORMAT_KEY = 'format'; -const CLOCK_CUSTOM_FORMAT_KEY = 'custom-format'; +// in org.gnome.desktop.interface +const CLOCK_FORMAT_KEY = 'clock-format'; + +// in org.gnome.shell.clock const CLOCK_SHOW_DATE_KEY = 'show-date'; const CLOCK_SHOW_SECONDS_KEY = 'show-seconds'; @@ -492,36 +494,32 @@ function ClockButton() { } ClockButton.prototype = { - __proto__: PanelMenu.Button.prototype, - _init: function() { - PanelMenu.Button.prototype._init.call(this, St.Align.START); - this.menu.addAction(_("Preferences"), Lang.bind(this, this._onPrefs)); + this.actor = new St.Bin({ style_class: 'panel-button', + reactive: true, + can_focus: true, + x_fill: true, + y_fill: false, + track_hover: true }); + this.actor._delegate = this; + this.actor.connect('button-press-event', + Lang.bind(this, this._toggleCalendar)); this._clock = new St.Label(); this.actor.set_child(this._clock); this._calendarPopup = null; + this._desktopSettings = new Gio.Settings({ schema: 'org.gnome.desktop.interface' }); this._clockSettings = new Gio.Settings({ schema: 'org.gnome.shell.clock' }); + + this._desktopSettings.connect('changed', Lang.bind(this, this._updateClock)); this._clockSettings.connect('changed', Lang.bind(this, this._updateClock)); // Start the clock this._updateClock(); }, - _onButtonPress: function(actor, event) { - let button = event.get_button(); - let menuShowing = this.menu.isOpen; - let calendarShowing = this._calendarPopup && this._calendarPopup.isOpen; - - if (menuShowing || (button == 3 && !calendarShowing)) - this.menu.toggle(); - else - this._toggleCalendar(); - return true; - }, - closeCalendar: function() { if (!this._calendarPopup || !this._calendarPopup.isOpen) return; @@ -537,24 +535,12 @@ ClockButton.prototype = { this.actor.add_style_pseudo_class('pressed'); }, - _onPrefs: function() { - let args = ['gnome-shell-clock-preferences']; - let p = new Shell.Process({ args: args }); - - p.run(); - }, - _toggleCalendar: function() { if (this._calendarPopup == null) { this._calendarPopup = new CalendarPopup(); this._calendarPopup.actor.hide(); } - if (this.menu.isOpen && !this._calendarPopup.isOpen) { - this.menu.close(); - return; - } - if (!this._calendarPopup.isOpen) this.openCalendar(); else @@ -562,23 +548,13 @@ ClockButton.prototype = { }, _updateClock: function() { - let format = this._clockSettings.get_string(CLOCK_FORMAT_KEY); + let format = this._desktopSettings.get_string(CLOCK_FORMAT_KEY); let showDate = this._clockSettings.get_boolean(CLOCK_SHOW_DATE_KEY); let showSeconds = this._clockSettings.get_boolean(CLOCK_SHOW_SECONDS_KEY); let clockFormat; switch (format) { - case 'unix': - // force updates every second - showSeconds = true; - clockFormat = '%s'; - break; - case 'custom': - // force updates every second - showSeconds = true; - clockFormat = this._clockSettings.get_string(CLOCK_CUSTOM_FORMAT_KEY); - break; - case '24-hour': + case '24h': if (showDate) /* Translators: This is the time format with date used in 24-hour mode. */ @@ -590,7 +566,7 @@ ClockButton.prototype = { clockFormat = showSeconds ? _("%a %R:%S") : _("%a %R"); break; - case '12-hour': + case '12h': default: if (showDate) /* Translators: This is a time format with date used @@ -803,9 +779,6 @@ Panel.prototype = { this._clockButton = new ClockButton(); this._centerBox.add(this._clockButton.actor, { y_fill: true }); - let clockMenuManager = new PopupMenu.PopupMenuManager(this); - clockMenuManager.addMenu(this._clockButton.menu); - /* right */ // System status applets live in statusBox, while legacy tray icons diff --git a/po/POTFILES.in b/po/POTFILES.in index b0e2831cb..5ac0ba766 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,8 +1,6 @@ data/gnome-shell.desktop.in.in -data/gnome-shell-clock-preferences.desktop.in.in data/org.gnome.shell.gschema.xml.in data/org.gnome.accessibility.magnifier.gschema.xml.in -[type: gettext/glade]data/clock-preferences.ui js/ui/appDisplay.js js/ui/appFavorites.js js/ui/dash.js diff --git a/src/Makefile.am b/src/Makefile.am index e79a486fe..fa9804b72 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,7 +8,7 @@ noinst_PROGRAMS = .AUTOPARALLEL: -bin_SCRIPTS = gnome-shell gnome-shell-clock-preferences +bin_SCRIPTS = gnome-shell gnome-shell: gnome-shell.in $(AM_V_GEN) sed -e "s|@MUTTER_BIN_DIR[@]|$(MUTTER_BIN_DIR)|" \ @@ -23,15 +23,6 @@ gnome-shell: gnome-shell.in CLEANFILES += gnome-shell EXTRA_DIST += gnome-shell.in -gnome-shell-clock-preferences: gnome-shell-clock-preferences.in - $(AM_V_GEN) sed -e "s|@datadir[@]|$(datadir)|" \ - -e "s|@pkgdatadir[@]|$(pkgdatadir)|" \ - -e "s|@localedir[@]|$(datadir)/locale|" \ - -e "s|@GJS_CONSOLE[@]|$(GJS_CONSOLE)|" \ - $< > $@ && chmod a+x $@ -CLEANFILES += gnome-shell-clock-preferences -EXTRA_DIST += gnome-shell-clock-preferences.in - include Makefile-gdmuser.am include Makefile-st.am include Makefile-tray.am diff --git a/src/gnome-shell-clock-preferences.in b/src/gnome-shell-clock-preferences.in deleted file mode 100644 index 76391a8e0..000000000 --- a/src/gnome-shell-clock-preferences.in +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -if [ -f "$0.in" ] -then - scriptDir="`dirname $0`" - uiDir="$scriptDir/../data" - jsDir="$scriptDir/../js" - schemaDir="$scriptDir/../data" -else - uiDir="@pkgdatadir@" - jsDir="@pkgdatadir@/js" - schemaDir="@datadir@/glib-2.0/schemas" -fi - -progName="`basename $0`" -localeDir="@localedir@" -uiFile="$uiDir/clock-preferences.ui" -export GJS_PATH="$jsDir" -export GSETTINGS_SCHEMA_DIR="$schemaDir" - -@GJS_CONSOLE@ --js-version 1.8 -c "const ClockPreferences = imports.prefs.clockPreferences; -ClockPreferences.main({ progName: '$progName', - uiFile: '$uiFile', - localeDir: '$localeDir' });"