Add a simple preference dialog for the clock
Port the 'General' preferences tab of the panel's clock applet to javascript and add it to the build system. https://bugzilla.gnome.org/show_bug.cgi?id=600276
This commit is contained in:
parent
e6b91414de
commit
266a0fb7d6
3
.gitignore
vendored
3
.gitignore
vendored
@ -18,6 +18,8 @@ config
|
||||
configure
|
||||
data/gnome-shell.desktop
|
||||
data/gnome-shell.desktop.in
|
||||
data/gnome-shell-clock-preferences.desktop
|
||||
data/gnome-shell-clock-preferences.desktop.in
|
||||
intltool-extract.in
|
||||
intltool-merge.in
|
||||
intltool-update.in
|
||||
@ -38,6 +40,7 @@ src/Makefile
|
||||
src/Makefile.in
|
||||
src/gnomeshell-taskpanel
|
||||
src/gnome-shell
|
||||
src/gnome-shell-clock-preferences
|
||||
src/test-recorder
|
||||
src/test-recorder.ogg
|
||||
src/test-theme
|
||||
|
@ -96,8 +96,10 @@ AC_SUBST(MUTTER_PLUGIN_DIR)
|
||||
|
||||
GJS_JS_DIR=`$PKG_CONFIG --variable=jsdir gjs-1.0`
|
||||
GJS_JS_NATIVE_DIR=`$PKG_CONFIG --variable=jsnativedir gjs-1.0`
|
||||
GJS_CONSOLE=`$PKG_CONFIG --variable=gjs_console gjs-1.0`
|
||||
AC_SUBST(GJS_JS_DIR)
|
||||
AC_SUBST(GJS_JS_NATIVE_DIR)
|
||||
AC_SUBST(GJS_CONSOLE)
|
||||
|
||||
AC_CHECK_FUNCS(fdwalk)
|
||||
AC_CHECK_HEADERS([sys/resource.h])
|
||||
@ -151,6 +153,7 @@ AC_CONFIG_FILES([
|
||||
js/Makefile
|
||||
js/misc/Makefile
|
||||
js/ui/Makefile
|
||||
js/prefs/Makefile
|
||||
src/Makefile
|
||||
tests/Makefile
|
||||
po/Makefile.in
|
||||
|
@ -1,17 +1,19 @@
|
||||
desktopdir=$(datadir)/applications
|
||||
desktop_DATA = gnome-shell.desktop
|
||||
desktop_DATA = gnome-shell.desktop gnome-shell-clock-preferences.desktop
|
||||
|
||||
# We substitute in bindir so it works as an autostart
|
||||
# file when built in a non-system prefix
|
||||
gnome-shell.desktop.in: gnome-shell.desktop.in.in
|
||||
%.desktop.in:%.desktop.in.in
|
||||
$(AM_V_GEN) sed -e "s|@bindir[@]|$(bindir)|" \
|
||||
-e "s|@VERSION[@]|$(VERSION)|" \
|
||||
$< > $@ || rm $@
|
||||
|
||||
# Placeholder until we add intltool
|
||||
gnome-shell.desktop: gnome-shell.desktop.in
|
||||
%.desktop:%.desktop.in
|
||||
$(AM_V_GEN) sed s/^_// < $< > $@ || rm $@
|
||||
|
||||
pkgdata_DATA = clock-preferences.ui
|
||||
|
||||
imagesdir = $(pkgdatadir)/images
|
||||
dist_images_DATA = \
|
||||
close-black.svg \
|
||||
@ -52,9 +54,11 @@ install-data-local:
|
||||
|
||||
EXTRA_DIST = \
|
||||
gnome-shell.desktop.in.in \
|
||||
gnome-shell-clock-preferences.desktop.in.in \
|
||||
$(schema_DATA)
|
||||
|
||||
CLEANFILES = \
|
||||
gnome-shell.desktop.in \
|
||||
gnome-shell-clock-preferences.desktop.in \
|
||||
$(desktop_DATA)
|
||||
|
||||
|
184
data/clock-preferences.ui
Normal file
184
data/clock-preferences.ui
Normal file
@ -0,0 +1,184 @@
|
||||
<?xml version="1.0"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.16"/>
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<object class="GtkDialog" id="prefs-dialog">
|
||||
<property name="border_width">5</property>
|
||||
<property name="title" translatable="yes">Clock Preferences</property>
|
||||
<property name="window_position">center</property>
|
||||
<property name="type_hint">normal</property>
|
||||
<property name="has_separator">False</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkVBox" id="dialog-vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">18</property>
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">none</property>
|
||||
<child>
|
||||
<object class="GtkAlignment" id="alignment1">
|
||||
<property name="visible">True</property>
|
||||
<property name="top_padding">6</property>
|
||||
<property name="left_padding">12</property>
|
||||
<property name="right_padding">6</property>
|
||||
<child>
|
||||
<object class="GtkHBox" id="hbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="12hr_radio">
|
||||
<property name="label" translatable="yes">_12 hour format</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="24hr_radio">
|
||||
<property name="label" translatable="yes">_24 hour format</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<property name="group">12hr_radio</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="label_format">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><b>Clock Format</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame" id="frame2">
|
||||
<property name="visible">True</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">none</property>
|
||||
<child>
|
||||
<object class="GtkAlignment" id="alignment2">
|
||||
<property name="visible">True</property>
|
||||
<property name="top_padding">6</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="date_check">
|
||||
<property name="label" translatable="yes">Show the _date</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="seconds_check">
|
||||
<property name="label" translatable="yes">Show seco_nds</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="label_display">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><b>Panel Display</b></property>
|
||||
<property name="use_markup">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="padding">6</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkHButtonBox" id="dialog-action_area1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="prefs_close_button">
|
||||
<property name="label">gtk-close</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="0">prefs_close_button</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
</interface>
|
15
data/gnome-shell-clock-preferences.desktop.in.in
Normal file
15
data/gnome-shell-clock-preferences.desktop.in.in
Normal file
@ -0,0 +1,15 @@
|
||||
[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@
|
@ -1 +1 @@
|
||||
SUBDIRS = misc ui
|
||||
SUBDIRS = misc ui prefs
|
||||
|
4
js/prefs/Makefile.am
Normal file
4
js/prefs/Makefile.am
Normal file
@ -0,0 +1,4 @@
|
||||
jsprefsdir = $(pkgdatadir)/js/prefs
|
||||
|
||||
dist_jsprefs_DATA = \
|
||||
clockPreferences.js
|
91
js/prefs/clockPreferences.js
Normal file
91
js/prefs/clockPreferences.js
Normal file
@ -0,0 +1,91 @@
|
||||
const GLib = imports.gi.GLib;
|
||||
const Gtk = imports.gi.Gtk;
|
||||
const GConf = imports.gi.GConf;
|
||||
|
||||
const Lang = imports.lang;
|
||||
const Signals = imports.signals;
|
||||
|
||||
const GCONF_DIR = '/desktop/gnome/shell/clock';
|
||||
const FORMAT_KEY = GCONF_DIR + '/format';
|
||||
const SHOW_DATE_KEY = GCONF_DIR + '/show_date';
|
||||
const SHOW_SECONDS_KEY = GCONF_DIR + '/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._gconf = GConf.Client.get_default();
|
||||
this._gconf.add_dir(GCONF_DIR, GConf.ClientPreloadType.PRELOAD_NONE);
|
||||
this._notifyId = this._gconf.notify_add(GCONF_DIR,
|
||||
Lang.bind(this,
|
||||
this._updateDialog));
|
||||
|
||||
this._12hrRadio.connect('toggled', Lang.bind(this,
|
||||
function() {
|
||||
let format = this._12hrRadio.active ? '12-hour' : '24-hour';
|
||||
this._gconf.set_string(FORMAT_KEY, format);
|
||||
}));
|
||||
this._dateCheck.connect('toggled', Lang.bind(this,
|
||||
function() {
|
||||
this._gconf.set_bool(SHOW_DATE_KEY, this._dateCheck.active);
|
||||
}));
|
||||
this._secondsCheck.connect('toggled', Lang.bind(this,
|
||||
function() {
|
||||
this._gconf.set_bool(SHOW_SECONDS_KEY,
|
||||
this._secondsCheck.active);
|
||||
}));
|
||||
|
||||
this._updateDialog();
|
||||
},
|
||||
|
||||
show: function() {
|
||||
this._dialog.show_all();
|
||||
},
|
||||
|
||||
_updateDialog: function() {
|
||||
let format = this._gconf.get_string(FORMAT_KEY);
|
||||
this._12hrRadio.active = (format == "12-hour");
|
||||
this._24hrRadio.active = (format == "24-hour");
|
||||
|
||||
this._dateCheck.active = this._gconf.get_bool(SHOW_DATE_KEY);
|
||||
this._secondsCheck.active = this._gconf.get_bool(SHOW_SECONDS_KEY);
|
||||
},
|
||||
|
||||
_onResponse: function() {
|
||||
this._dialog.destroy();
|
||||
this._gconf.notify_remove(this._notifyId);
|
||||
this.emit('destroy');
|
||||
}
|
||||
};
|
||||
Signals.addSignalMethods(ClockPreferences.prototype);
|
||||
|
||||
function main(params) {
|
||||
if ('progName' in params)
|
||||
GLib.set_prgname(params['progName']);
|
||||
Gtk.init(null, null);
|
||||
|
||||
let clockPrefs = new ClockPreferences(params['uiFile']);
|
||||
clockPrefs.connect('destroy',
|
||||
function() {
|
||||
Gtk.main_quit();
|
||||
});
|
||||
clockPrefs.show();
|
||||
|
||||
Gtk.main();
|
||||
}
|
@ -8,7 +8,7 @@ noinst_PROGRAMS =
|
||||
|
||||
.AUTOPARALLEL:
|
||||
|
||||
bin_SCRIPTS = gnome-shell
|
||||
bin_SCRIPTS = gnome-shell gnome-shell-clock-preferences
|
||||
|
||||
gnome-shell: gnome-shell.in
|
||||
$(AM_V_GEN) sed -e "s|@MUTTER_BIN_DIR[@]|$(MUTTER_BIN_DIR)|" \
|
||||
@ -24,6 +24,13 @@ 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|@pkgdatadir[@]|$(pkgdatadir)|" \
|
||||
-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
|
||||
|
18
src/gnome-shell-clock-preferences.in
Normal file
18
src/gnome-shell-clock-preferences.in
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -f "$0.in" ]
|
||||
then
|
||||
scriptDir="`dirname $0`"
|
||||
uiDir="$scriptDir/../data"
|
||||
jsDir="$scriptDir/../js"
|
||||
else
|
||||
uiDir="@pkgdatadir@"
|
||||
jsDir="@pkgdatadir@/js"
|
||||
fi
|
||||
|
||||
progName="`basename $0`"
|
||||
uiFile="$uiDir/clock-preferences.ui"
|
||||
export GJS_PATH="$jsDir"
|
||||
|
||||
@GJS_CONSOLE@ -c "const ClockPreferences = imports.prefs.clockPreferences;
|
||||
ClockPreferences.main({ progName: '$progName', uiFile: '$uiFile' });"
|
Loading…
Reference in New Issue
Block a user