First release

This commit is contained in:
Léo Andrès 2016-12-24 01:56:58 +01:00 committed by zapashcanon
parent 6f3f1b9882
commit 6800d2fff7
Signed by: zapashcanon
GPG Key ID: 8981C3C62D1D28F1
11 changed files with 577 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
_build/
*.compiled
*.mo
powerful-topbar@leo.ndrs.fr/locale/
powerful-topbar@leo.ndrs.fr/locale/*

9
LICENSE.md Normal file
View File

@ -0,0 +1,9 @@
The ISC License (ISC)
=====================
Copyright © 2016-2018, Léo Andrès
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

64
Makefile Normal file
View File

@ -0,0 +1,64 @@
.PHONY: clean mrproper
EXTENSION_NAME := powerful-topbar
UUID := $(EXTENSION_NAME)@leo.ndrs.fr
AUTHOR_MAIL := leo@ndrs.fr
VERSION := 0.0.1
BUILD_DIR := _build
SRC_DIR := $(UUID)
SCHEMAS_DIR := $(SRC_DIR)/schemas
PO_DIR := $(SRC_DIR)/po
LOCALE_DIR := $(SRC_DIR)/locale
JS_FILES := $(wildcard $(SRC_DIR)/*.js)
FILES := $(SRC_DIR)/* README.md LICENSE.md
COMPILED_SCHEMAS := $(SCHEMAS_DIR)/gschemas.compiled
PO_FILES := $(wildcard $(PO_DIR)/*.po)
MO_FILES := $(PO_FILES:$(PO_DIR)/%.po=$(LOCALE_DIR)/%/LC_MESSAGES/$(UUID).mo)
MO_DIR := $(PO_FILES:$(PO_DIR)/%.po=$(LOCALE_DIR)/%/LC_MESSAGES)
POT_FILE := $(PO_DIR)/$(UUID).pot
TOLOCALIZE := $(JS_FILES:$(SRC_DIR)/%.js=%.js)
ifeq ($(strip $(DESTDIR)),)
INSTALLBASE := $(HOME)/.local
else
INSTALLBASE := $(DESTDIR)/usr
endif
INSTALLBASE := $(INSTALLBASE)/share/gnome-shell/extensions
INSTALL_DIR := $(INSTALLBASE)/$(UUID)
default: build clean
$(BUILD_DIR):
mkdir -p $@
$(COMPILED_SCHEMAS): $(SCHEMAS_DIR)/org.gnome.shell.extensions.$(EXTENSION_NAME).gschema.xml
glib-compile-schemas $(SCHEMAS_DIR)
$(LOCALE_DIR)/%/LC_MESSAGES:
mkdir -p $@
$(LOCALE_DIR)/%/LC_MESSAGES/$(UUID).mo: $(PO_DIR)/%.po $(MO_DIR)
msgfmt -c $< -o $@
$(POT_FILE): $(PO_DIR)
cd $(SRC_DIR) && xgettext --from-code=UTF-8 --package-name "gnome-shell-extension-$(EXTENSION_NAME)" --package-version=$(VERSION) --msgid-bugs-address=$(AUTHOR_MAIL) -k_ -kN_ -o po/$(UUD).pot $(TOLOCALIZE) && cd -
build: $(BUILD_DIR) $(COMPILED_SCHEMAS) $(MO_FILES)
cp -r $(FILES) $<
install: build
rm -rf $(INSTALL_DIR)
mkdir -p $(INSTALL_DIR)
cp -r $(BUILD_DIR)/* $(INSTALL_DIR)
clean:
rm -f $(COMPILED_SCHEMAS)
rm -rf $(LOCALE_DIR)
mrproper: clean
rm -rf $(BUILD_DIR)

32
README.md Normal file
View File

@ -0,0 +1,32 @@
# Powerful Top Bar
A GNOME Shell extension to get a powerful top bar.
## Preview
![screenshot]
## Install
You'll need the `glib-compile-schemas`, `msgfmt` and `make` commands on your system, available through `libglib`, `gettext` and `make`.
* download source or clone the repository
* from the `powerful-topbar` repository:
* for a user only installation: `make install`
* for a system-wide installation: `sudo make install DESTDIR=/`
* reload the shell using X:
* press <kbd>Alt</kbd>+<kbd>F2</kbd>
* write <kbd>r</kbd>
* press <kbd>Enter</kbd>
* reload the extension on Wayland:
* `gnome-shell-extension-tool -r powerful-topbar@leo.ndrs.fr`
* enable via GNOME Tweak Tool
## License
Copyright © 2016-2018 Léo Andrès.
Powerful topbar is published under the `ISC` license, see [LICENSE] for details.
[LICENSE]: ./LICENSE.md
[screenshot]: https://git.zapashcanon.fr/zapashcanon/powerful-topbar/raw/branch/master/screenshot01.png

View File

@ -0,0 +1,92 @@
/* -*- 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 });
}

View File

@ -0,0 +1,189 @@
const Test = imports.ui.main;
const Topbar = imports.ui.main.panel;
const Extension = imports.misc.extensionUtils.getCurrentExtension();
const Convenience = Extension.imports.convenience;
const Settings = Convenience.getSettings();
// Settings
const SETTING_SHOW_ACTIVITIES = 'show-activities';
const SETTING_SHOW_APPLICATION_TITLE = 'show-application-title';
const SETTING_SHOW_APPLICATION_ICON = 'show-application-icon';
const SETTING_SHOW_APPLICATION_ARROW = 'show-application-arrow';
const SETTING_SHOW_A11Y = 'show-a11y';
const SETTING_SHOW_KEYBOARD = 'show-keyboard';
const SETTING_SHOW_VOLUME_INDICATOR = 'show-volume-indicator';
const SETTING_SHOW_NETWORK_INDICATOR = 'show-network-indicator';
const SETTING_SHOW_RFKILL_INDICATOR = 'show-rfkill-indicator';
const SETTING_SHOW_BLUETOOTH_INDICATOR = 'show-bluetooth-indicator';
const SETTING_SHOW_POWER_INDICATOR = 'show-power-indicator';
const SETTING_SHOW_POWER_PERCENTAGE_LABEL = 'show-power-percentage-label'
const SETTING_REMOVE_ROUNDED_CORNERS = 'remove-rounded-corners';
function init() {
Convenience.initTranslations("powerful-topbar@leo.ndrs.fr");
Settings.connect('changed', function() { auto(); });
}
function enable() {
auto();
}
function disable() {
Settings.disconnect('changed');
show_status_area('activities');
show_status_area_component('appMenu', '_iconBox');
show_status_area_component('appMenu', '_label');
show_status_area_component('appMenu', '_arrow');
show_status_area('a11y');
show_status_area('keyboard');
show_status_area_component_indicator('aggregateMenu', '_volume', 'indicators');
show_status_area_component_indicator('aggregateMenu', '_network', 'indicators');
show_status_area_component_indicator('aggregateMenu', '_rfkill', '_indicator');
show_status_area_component_indicator('aggregateMenu', '_bluetooth', '_indicator');
show_status_area_component_indicator('aggregateMenu', '_power', '_indicator');
show_status_area_component_indicator('aggregateMenu', '_power', '_percentageLabel');
restore_rounded_corners();
}
function auto() {
auto_status_area('activities', SETTING_SHOW_ACTIVITIES);
auto_status_area('a11y', SETTING_SHOW_A11Y);
auto_status_area('keyboard', SETTING_SHOW_KEYBOARD);
auto_status_area_component('appMenu', '_iconBox', SETTING_SHOW_APPLICATION_ICON);
auto_status_area_component('appMenu', '_label', SETTING_SHOW_APPLICATION_TITLE);
auto_status_area_component('appMenu', '_arrow', SETTING_SHOW_APPLICATION_ARROW);
auto_status_area_component_indicator('aggregateMenu', '_volume', 'indicators', SETTING_SHOW_VOLUME_INDICATOR);
auto_status_area_component_indicator('aggregateMenu', '_network', 'indicators', SETTING_SHOW_NETWORK_INDICATOR);
auto_status_area_component_indicator('aggregateMenu', '_rfkill', '_indicator', SETTING_SHOW_RFKILL_INDICATOR);
auto_status_area_component_indicator('aggregateMenu', '_bluetooth', '_indicator', SETTING_SHOW_BLUETOOTH_INDICATOR);
auto_status_area_component_indicator('aggregateMenu', '_power', '_indicator', SETTING_SHOW_POWER_INDICATOR);
auto_status_area_component_indicator('aggregateMenu', '_power', '_percentageLabel', SETTING_SHOW_POWER_PERCENTAGE_LABEL);
auto_rounded_corners();
}
function auto_rounded_corners() {
if (Settings.get_boolean(SETTING_REMOVE_ROUNDED_CORNERS)) {
remove_rounded_corners();
} else {
restore_rounded_corners();
}
}
function auto_status_area(areaName, settingName) {
if (Settings.get_boolean(settingName)) {
show_status_area(areaName);
} else {
hide_status_area(areaName);
}
}
function auto_status_area_component(areaName, componentName, settingName) {
if (Settings.get_boolean(settingName)) {
show_status_area_component(areaName, componentName);
} else {
hide_status_area_component(areaName, componentName);
}
}
function auto_status_area_component_indicator(areaName, componentName, indicatorName, settingName) {
if (Settings.get_boolean(settingName)) {
show_status_area_component_indicator(areaName, componentName, indicatorName);
} else {
hide_status_area_component_indicator(areaName, componentName, indicatorName);
}
}
function hide_status_area(areaName) {
let area = Topbar.statusArea[areaName];
if (area != null) {
area.container.hide();
}
}
function show_status_area(areaName) {
let area = Topbar.statusArea[areaName];
if (area != null) {
area.container.show();
}
}
function hide_status_area_component(areaName, componentName) {
let area = Topbar.statusArea[areaName];
let component = area[componentName];
if (component != null) {
component.hide();
}
}
function show_status_area_component(areaName, componentName) {
let area = Topbar.statusArea[areaName];
let component = area[componentName];
if (component != null) {
component.show();
}
}
function hide_status_area_component_indicator(areaName, componentName, indicatorName) {
let area = Topbar.statusArea[areaName];
let component = area[componentName];
let indicator = component[indicatorName];
if (indicator != null) {
indicator.hide();
}
}
function show_status_area_component_indicator(areaName, componentName, indicatorName) {
let area = Topbar.statusArea[areaName];
let component = area[componentName];
let indicator = component[indicatorName];
if (indicator != null) {
indicator.show();
}
}
function remove_rounded_corners() {
let leftCorner = Topbar._leftCorner.actor;
let rightCorner = Topbar._rightCorner.actor;
if (leftCorner != null && rightCorner != null) {
leftCorner.add_style_class_name('straight-panel-corner');
rightCorner.add_style_class_name('straight-panel-corner');
}
}
function restore_rounded_corners() {
let leftCorner = Topbar._leftCorner.actor;
let rightCorner = Topbar._rightCorner.actor;
if (leftCorner != null && rightCorner != null) {
leftCorner.remove_style_class_name('straight-panel-corner');
rightCorner.remove_style_class_name('straight-panel-corner');
}
}

View File

@ -0,0 +1,11 @@
{
"description": "Provide a powerful top bar",
"gettext-domain": "powerful-topbar",
"name": "Powerful Top Bar",
"original-author": "leo@ndrs.fr",
"shell-version": ["3.18", "3.20", "3.22"],
"settings-schema": "org.gnome.shell.extensions.powerful-topbar",
"url": "https://git.zapashcanon.fr/zapashcanon/powerful-topbar",
"uuid": "powerful-topbar@leo.ndrs.fr",
"version": -1
}

View File

@ -0,0 +1,100 @@
const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Extension = imports.misc.extensionUtils.getCurrentExtension();
const Convenience = Extension.imports.convenience;
const Gettext = imports.gettext.domain("powerful-topbar@leo.ndrs.fr");
const _ = Gettext.gettext;
const Lang = imports.lang;
const SETTING_SHOW_ACTIVITIES = 'show-activities';
const SETTING_SHOW_APPLICATION_TITLE = 'show-application-title';
const SETTING_SHOW_APPLICATION_ICON = 'show-application-icon';
const SETTING_SHOW_APPLICATION_ARROW = 'show-application-arrow';
const SETTING_SHOW_A11Y = 'show-a11y';
const SETTING_SHOW_KEYBOARD = 'show-keyboard';
const SETTING_SHOW_VOLUME_INDICATOR = 'show-volume-indicator';
const SETTING_SHOW_NETWORK_INDICATOR = 'show-network-indicator';
const SETTING_SHOW_RFKILL_INDICATOR = 'show-rfkill-indicator';
const SETTING_SHOW_BLUETOOTH_INDICATOR = 'show-bluetooth-indicator';
const SETTING_SHOW_POWER_INDICATOR = 'show-power-indicator';
const SETTING_SHOW_POWER_PERCENTAGE_LABEL = 'show-power-percentage-label'
const SETTING_REMOVE_ROUNDED_CORNERS = 'remove-rounded-corners';
const PowerfulTopbarPrefsWidget = new GObject.Class({
Name: 'PowerfulTopbarPrefsWidget',
GTypeName: 'PowerfulTopbarPrefsWidget',
Extends: Gtk.Grid,
_init: function(params) {
this.parent(params);
this.orientation = Gtk.Orientation.VERTICAL;
this.margin = 12;
this._settings = Convenience.getSettings();
this._widgets = {};
this._widgets.box = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
margin: 20,
margin_top: 10,
expand: true,
spacing: 10
});
this._create_switch(SETTING_SHOW_ACTIVITIES);
this._create_switch(SETTING_SHOW_APPLICATION_TITLE);
this._create_switch(SETTING_SHOW_APPLICATION_ICON);
this._create_switch(SETTING_SHOW_APPLICATION_ARROW);
this._create_switch(SETTING_SHOW_A11Y);
this._create_switch(SETTING_SHOW_KEYBOARD);
this._create_switch(SETTING_SHOW_VOLUME_INDICATOR);
this._create_switch(SETTING_SHOW_NETWORK_INDICATOR);
this._create_switch(SETTING_SHOW_RFKILL_INDICATOR);
this._create_switch(SETTING_SHOW_BLUETOOTH_INDICATOR);
this._create_switch(SETTING_SHOW_POWER_INDICATOR);
this._create_switch(SETTING_SHOW_POWER_PERCENTAGE_LABEL);
this._create_switch(SETTING_REMOVE_ROUNDED_CORNERS);
this.add(this._widgets.box);
},
_create_switch: function(settingName) {
let switchButton = new Gtk.Switch({
active: this._settings.get_boolean(settingName)
});
let hbox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL
});
let label = new Gtk.Label({
label: _(this._settings.settings_schema.get_key(settingName).get_description()),
xalign: 0
});
hbox.pack_start(label, true, true, 0);
hbox.add(switchButton);
this._widgets.box.add(hbox);
switchButton.connect('notify::active', Lang.bind(this, function(button) {
this._settings.set_boolean(settingName, button.get_active());
}));
}
});
function init() {
Convenience.initTranslations("powerful-topbar@leo.ndrs.fr");
}
function buildPrefsWidget() {
let widget = new PowerfulTopbarPrefsWidget();
widget.show_all();
return widget;
}

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="powerful-topbar@leo.ndrs.fr">
<schema path="/org/gnome/shell/extensions/powerful-topbar/" id="org.gnome.shell.extensions.powerful-topbar">
<key name="show-application-icon" type="b">
<default>true</default>
<summary>Show application's icon</summary>
<description>Show application's icon</description>
</key>
<key name="show-application-title" type="b">
<default>false</default>
<summary>Show application's title</summary>
<description>Show application's title</description>
</key>
<key name="show-application-arrow" type="b">
<default>true</default>
<summary>Show application's arrow</summary>
<description>Show application's arrow</description>
</key>
<key name="show-activities" type="b">
<default>false</default>
<summary>Show activities</summary>
<description>Show activities</description>
</key>
<key name="show-a11y" type="b">
<default>false</default>
<summary>Show a11y</summary>
<description>Show a11y</description>
</key>
<key name="show-keyboard" type="b">
<default>false</default>
<summary>Show keyboard</summary>
<description>Show keyboard</description>
</key>
<key name="show-volume-indicator" type="b">
<default>false</default>
<summary>Show volume's indicator</summary>
<description>Show volume's indicator</description>
</key>
<key name="show-network-indicator" type="b">
<default>false</default>
<summary>Show network's indicator</summary>
<description>Show network's indicator</description>
</key>
<key name="show-rfkill-indicator" type="b">
<default>false</default>
<summary>Show rfkill's indicator</summary>
<description>Show rfkill's indicator</description>
</key>
<key name="show-bluetooth-indicator" type="b">
<default>false</default>
<summary>Show bluetooth's indicator</summary>
<description>Show bluetooth's indicator</description>
</key>
<key name="show-power-indicator" type="b">
<default>false</default>
<summary>Show power's indicator</summary>
<description>Show power's indicator</description>
</key>
<key name="show-power-percentage-label" type="b">
<default>false</default>
<summary>Show power's percentage</summary>
<description>Show power's percentage</description>
</key>
<key name="remove-rounded-corners" type="b">
<default>true</default>
<summary>Remove rounded corners</summary>
<description>Remove rounded corners</description>
</key>
</schema>
</schemalist>

View File

@ -0,0 +1,3 @@
.straight-panel-corner.panel-corner {
-panel-corner-radius: 0;
}

BIN
screenshot01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB