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.

master
Jens Lody 11 years ago
parent c7e3156798
commit 1bccf4db4e
  1. 7
      Makefile.am
  2. 13
      configure.ac
  3. 11
      data/Makefile.am
  4. 8
      data/org.gnome.shell.extensions.panel-osd.gschema.xml.in
  5. 77
      data/panel-osd-settings.ui
  6. 9
      gnome-shell-extension-panel-osd.cbp
  7. 1
      m4/.gitignore
  8. 1
      po/LINGUAS
  9. 222
      po/Makefile.in
  10. 3
      po/POTFILES.in
  11. 8
      po/de.po
  12. 22
      po/gnome-shell-extension-panel-osd.pot
  13. 54
      po/update.js
  14. 2
      src/Makefile.am
  15. 92
      src/convenience.js
  16. 31
      src/extension.js
  17. 88
      src/prefs.js

@ -1,6 +1,6 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
SUBDIRS = src data
SUBDIRS = src data po
uuid = panel-osd@berend.de.schouwer.gmail.com
@ -13,6 +13,11 @@ zip-file: all
$(MKDIR_P) $(builddir)/zip-file; \
$(MAKE) install DESTDIR="$(abs_builddir)/_build"; \
cp -r "$(builddir)/_build$(datadir)/gnome-shell/extensions/$(uuid)" "$(builddir)/_build"; \
if [ -f "$(builddir)/_build$(datadir)/glib-2.0/schemas/org.gnome.shell.extensions.panel-osd.gschema.xml" ]; then \
$(MKDIR_P) "$(builddir)/_build/$(uuid)/schemas"; \
mv "$(builddir)/_build$(datadir)/glib-2.0/schemas/org.gnome.shell.extensions.panel-osd.gschema.xml" "$(builddir)/_build/$(uuid)/schemas"; \
glib-compile-schemas "$(builddir)/_build/$(uuid)/schemas"; \
fi; \
cp -r "$(builddir)/_build$(datadir)/locale" "$(builddir)/_build/$(uuid)"; \
(cd "$(builddir)/_build/$(uuid)/"; \
zip -qr "$(abs_builddir)/zip-file/panel-osd.shell-extension.zip" .; \

@ -2,6 +2,7 @@ AC_PREREQ(2.63)
dnl be carefull, the version needs to be in sync with your gnome shell version
AC_INIT([gnome-shell-extension-panel-osd],[1.1],[https://github.com/jenslody/gnome-shell-extension-panel-osd/issues])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([config])
AM_INIT_AUTOMAKE([1.10 dist-xz foreign])
@ -10,6 +11,11 @@ m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
AC_PROG_SED
GETTEXT_PACKAGE=gnome-shell-extension-panel-osd
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
[The prefix for our gettext translation domains.])
IT_PROG_INTLTOOL(0.26)
PKG_PROG_PKG_CONFIG([0.22])
GLIB_GSETTINGS
@ -38,6 +44,7 @@ extensiontopdir=${datadir}/gnome-shell/extensions/panel-osd-extension@jenslody.d
dnl This is beyond ugly. Suggestions accepted.
if test "x${use_local_install}" == "xyes"; then
AC_SUBST(gsettingsschemadir, [${extensiontopdir}/schemas])
AC_SUBST(LOCALEDIR, [${extensiontopdir}/locale])
else
AC_SUBST(LOCALEDIR, [${datadir}/locale])
@ -47,10 +54,16 @@ dnl Please keep this sorted alphabetically.
AC_CONFIG_FILES([
Makefile
data/Makefile
po/Makefile.in
src/Makefile
])
AC_OUTPUT
dnl 'Fugly hack' doesn't get close to describe this. I don't know how else
dnl to change the directory for translations.
if test "x${use_local_install}" == "xyes"; then
${SED} -i -e "s%itlocaledir = .*%itlocaledir = ${extensiontopdir}/locale%g" po/Makefile
fi
if test "x$use_local_install" == "xyes"; then
echo
echo "The extension will be installed locally in the userdatadir."

@ -7,7 +7,7 @@ uuid = panel-osd@berend.de.schouwer.gmail.com
extensiondir = $(topextensiondir)/$(uuid)
dist_extension_DATA = stylesheet.css
dist_extension_DATA = stylesheet.css panel-osd-settings.ui
nodist_extension_DATA = metadata.json $(EXTRA_EXTENSION)
@ -19,3 +19,12 @@ metadata.json: metadata.json.in $(top_builddir)/config.status
-e "s|[@]url@|$(extensionurl)|" $< > $@
CLEANFILES = metadata.json
gschemas_in = org.gnome.shell.extensions.panel-osd.gschema.xml.in
@INTLTOOL_XML_NOMERGE_RULE@
gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml) @GSETTINGS_RULES@
EXTRA_DIST += $(gschemas_in)
CLEANFILES += $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS)

@ -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>

@ -31,10 +31,19 @@
<Unit filename="data/PanelOSD.png" />
<Unit filename="data/Screenshot.jpg" />
<Unit filename="data/metadata.json.in" />
<Unit filename="data/org.gnome.shell.extensions.panel-osd.gschema.xml.in" />
<Unit filename="data/panel-osd-settings.ui" />
<Unit filename="data/stylesheet.css" />
<Unit filename="gnome-shell-extension-panel-osd.spec" />
<Unit filename="po/Makefile.in" />
<Unit filename="po/POTFILES.in" />
<Unit filename="po/de.po" />
<Unit filename="po/gnome-shell-extension-panel-osd.pot" />
<Unit filename="po/update.js" />
<Unit filename="src/Makefile.am" />
<Unit filename="src/convenience.js" />
<Unit filename="src/extension.js" />
<Unit filename="src/prefs.js" />
<Unit filename="update_revision.sh" />
<Extensions>
<envvars />

1
m4/.gitignore vendored

@ -0,0 +1 @@
intltool.m4

@ -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");
}

@ -5,6 +5,6 @@ uuid = panel-osd@berend.de.schouwer.gmail.com
extensiondir = $(topextensiondir)/$(uuid)
dist_extension_DATA = extension.js
dist_extension_DATA = extension.js convenience.js prefs.js
nodist_extension_DATA = $(EXTRA_EXTENSION)

@ -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
});
}

@ -4,7 +4,7 @@
* We're grabbing "private" methods (start with _), so expect this to break
* with different versions of Gnome Shell.
*
* It was tested with 3.8.3, with various themes.
* It was tested with 3.6 to 3.11.90 with various themes.
*
* Most of this code is a direct copy from gnome-shell/js/ui/messageTray.js,
* so (C)opyright Gnome-Team, I think :)
@ -18,6 +18,15 @@ const Main = imports.ui.main;
const Tweener = imports.ui.tweener;
const LayoutManager = Main.layoutManager;
const Lang = imports.lang;
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';
/*
* Save MessageTray's original methods. We're going to change these
@ -47,7 +56,7 @@ const Urgency = {
NORMAL: 1,
HIGH: 2,
CRITICAL: 3
}
};
const State = {
HIDDEN: 0,
SHOWING: 1,
@ -58,6 +67,18 @@ const State = {
function init() {
}
let Settings;
let loadConfig = function() {
Settings = Convenience.getSettings(PANEL_OSD_SETTINGS_SCHEMA);
};
let getX_position = function() {
if (!Settings)
loadConfig();
return Settings.get_double(PANEL_OSD_X_POS_KEY);
}
/*
* Copied from MessageTray._showNotification()
@ -287,11 +308,13 @@ let extensionUpdateShowingNotification = function() {
// use panel's y and height property to determine the bottom of the top-panel.
// needed because the "hide top bar" and "hide top panel" use different approaches to hide the
// top bar.
// "hide top panel" keeps the haeight and just moves the panel out of the visible area, so using
// "hide top panel" keeps the height and just moves the panel out of the visible area, so using
// the panels-height is not enough.
let yPos = panel.y + panel.height - global.screen_height;
if (yPos < (-global.screen_height))
yPos = -global.screen_height;
//
this._notificationWidget.x = (global.screen_width - this._notificationWidget.width) * (getX_position() - 50) / 50 ;
// JRL changes end
// We tween all notifications to full opacity. This ensures that both new notifications and
// notifications that might have been in the process of hiding get full opacity.
@ -369,6 +392,8 @@ function disable() {
// remove our style, in case we just show a notification, otherwise the radius is drawn incorrect
if(Main.messageTray._notification)
Main.messageTray._notification._table.remove_style_class_name('jrlnotification');
// reset x-position
notificationWidget.x = originalNotificationWidgetX;
Main.messageTray._showNotification = originalShowNotification;
Main.messageTray._hideNotification = originalHideNotification;
Main.messageTray._updateShowingNotification = originalUpdateShowingNotification;

@ -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…
Cancel
Save