first commit
This commit is contained in:
commit
d1c2eb361c
8 changed files with 243 additions and 0 deletions
1
README.md
Normal file
1
README.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# Activate Gnome
|
93
convenience.js
Normal file
93
convenience.js
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
/* -*- mode: js; js-basic-offset: 4; indent-tabs-mode: nil -*- */
|
||||||
|
/*
|
||||||
|
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 });
|
||||||
|
}
|
||||||
|
|
53
extension.js
Normal file
53
extension.js
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
// -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*-
|
||||||
|
// Sample extension code, makes clicking on the panel show a message
|
||||||
|
const St = imports.gi.St;
|
||||||
|
const Mainloop = imports.mainloop;
|
||||||
|
|
||||||
|
const Gettext = imports.gettext.domain('activate_gnome');
|
||||||
|
const _ = Gettext.gettext;
|
||||||
|
|
||||||
|
const Main = imports.ui.main;
|
||||||
|
|
||||||
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
|
const Me = ExtensionUtils.getCurrentExtension();
|
||||||
|
const Convenience = Me.imports.convenience;
|
||||||
|
|
||||||
|
|
||||||
|
function _show() {
|
||||||
|
let settings = Convenience.getSettings();
|
||||||
|
let text1 = settings.get_string('text-l1') || _("Activate Gnome");
|
||||||
|
let text2 = settings.get_string('text-l2') || _("Go to Settings to activate Gnome.");
|
||||||
|
label_1 = new St.Label({ style_class: 'label-1', text: text1 });
|
||||||
|
label_2 = new St.Label({ style_class: 'label-2', text: text2 });
|
||||||
|
let monitor = Main.layoutManager.primaryMonitor;
|
||||||
|
var h = Math.floor(monitor.height / 20 * 19 - label_2.height);
|
||||||
|
var w = Math.floor (monitor.width / 15 * 14 - label_2.width);
|
||||||
|
global.stage.add_actor(label_2);
|
||||||
|
label_2.set_position(w, h);
|
||||||
|
global.stage.add_actor(label_1);
|
||||||
|
label_1.set_position(w, h - label_1.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Put your extension initialization code here
|
||||||
|
function init(metadata) {
|
||||||
|
log ('Example extension initalized');
|
||||||
|
Convenience.initTranslations();
|
||||||
|
}
|
||||||
|
|
||||||
|
function refresh() {
|
||||||
|
// Don't know how to get rid of this
|
||||||
|
disable();
|
||||||
|
_show();
|
||||||
|
}
|
||||||
|
|
||||||
|
function enable() {
|
||||||
|
log ('Example extension enabled');
|
||||||
|
_show();
|
||||||
|
Mainloop.timeout_add(3000, () => { refresh(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
function disable() {
|
||||||
|
log ('Example extension disabled');
|
||||||
|
label_1.destroy();
|
||||||
|
label_2.destroy();
|
||||||
|
}
|
10
metadata.json
Normal file
10
metadata.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"extension-id": "activate_gnome",
|
||||||
|
"uuid": "activate_gnome@jerryxiao",
|
||||||
|
"settings-schema": "org.gnome.shell.extensions.activate_gnome",
|
||||||
|
"gettext-domain": "activate_gnome",
|
||||||
|
"name": "Gnome is not activated",
|
||||||
|
"description": "Shows Activate Gnome watermark on your screen.",
|
||||||
|
"shell-version": [ "3.30" ],
|
||||||
|
"url": "https://github.com/Jerry981028/activate_gnome"
|
||||||
|
}
|
59
prefs.js
Normal file
59
prefs.js
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
// -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*-
|
||||||
|
|
||||||
|
const GLib = imports.gi.GLib;
|
||||||
|
const GObject = imports.gi.GObject;
|
||||||
|
const Gio = imports.gi.Gio;
|
||||||
|
const Gtk = imports.gi.Gtk;
|
||||||
|
|
||||||
|
const Gettext = imports.gettext.domain('activate_gnome');
|
||||||
|
const _ = Gettext.gettext;
|
||||||
|
|
||||||
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
|
const Me = ExtensionUtils.getCurrentExtension();
|
||||||
|
const Convenience = Me.imports.convenience;
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
Convenience.initTranslations();
|
||||||
|
}
|
||||||
|
|
||||||
|
const ExamplePrefsWidget = GObject.registerClass(
|
||||||
|
class ExamplePrefsWidget extends Gtk.Grid {
|
||||||
|
_init(params) {
|
||||||
|
super._init(params);
|
||||||
|
this.margin = 12;
|
||||||
|
this.row_spacing = this.column_spacing = 6;
|
||||||
|
this.set_orientation(Gtk.Orientation.VERTICAL);
|
||||||
|
|
||||||
|
this.add(new Gtk.Label({ label: '<b>' + _("Line 1") + '</b>',
|
||||||
|
use_markup: true,
|
||||||
|
halign: Gtk.Align.START }));
|
||||||
|
|
||||||
|
let entryl1 = new Gtk.Entry({ hexpand: true,
|
||||||
|
margin_bottom: 12 });
|
||||||
|
this.add(entryl1);
|
||||||
|
|
||||||
|
this.add(new Gtk.Label({ label: '<b>' + _("Line 2") + '</b>',
|
||||||
|
use_markup: true,
|
||||||
|
halign: Gtk.Align.START }));
|
||||||
|
|
||||||
|
let entryl2 = new Gtk.Entry({ hexpand: true,
|
||||||
|
margin_bottom: 12 });
|
||||||
|
this.add(entryl2);
|
||||||
|
|
||||||
|
this._settings = Convenience.getSettings();
|
||||||
|
this._settings.bind('text-l1', entryl1, 'text', Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
this._settings.bind('text-l2', entryl2, 'text', Gio.SettingsBindFlags.DEFAULT);
|
||||||
|
|
||||||
|
let primaryText = _("You can customize the words on your screen.");
|
||||||
|
|
||||||
|
this.add(new Gtk.Label({ label: primaryText,
|
||||||
|
wrap: true, xalign: 0 }));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function buildPrefsWidget() {
|
||||||
|
let widget = new ExamplePrefsWidget();
|
||||||
|
widget.show_all();
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
BIN
schemas/gschemas.compiled
Normal file
BIN
schemas/gschemas.compiled
Normal file
Binary file not shown.
12
schemas/org.gnome.shell.extensions.topicons.gschema.xml
Normal file
12
schemas/org.gnome.shell.extensions.topicons.gschema.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<schemalist gettext-domain="activate_gnome">
|
||||||
|
<schema id="org.gnome.shell.extensions.activate_gnome" path="/org/gnome/shell/extensions/activate_gnome/">
|
||||||
|
<key name="text-l1" type="s">
|
||||||
|
<default>'Activate Gnome'</default>
|
||||||
|
<summary>Text to display on line No.1</summary>
|
||||||
|
</key>
|
||||||
|
<key name="text-l2" type="s">
|
||||||
|
<default>'Go to Settings to activate Gnome.'</default>
|
||||||
|
<summary>Text to display on line No.2</summary>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
</schemalist>
|
15
stylesheet.css
Normal file
15
stylesheet.css
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/* Example stylesheet */
|
||||||
|
.label-1 {
|
||||||
|
font-size: 36px;
|
||||||
|
font-weight: normal;
|
||||||
|
color: rgba(255, 255, 255, 0.3);
|
||||||
|
background-color: rgba(10, 10, 10, 0);
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
.label-2 {
|
||||||
|
font-size: 26px;
|
||||||
|
font-weight: normal;
|
||||||
|
color: rgba(255, 255, 255, 0.3);
|
||||||
|
background-color: rgba(10, 10, 10, 0);
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
Loading…
Reference in a new issue