Make x-position of notification configurable, add translation files , make po/update.js able to fetch translatable strings from xml(glade in this case) files.
parent
c7e3156798
commit
1bccf4db4e
@ -0,0 +1,8 @@ |
|||||||
|
<schemalist gettext-domain="gnome-shell-extension-panel-osd"> |
||||||
|
<schema id="org.gnome.shell.extensions.panel-osd" path="/org/gnome/shell/extensions/panel-osd/"> |
||||||
|
<key name="x-pos" type="d"> |
||||||
|
<default>50.0</default> |
||||||
|
<_summary>Horizontal position of notification.</_summary> |
||||||
|
</key> |
||||||
|
</schema> |
||||||
|
</schemalist> |
@ -0,0 +1,77 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!-- Generated with glade 3.16.1 --> |
||||||
|
<interface> |
||||||
|
<requires lib="gtk+" version="3.0"/> |
||||||
|
<object class="GtkAdjustment" id="x-adjustment"> |
||||||
|
<property name="upper">100</property> |
||||||
|
<property name="step_increment">0.10000000000000001</property> |
||||||
|
<property name="page_increment">2</property> |
||||||
|
</object> |
||||||
|
<object class="GtkBox" id="main-widget"> |
||||||
|
<property name="can_focus">False</property> |
||||||
|
<property name="margin_top">5</property> |
||||||
|
<property name="border_width">14</property> |
||||||
|
<property name="orientation">vertical</property> |
||||||
|
<child> |
||||||
|
<object class="GtkLabel" id="label-x-pos"> |
||||||
|
<property name="visible">True</property> |
||||||
|
<property name="can_focus">False</property> |
||||||
|
<property name="hexpand">True</property> |
||||||
|
<property name="xalign">0</property> |
||||||
|
<property name="label" translatable="yes">Horizontal position [%] from 0% (left) to 100% (right)</property> |
||||||
|
<property name="ellipsize">start</property> |
||||||
|
<property name="track_visited_links">False</property> |
||||||
|
</object> |
||||||
|
<packing> |
||||||
|
<property name="expand">False</property> |
||||||
|
<property name="fill">True</property> |
||||||
|
<property name="position">0</property> |
||||||
|
</packing> |
||||||
|
</child> |
||||||
|
<child> |
||||||
|
<object class="GtkScale" id="scale-x-pos"> |
||||||
|
<property name="visible">True</property> |
||||||
|
<property name="can_focus">True</property> |
||||||
|
<property name="hexpand">True</property> |
||||||
|
<property name="adjustment">x-adjustment</property> |
||||||
|
<property name="show_fill_level">True</property> |
||||||
|
<property name="restrict_to_fill_level">False</property> |
||||||
|
<property name="fill_level">100</property> |
||||||
|
</object> |
||||||
|
<packing> |
||||||
|
<property name="expand">True</property> |
||||||
|
<property name="fill">False</property> |
||||||
|
<property name="position">1</property> |
||||||
|
</packing> |
||||||
|
</child> |
||||||
|
<child> |
||||||
|
<object class="GtkSeparator" id="separator1"> |
||||||
|
<property name="visible">True</property> |
||||||
|
<property name="can_focus">False</property> |
||||||
|
<property name="margin_left">5</property> |
||||||
|
<property name="margin_right">5</property> |
||||||
|
<property name="margin_top">10</property> |
||||||
|
<property name="margin_bottom">10</property> |
||||||
|
</object> |
||||||
|
<packing> |
||||||
|
<property name="expand">False</property> |
||||||
|
<property name="fill">True</property> |
||||||
|
<property name="position">2</property> |
||||||
|
</packing> |
||||||
|
</child> |
||||||
|
<child> |
||||||
|
<object class="GtkButton" id="button-reset"> |
||||||
|
<property name="label" translatable="yes">Reset to defaults</property> |
||||||
|
<property name="visible">True</property> |
||||||
|
<property name="can_focus">True</property> |
||||||
|
<property name="receives_default">True</property> |
||||||
|
<property name="halign">end</property> |
||||||
|
</object> |
||||||
|
<packing> |
||||||
|
<property name="expand">False</property> |
||||||
|
<property name="fill">True</property> |
||||||
|
<property name="position">3</property> |
||||||
|
</packing> |
||||||
|
</child> |
||||||
|
</object> |
||||||
|
</interface> |
@ -0,0 +1 @@ |
|||||||
|
intltool.m4 |
@ -0,0 +1 @@ |
|||||||
|
de |
@ -0,0 +1,222 @@ |
|||||||
|
# Makefile for program source directory in GNU NLS utilities package.
|
||||||
|
# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
|
||||||
|
# Copyright (C) 2004-2008 Rodney Dawes <dobey.pwns@gmail.com>
|
||||||
|
#
|
||||||
|
# This file may be copied and used freely without restrictions. It may
|
||||||
|
# be used in projects which are not available under a GNU Public License,
|
||||||
|
# but which still want to provide support for the GNU gettext functionality.
|
||||||
|
#
|
||||||
|
# - Modified by Owen Taylor <otaylor@redhat.com> to use GETTEXT_PACKAGE
|
||||||
|
# instead of PACKAGE and to look for po2tbl in ./ not in intl/
|
||||||
|
#
|
||||||
|
# - Modified by jacob berkman <jacob@ximian.com> to install
|
||||||
|
# Makefile.in.in and po2tbl.sed.in for use with glib-gettextize
|
||||||
|
#
|
||||||
|
# - Modified by Rodney Dawes <dobey.pwns@gmail.com> for use with intltool
|
||||||
|
#
|
||||||
|
# We have the following line for use by intltoolize:
|
||||||
|
# INTLTOOL_MAKEFILE
|
||||||
|
|
||||||
|
GETTEXT_PACKAGE = gnome-shell-extension-panel-osd
|
||||||
|
PACKAGE = gnome-shell-extension-panel-osd
|
||||||
|
VERSION = 1.1
|
||||||
|
|
||||||
|
SHELL = /bin/sh
|
||||||
|
|
||||||
|
srcdir = .
|
||||||
|
top_srcdir = ..
|
||||||
|
top_builddir = ..
|
||||||
|
|
||||||
|
|
||||||
|
prefix = /usr/local
|
||||||
|
exec_prefix = ${prefix}
|
||||||
|
datadir = ${datarootdir}
|
||||||
|
datarootdir = ${prefix}/share
|
||||||
|
libdir = ${exec_prefix}/lib
|
||||||
|
DATADIRNAME = share
|
||||||
|
itlocaledir = $(prefix)/$(DATADIRNAME)/locale
|
||||||
|
subdir = po
|
||||||
|
install_sh = ${SHELL} /home/jens/sources/p/gnome-shell-extension-panel-osd/config/install-sh
|
||||||
|
# Automake >= 1.8 provides $(MKDIR_P).
|
||||||
|
# Until it can be supposed, use the safe fallback:
|
||||||
|
mkdir_p = $(install_sh) -d
|
||||||
|
|
||||||
|
INSTALL = /usr/bin/install -c
|
||||||
|
INSTALL_DATA = ${INSTALL} -m 644
|
||||||
|
|
||||||
|
GMSGFMT = /usr/bin/msgfmt
|
||||||
|
MSGFMT = /usr/bin/msgfmt
|
||||||
|
XGETTEXT = /usr/bin/xgettext
|
||||||
|
INTLTOOL_UPDATE = /usr/bin/intltool-update
|
||||||
|
INTLTOOL_EXTRACT = /usr/bin/intltool-extract
|
||||||
|
MSGMERGE = INTLTOOL_EXTRACT="$(INTLTOOL_EXTRACT)" XGETTEXT="$(XGETTEXT)" srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist
|
||||||
|
GENPOT = INTLTOOL_EXTRACT="$(INTLTOOL_EXTRACT)" XGETTEXT="$(XGETTEXT)" srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot
|
||||||
|
|
||||||
|
ALL_LINGUAS =
|
||||||
|
|
||||||
|
PO_LINGUAS=$(shell if test -r $(srcdir)/LINGUAS; then grep -v "^\#" $(srcdir)/LINGUAS; else echo "$(ALL_LINGUAS)"; fi)
|
||||||
|
|
||||||
|
USER_LINGUAS=$(shell if test -n "$(LINGUAS)"; then LLINGUAS="$(LINGUAS)"; ALINGUAS="$(ALL_LINGUAS)"; for lang in $$LLINGUAS; do if test -n "`grep \^$$lang$$ $(srcdir)/LINGUAS 2>/dev/null`" -o -n "`echo $$ALINGUAS|tr ' ' '\n'|grep \^$$lang$$`"; then printf "$$lang "; fi; done; fi)
|
||||||
|
|
||||||
|
USE_LINGUAS=$(shell if test -n "$(USER_LINGUAS)" -o -n "$(LINGUAS)"; then LLINGUAS="$(USER_LINGUAS)"; else if test -n "$(PO_LINGUAS)"; then LLINGUAS="$(PO_LINGUAS)"; else LLINGUAS="$(ALL_LINGUAS)"; fi; fi; for lang in $$LLINGUAS; do printf "$$lang "; done)
|
||||||
|
|
||||||
|
POFILES=$(shell LINGUAS="$(PO_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.po "; done)
|
||||||
|
|
||||||
|
DISTFILES = Makefile.in.in POTFILES.in $(POFILES)
|
||||||
|
EXTRA_DISTFILES = ChangeLog POTFILES.skip Makevars LINGUAS
|
||||||
|
|
||||||
|
POTFILES = \
|
||||||
|
# This comment gets stripped out
|
||||||
|
|
||||||
|
CATALOGS=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.gmo "; done)
|
||||||
|
|
||||||
|
.SUFFIXES: |
||||||
|
.SUFFIXES: .po .pox .gmo .mo .msg .cat |
||||||
|
|
||||||
|
AM_DEFAULT_VERBOSITY = 0
|
||||||
|
INTLTOOL_V_MSGFMT = $(INTLTOOL__v_MSGFMT_$(V))
|
||||||
|
INTLTOOL__v_MSGFMT_= $(INTLTOOL__v_MSGFMT_$(AM_DEFAULT_VERBOSITY))
|
||||||
|
INTLTOOL__v_MSGFMT_0 = @echo " MSGFMT" $@;
|
||||||
|
|
||||||
|
.po.pox: |
||||||
|
$(MAKE) $(GETTEXT_PACKAGE).pot
|
||||||
|
$(MSGMERGE) $< $(GETTEXT_PACKAGE).pot -o $*.pox
|
||||||
|
|
||||||
|
.po.mo: |
||||||
|
$(INTLTOOL_V_MSGFMT)$(MSGFMT) -o $@ $<
|
||||||
|
|
||||||
|
.po.gmo: |
||||||
|
$(INTLTOOL_V_MSGFMT)file=`echo $* | sed 's,.*/,,'`.gmo \
|
||||||
|
&& rm -f $$file && $(GMSGFMT) -o $$file $<
|
||||||
|
|
||||||
|
.po.cat: |
||||||
|
sed -f ../intl/po2msg.sed < $< > $*.msg \
|
||||||
|
&& rm -f $@ && gencat $@ $*.msg
|
||||||
|
|
||||||
|
|
||||||
|
all: all-yes |
||||||
|
|
||||||
|
all-yes: $(CATALOGS) |
||||||
|
all-no: |
||||||
|
|
||||||
|
$(GETTEXT_PACKAGE).pot: $(POTFILES) |
||||||
|
$(GENPOT)
|
||||||
|
|
||||||
|
install: install-data |
||||||
|
install-data: install-data-yes |
||||||
|
install-data-no: all |
||||||
|
install-data-yes: all |
||||||
|
linguas="$(USE_LINGUAS)"; \
|
||||||
|
for lang in $$linguas; do \
|
||||||
|
dir=$(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES; \
|
||||||
|
$(mkdir_p) $$dir; \
|
||||||
|
if test -r $$lang.gmo; then \
|
||||||
|
$(INSTALL_DATA) $$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \
|
||||||
|
echo "installing $$lang.gmo as $$dir/$(GETTEXT_PACKAGE).mo"; \
|
||||||
|
else \
|
||||||
|
$(INSTALL_DATA) $(srcdir)/$$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \
|
||||||
|
echo "installing $(srcdir)/$$lang.gmo as" \
|
||||||
|
"$$dir/$(GETTEXT_PACKAGE).mo"; \
|
||||||
|
fi; \
|
||||||
|
if test -r $$lang.gmo.m; then \
|
||||||
|
$(INSTALL_DATA) $$lang.gmo.m $$dir/$(GETTEXT_PACKAGE).mo.m; \
|
||||||
|
echo "installing $$lang.gmo.m as $$dir/$(GETTEXT_PACKAGE).mo.m"; \
|
||||||
|
else \
|
||||||
|
if test -r $(srcdir)/$$lang.gmo.m ; then \
|
||||||
|
$(INSTALL_DATA) $(srcdir)/$$lang.gmo.m \
|
||||||
|
$$dir/$(GETTEXT_PACKAGE).mo.m; \
|
||||||
|
echo "installing $(srcdir)/$$lang.gmo.m as" \
|
||||||
|
"$$dir/$(GETTEXT_PACKAGE).mo.m"; \
|
||||||
|
else \
|
||||||
|
true; \
|
||||||
|
fi; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
|
||||||
|
# Empty stubs to satisfy archaic automake needs
|
||||||
|
dvi info ctags tags CTAGS TAGS ID: |
||||||
|
|
||||||
|
# Define this as empty until I found a useful application.
|
||||||
|
install-exec installcheck: |
||||||
|
|
||||||
|
uninstall: |
||||||
|
linguas="$(USE_LINGUAS)"; \
|
||||||
|
for lang in $$linguas; do \
|
||||||
|
rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \
|
||||||
|
rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \
|
||||||
|
done
|
||||||
|
|
||||||
|
check: all $(GETTEXT_PACKAGE).pot |
||||||
|
rm -f missing notexist
|
||||||
|
srcdir=$(srcdir) $(INTLTOOL_UPDATE) -m
|
||||||
|
if [ -r missing -o -r notexist ]; then \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
mostlyclean: |
||||||
|
rm -f *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp
|
||||||
|
rm -f .intltool-merge-cache
|
||||||
|
|
||||||
|
clean: mostlyclean |
||||||
|
|
||||||
|
distclean: clean |
||||||
|
rm -f Makefile Makefile.in POTFILES stamp-it
|
||||||
|
rm -f *.mo *.msg *.cat *.cat.m *.gmo
|
||||||
|
|
||||||
|
maintainer-clean: distclean |
||||||
|
@echo "This command is intended for maintainers to use;"
|
||||||
|
@echo "it deletes files that may require special tools to rebuild."
|
||||||
|
rm -f Makefile.in.in
|
||||||
|
|
||||||
|
distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
|
||||||
|
dist distdir: $(DISTFILES) |
||||||
|
dists="$(DISTFILES)"; \
|
||||||
|
extra_dists="$(EXTRA_DISTFILES)"; \
|
||||||
|
for file in $$extra_dists; do \
|
||||||
|
test -f $(srcdir)/$$file && dists="$$dists $(srcdir)/$$file"; \
|
||||||
|
done; \
|
||||||
|
for file in $$dists; do \
|
||||||
|
test -f $$file || file="$(srcdir)/$$file"; \
|
||||||
|
ln $$file $(distdir) 2> /dev/null \
|
||||||
|
|| cp -p $$file $(distdir); \
|
||||||
|
done
|
||||||
|
|
||||||
|
update-po: Makefile |
||||||
|
$(MAKE) $(GETTEXT_PACKAGE).pot
|
||||||
|
tmpdir=`pwd`; \
|
||||||
|
linguas="$(USE_LINGUAS)"; \
|
||||||
|
for lang in $$linguas; do \
|
||||||
|
echo "$$lang:"; \
|
||||||
|
result="`$(MSGMERGE) -o $$tmpdir/$$lang.new.po $$lang`"; \
|
||||||
|
if $$result; then \
|
||||||
|
if cmp $(srcdir)/$$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
|
||||||
|
rm -f $$tmpdir/$$lang.new.po; \
|
||||||
|
else \
|
||||||
|
if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
|
||||||
|
:; \
|
||||||
|
else \
|
||||||
|
echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
|
||||||
|
rm -f $$tmpdir/$$lang.new.po; \
|
||||||
|
exit 1; \
|
||||||
|
fi; \
|
||||||
|
fi; \
|
||||||
|
else \
|
||||||
|
echo "msgmerge for $$lang.gmo failed!"; \
|
||||||
|
rm -f $$tmpdir/$$lang.new.po; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
|
||||||
|
Makefile POTFILES: stamp-it |
||||||
|
@if test ! -f $@; then \
|
||||||
|
rm -f stamp-it; \
|
||||||
|
$(MAKE) stamp-it; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
stamp-it: Makefile.in.in $(top_builddir)/config.status POTFILES.in |
||||||
|
cd $(top_builddir) \
|
||||||
|
&& CONFIG_FILES=$(subdir)/Makefile.in CONFIG_HEADERS= CONFIG_LINKS= \
|
||||||
|
$(SHELL) ./config.status
|
||||||
|
|
||||||
|
# Tell versions [3.59,3.63) of GNU make not to export all variables.
|
||||||
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||||
|
.NOEXPORT: |
@ -0,0 +1,3 @@ |
|||||||
|
../src/extension.js |
||||||
|
../src/prefs.js |
||||||
|
../data/panel-osd-settings.ui |
@ -0,0 +1,8 @@ |
|||||||
|
#: ../data/panel-osd-settings.ui:21 |
||||||
|
#, fuzzy |
||||||
|
msgid "Horizontal position [%] from 0% (left) to 100% (right)" |
||||||
|
msgstr "Horizontale Position [%] von links (0%) bis rechts (100%)" |
||||||
|
|
||||||
|
#: ../data/panel-osd-settings.ui:64 |
||||||
|
msgid "Reset to defaults" |
||||||
|
msgstr "Auf Standardwert zurücksetzen" |
@ -0,0 +1,22 @@ |
|||||||
|
# SOME DESCRIPTIVE TITLE. |
||||||
|
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
||||||
|
# This file is distributed under the same license as the PACKAGE package. |
||||||
|
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
||||||
|
# |
||||||
|
#, fuzzy |
||||||
|
msgid "" |
||||||
|
msgstr "" |
||||||
|
"Project-Id-Version: PACKAGE VERSION\n" |
||||||
|
"Report-Msgid-Bugs-To: \n" |
||||||
|
"POT-Creation-Date: 2014-02-16 18:20+0100\n" |
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
||||||
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
||||||
|
"Language-Team: LANGUAGE <LL@li.org>\n" |
||||||
|
"Language: \n" |
||||||
|
"MIME-Version: 1.0\n" |
||||||
|
"Content-Type: text/plain; charset=CHARSET\n" |
||||||
|
"Content-Transfer-Encoding: 8bit\n" |
||||||
|
|
||||||
|
#: ../data/panel-osd-settings.ui:19 |
||||||
|
msgid "Horizontal position [%] from left (0%) to right (100%)" |
||||||
|
msgstr "" |
@ -0,0 +1,54 @@ |
|||||||
|
#!/usr/bin/env seed
|
||||||
|
|
||||||
|
/* |
||||||
|
* |
||||||
|
* PO Updater for GNOME Shell Extension Panel OSD |
||||||
|
* |
||||||
|
* Copyright (C) 2012 |
||||||
|
* Christian METZLER <neroth@xeked.com> |
||||||
|
* 2014 Jens Lody <jens@jenslody.de> |
||||||
|
* |
||||||
|
* |
||||||
|
* This file is part of gnome-shell-extension-panel-osd. |
||||||
|
* |
||||||
|
* gnome-shell-extension-panel-osd is free software: you can redistribute it and/or modify |
||||||
|
* it under the terms of the GNU General Public License as published by |
||||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||||
|
* (at your option) any later version. |
||||||
|
* |
||||||
|
* gnome-shell-extension-panel-osd is distributed in the hope that it will be useful, |
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
|
* GNU General Public License for more details. |
||||||
|
* |
||||||
|
* You should have received a copy of the GNU General Public License |
||||||
|
* along with gnome-shell-extension-panel-osd. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
Gio = imports.gi.Gio; |
||||||
|
|
||||||
|
print("Generate gnome-shell-extension-panel-osd.pot"); |
||||||
|
var xgettext = Seed.spawn("xgettext -o gnome-shell-extension-panel-osd.pot --from-code=utf-8 --keyword=_ --keyword=translatable -f POTFILES.in"); |
||||||
|
|
||||||
|
if (xgettext.stderr) |
||||||
|
print(xgettext.stderr); |
||||||
|
else { |
||||||
|
var file = Gio.file_new_for_path("."); |
||||||
|
var enumerator = file.enumerate_children("standard::name,standard::size"); |
||||||
|
var linguas = ""; |
||||||
|
var n = ""; |
||||||
|
var i = 0; |
||||||
|
while (child = enumerator.next_file()) |
||||||
|
if (child.get_name().search(/.po$/) != -1) { |
||||||
|
print("Generate " + child.get_name()); |
||||||
|
linguas += n + (child.get_name().split(".po")[0]); |
||||||
|
Seed.spawn("msgmerge -U " + child.get_name() + " gnome-shell-extension-panel-osd.pot"); |
||||||
|
n = "\n"; |
||||||
|
i++; |
||||||
|
} |
||||||
|
|
||||||
|
print("Write LINGUAS file"); |
||||||
|
Gio.simple_write("LINGUAS", linguas); |
||||||
|
print("Successfully generated " + i + " entry"); |
||||||
|
} |
@ -0,0 +1,92 @@ |
|||||||
|
/* -*- mode: js -*- */ |
||||||
|
/* |
||||||
|
Copyright (c) 2011-2012, Giovanni Campagna <scampa.giovanni@gmail.com> |
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without |
||||||
|
modification, are permitted provided that the following conditions are met: |
||||||
|
* Redistributions of source code must retain the above copyright |
||||||
|
notice, this list of conditions and the following disclaimer. |
||||||
|
* Redistributions in binary form must reproduce the above copyright |
||||||
|
notice, this list of conditions and the following disclaimer in the |
||||||
|
documentation and/or other materials provided with the distribution. |
||||||
|
* Neither the name of the GNOME nor the |
||||||
|
names of its contributors may be used to endorse or promote products |
||||||
|
derived from this software without specific prior written permission. |
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY |
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
*/ |
||||||
|
const Gettext = imports.gettext; |
||||||
|
const Gio = imports.gi.Gio; |
||||||
|
|
||||||
|
const Config = imports.misc.config; |
||||||
|
const ExtensionUtils = imports.misc.extensionUtils; |
||||||
|
|
||||||
|
/** |
||||||
|
* initTranslations: |
||||||
|
* @domain: (optional): the gettext domain to use |
||||||
|
* |
||||||
|
* Initialize Gettext to load translations from extensionsdir/locale. |
||||||
|
* If @domain is not provided, it will be taken from metadata['gettext-domain'] |
||||||
|
*/ |
||||||
|
function initTranslations(domain) { |
||||||
|
let extension = ExtensionUtils.getCurrentExtension(); |
||||||
|
|
||||||
|
domain = domain || extension.metadata['gettext-domain']; |
||||||
|
|
||||||
|
// check if this extension was built with "make zip-file", and thus
|
||||||
|
// has the locale files in a subfolder
|
||||||
|
// otherwise assume that extension has been installed in the
|
||||||
|
// same prefix as gnome-shell
|
||||||
|
let localeDir = extension.dir.get_child('locale'); |
||||||
|
if (localeDir.query_exists(null)) |
||||||
|
Gettext.bindtextdomain(domain, localeDir.get_path()); |
||||||
|
else |
||||||
|
Gettext.bindtextdomain(domain, Config.LOCALEDIR); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* getSettings: |
||||||
|
* @schema: (optional): the GSettings schema id |
||||||
|
* |
||||||
|
* Builds and return a GSettings schema for @schema, using schema files |
||||||
|
* in extensionsdir/schemas. If @schema is not provided, it is taken from |
||||||
|
* metadata['settings-schema']. |
||||||
|
*/ |
||||||
|
function getSettings(schema) { |
||||||
|
let extension = ExtensionUtils.getCurrentExtension(); |
||||||
|
|
||||||
|
schema = schema || extension.metadata['settings-schema']; |
||||||
|
|
||||||
|
const GioSSS = Gio.SettingsSchemaSource; |
||||||
|
|
||||||
|
// check if this extension was built with "make zip-file", and thus
|
||||||
|
// has the schema files in a subfolder
|
||||||
|
// otherwise assume that extension has been installed in the
|
||||||
|
// same prefix as gnome-shell (and therefore schemas are available
|
||||||
|
// in the standard folders)
|
||||||
|
let schemaDir = extension.dir.get_child('schemas'); |
||||||
|
let schemaSource; |
||||||
|
if (schemaDir.query_exists(null)) |
||||||
|
schemaSource = GioSSS.new_from_directory(schemaDir.get_path(), |
||||||
|
GioSSS.get_default(), |
||||||
|
false); |
||||||
|
else |
||||||
|
schemaSource = GioSSS.get_default(); |
||||||
|
|
||||||
|
let schemaObj = schemaSource.lookup(schema, true); |
||||||
|
if (!schemaObj) |
||||||
|
throw new Error('Schema ' + schema + ' could not be found for extension ' + extension.metadata.uuid + '. Please check your installation.'); |
||||||
|
|
||||||
|
return new Gio.Settings({ |
||||||
|
settings_schema: schemaObj |
||||||
|
}); |
||||||
|
} |
@ -0,0 +1,88 @@ |
|||||||
|
const Gtk = imports.gi.Gtk; |
||||||
|
const GObject = imports.gi.GObject; |
||||||
|
const GtkBuilder = Gtk.Builder; |
||||||
|
const Lang = imports.lang; |
||||||
|
const Mainloop = imports.mainloop; |
||||||
|
|
||||||
|
const Gettext = imports.gettext.domain('gnome-shell-extension-panel-osd'); |
||||||
|
const _ = Gettext.gettext; |
||||||
|
|
||||||
|
const ExtensionUtils = imports.misc.extensionUtils; |
||||||
|
const Me = ExtensionUtils.getCurrentExtension(); |
||||||
|
const Convenience = Me.imports.convenience; |
||||||
|
|
||||||
|
const EXTENSIONDIR = Me.dir.get_path(); |
||||||
|
|
||||||
|
const PANEL_OSD_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.panel-osd'; |
||||||
|
const PANEL_OSD_X_POS_KEY = 'x-pos'; |
||||||
|
|
||||||
|
const PanelOsdPrefsWidget = new GObject.Class({ |
||||||
|
Name: 'PanelOsdExtension.Prefs.Widget', |
||||||
|
GTypeName: 'PanelOsdExtensionPrefsWidget', |
||||||
|
Extends: Gtk.Box, |
||||||
|
|
||||||
|
_init: function(params) { |
||||||
|
this.parent(params); |
||||||
|
|
||||||
|
this.initWindow(); |
||||||
|
|
||||||
|
this.add(this.MainWidget); |
||||||
|
}, |
||||||
|
|
||||||
|
Window: new Gtk.Builder(), |
||||||
|
|
||||||
|
initWindow: function() { |
||||||
|
this.Window.set_translation_domain('gnome-shell-extension-panel-osd'); |
||||||
|
this.Window.add_from_file(EXTENSIONDIR + "/panel-osd-settings.ui"); |
||||||
|
|
||||||
|
this.MainWidget = this.Window.get_object("main-widget"); |
||||||
|
|
||||||
|
this.x_scale = this.Window.get_object("scale-x-pos"); |
||||||
|
this.x_scale.set_value(this.x_position); |
||||||
|
// prevent from continously updating the value
|
||||||
|
this.xScaleTimeout = undefined; |
||||||
|
this.x_scale.connect("value-changed", Lang.bind(this, function(slider) { |
||||||
|
|
||||||
|
if (this.xScaleTimeout != undefined) |
||||||
|
Mainloop.source_remove(this.xScaleTimeout); |
||||||
|
this.xScaleTimeout = Mainloop.timeout_add(250, Lang.bind(this, function() { |
||||||
|
this.x_position = slider.get_value(); |
||||||
|
return false; |
||||||
|
})); |
||||||
|
|
||||||
|
})); |
||||||
|
|
||||||
|
this.Window.get_object("button-reset").connect("clicked", Lang.bind(this, function() { |
||||||
|
this.x_scale.set_value(50);; |
||||||
|
})); |
||||||
|
|
||||||
|
|
||||||
|
}, |
||||||
|
|
||||||
|
loadConfig: function() { |
||||||
|
this.Settings = Convenience.getSettings(PANEL_OSD_SETTINGS_SCHEMA); |
||||||
|
}, |
||||||
|
|
||||||
|
get x_position() { |
||||||
|
if (!this.Settings) |
||||||
|
this.loadConfig(); |
||||||
|
return this.Settings.get_double(PANEL_OSD_X_POS_KEY); |
||||||
|
}, |
||||||
|
|
||||||
|
set x_position(v) { |
||||||
|
if (!this.Settings) |
||||||
|
this.loadConfig(); |
||||||
|
this.Settings.set_double(PANEL_OSD_X_POS_KEY, v); |
||||||
|
} |
||||||
|
|
||||||
|
}); |
||||||
|
|
||||||
|
function init() { |
||||||
|
Convenience.initTranslations('gnome-shell-extension-panel-osd'); |
||||||
|
} |
||||||
|
|
||||||
|
function buildPrefsWidget() { |
||||||
|
let widget = new PanelOsdPrefsWidget(); |
||||||
|
widget.show_all(); |
||||||
|
return widget; |
||||||
|
} |
Loading…
Reference in new issue