Skip to content

Commit

Permalink
Color chooser
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLauinger77 committed Nov 15, 2022
1 parent f9dad61 commit e2397dd
Show file tree
Hide file tree
Showing 19 changed files with 318 additions and 59 deletions.
Binary file modified menu_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 20 additions & 1 deletion [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const ICON_SIZE = 22;

const _rgbToHex = (r, g, b) =>
"#" + [r, g, b].map((x) => x.toString(16).padStart(2, "0")).join("");

let _indicator;
let originalUpdateCount;
let originalStyle;
Expand Down Expand Up @@ -478,10 +481,26 @@ function _checkNotifyMBlog(source) {
return result;
}

function isSupported() {
let current_version = Config.PACKAGE_VERSION.split(".");
return current_version[0] >= 42 ? true : false;
}

function _changeStatusIcon(newMessage) {
// Change Status Icon in Panel
if (newMessage && !iconChanged) {
let color = settings.get_string("color");
let color;
if (isSupported) {
let strcolor = settings.get_string("color-rgba");
let arrColor = strcolor.replace("rgb(", "").replace(")", "").split(",");
color = _rgbToHex(
parseInt(arrColor[0]),
parseInt(arrColor[1]),
parseInt(arrColor[2])
);
} else {
color = settings.get_string("color");
}
iconBox.set_style("color: " + color + ";");
iconChanged = true;
} else if (!newMessage && iconChanged) {
Expand Down
2 changes: 1 addition & 1 deletion [email protected]/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"gettext-domain": "messagingmenu",
"description": "A Messaging Menu for the Gnome Shell. All Email and Chat Applications in one Place.",
"url": "https://github.com/ChrisLauinger77/messagingmenu",
"version": 28,
"version": 29,
"settings-schema": "org.gnome.shell.extensions.messagingmenu"
}
52 changes: 31 additions & 21 deletions [email protected]/prefs.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const ExtensionUtils = imports.misc.extensionUtils;
const GObject = imports.gi.GObject;
const { Gtk } = imports.gi;
const { Gtk, Gdk, GObject, Gio } = imports.gi;
const Me = ExtensionUtils.getCurrentExtension();
const Gettext = imports.gettext.domain("messagingmenu");
const _ = Gettext.gettext;

//only here to be catched by translation
const strFix1 = _("Notification Color (RGB):");

let settings;

function createColorSettingWidget() {
Expand Down Expand Up @@ -138,27 +140,35 @@ function fillPreferencesWindow(window) {
window.add(page);

let email_setting_switch = builder.get_object("email_setting_switch");
email_setting_switch.set_active(settings.get_boolean("notify-email"));
email_setting_switch.connect("notify::active", function (button1) {
settings.set_boolean("notify-email", button1.active);
});
settings.bind(
"notify-email",
email_setting_switch,
"active",
Gio.SettingsBindFlags.DEFAULT
);
let chat_setting_switch = builder.get_object("chat_setting_switch");
chat_setting_switch.set_active(settings.get_boolean("notify-chat"));
chat_setting_switch.connect("notify::active", function (button2) {
settings.set_boolean("notify-chat", button2.active);
});
settings.bind(
"notify-chat",
chat_setting_switch,
"active",
Gio.SettingsBindFlags.DEFAULT
);
let mblogging_setting_switch = builder.get_object("mblogging_setting_switch");
mblogging_setting_switch.set_active(settings.get_boolean("notify-mblogging"));
mblogging_setting_switch.connect("notify::active", function (button3) {
settings.set_boolean("notify-mblogging", button3.active);
});
let color_setting_string = builder.get_object("color_setting_string");
color_setting_string.set_text(settings.get_string("color"));
color_setting_string.connect("notify::text", function (entry) {
// only save correct color hexcode
if (entry.text.length == 7 && entry.text.charAt(0) == "#") {
settings.set_string("color", entry.text);
}
settings.bind(
"notify-mblogging",
mblogging_setting_switch,
"active",
Gio.SettingsBindFlags.DEFAULT
);
let color_setting_button = builder.get_object("color_setting_button");
let mycolor = new Gdk.RGBA();
mycolor.parse(settings.get_string("color-rgba"));
color_setting_button.set_rgba(mycolor);
color_setting_button.connect("color-set", function (color_setting_button) {
settings.set_string(
"color-rgba",
color_setting_button.get_rgba().to_string()
);
});
}

Expand Down
6 changes: 3 additions & 3 deletions [email protected]/prefs.ui
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
</child>
<child>
<object class="AdwActionRow" id="messagingmenu_row4">
<property name="title" translatable="yes">Notification Color (Hex):</property>
<property name="activatable-widget">color_setting_string</property>
<property name="title" translatable="yes">Notification Color (RGB)</property>
<property name="activatable-widget">color_setting_button</property>
<child>
<object class="GtkEntry" id="color_setting_string">
<object class="GtkColorButton" id="color_setting_button">
<property name="valign">center</property>
</object>
</child>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<schemalist>
<schema id="org.gnome.shell.extensions.messagingmenu"
<schema id="org.gnome.shell.extensions.messagingmenu"
path="/org/gnome/shell/extensions/messagingmenu/">
<key name="notify-email" type="b">
<default>true</default>
Expand All @@ -23,8 +23,13 @@
</key>
<key name="color" type="s">
<default>'#ff0000'</default>
<summary>Notification Color</summary>
<description>The color used to paint the Icon</description>
<summary>Notification Color HEX</summary>
<description>The color used to paint the Icon(old version since GNOME 41)</description>
</key>
<key name="color-rgba" type="s">
<default>'rgba(255,0,0,1)'</default>
<summary>Notification Color RGBA</summary>
<description>The color used to paint the Icon(new version since GNOME 42)</description>
</key>
</schema>
</schemalist>
16 changes: 10 additions & 6 deletions po/af.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-11 14:44+0100\n"
"PO-Revision-Date: 2022-11-11 14:46+0100\n"
"POT-Creation-Date: 2022-11-14 22:57+0100\n"
"PO-Revision-Date: 2022-11-14 22:58+0100\n"
"Last-Translator: Christian Lauinger <[email protected]>\n"
"Language-Team: \n"
"Language: af\n"
Expand All @@ -30,19 +30,23 @@ msgstr "Kontakte"
msgid "Settings"
msgstr "Instellings"

#: [email protected]/prefs.js:18
#: [email protected]/prefs.js:8
msgid "Notification Color (RGB):"
msgstr "Kennisgewing Kleur (RGB):"

#: [email protected]/prefs.js:20
msgid "Notification Color (Hex):"
msgstr "Kennisgewing Kleur (Hex):"

#: [email protected]/prefs.js:51
#: [email protected]/prefs.js:53
msgid "Email Notification:"
msgstr "E-pos Kennisgewing:"

#: [email protected]/prefs.js:73
#: [email protected]/prefs.js:75
msgid "Chat Notification:"
msgstr "Chat Kennisgewing:"

#: [email protected]/prefs.js:95
#: [email protected]/prefs.js:97
msgid "Micro Blogging Notification:"
msgstr "Mikro Blog Kennisgewing:"

16 changes: 10 additions & 6 deletions po/cz.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Messaging Menu Version 4\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-11 14:49+0100\n"
"PO-Revision-Date: 2022-11-11 15:26+0100\n"
"POT-Creation-Date: 2022-11-14 22:57+0100\n"
"PO-Revision-Date: 2022-11-14 22:58+0100\n"
"Last-Translator: Christian Lauinger <[email protected]>\n"
"Language-Team: Czech\n"
"Language: cz\n"
Expand All @@ -30,19 +30,23 @@ msgstr "Kontakty"
msgid "Settings"
msgstr "Nastavení"

#: [email protected]/prefs.js:18
#: [email protected]/prefs.js:8
msgid "Notification Color (RGB):"
msgstr "Barva upozornění (RGB)"

#: [email protected]/prefs.js:20
msgid "Notification Color (Hex):"
msgstr "Barva upozornění (Hex)"

#: [email protected]/prefs.js:51
#: [email protected]/prefs.js:53
msgid "Email Notification:"
msgstr "Upozornění na email:"

#: [email protected]/prefs.js:73
#: [email protected]/prefs.js:75
msgid "Chat Notification:"
msgstr "Upozornění na zprávu v chatu:"

#: [email protected]/prefs.js:95
#: [email protected]/prefs.js:97
msgid "Micro Blogging Notification:"
msgstr "Upozornění na příspěvek na micro-blogu:"

16 changes: 10 additions & 6 deletions po/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-11 14:44+0100\n"
"PO-Revision-Date: 2022-11-11 14:45+0100\n"
"POT-Creation-Date: 2022-11-14 22:57+0100\n"
"PO-Revision-Date: 2022-11-14 22:58+0100\n"
"Last-Translator: Christian Lauinger <[email protected]>\n"
"Language-Team: \n"
"Language: de\n"
Expand All @@ -30,19 +30,23 @@ msgstr "Kontakte"
msgid "Settings"
msgstr "Einstellungen"

#: [email protected]/prefs.js:18
#: [email protected]/prefs.js:8
msgid "Notification Color (RGB):"
msgstr "Benachrichtigungsfarbe (RGB):"

#: [email protected]/prefs.js:20
msgid "Notification Color (Hex):"
msgstr "Benachrichtigungsfarbe (Hex):"

#: [email protected]/prefs.js:51
#: [email protected]/prefs.js:53
msgid "Email Notification:"
msgstr "Epost-Benachrichtigung:"

#: [email protected]/prefs.js:73
#: [email protected]/prefs.js:75
msgid "Chat Notification:"
msgstr "Chat-Benachrichtigung:"

#: [email protected]/prefs.js:95
#: [email protected]/prefs.js:97
msgid "Micro Blogging Notification:"
msgstr "Mikroblog-Benachrichtigung:"

16 changes: 10 additions & 6 deletions po/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Messaging Menu Version 4\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-11 14:49+0100\n"
"PO-Revision-Date: 2022-11-11 15:26+0100\n"
"POT-Creation-Date: 2022-11-14 22:57+0100\n"
"PO-Revision-Date: 2022-11-14 22:58+0100\n"
"Last-Translator: Christian Lauinger <[email protected]>\n"
"Language-Team: Spanish\n"
"Language: es\n"
Expand All @@ -30,19 +30,23 @@ msgstr "Contactos"
msgid "Settings"
msgstr "Ajustes"

#: [email protected]/prefs.js:18
#: [email protected]/prefs.js:8
msgid "Notification Color (RGB):"
msgstr "Color de la Notificación (RGB):"

#: [email protected]/prefs.js:20
msgid "Notification Color (Hex):"
msgstr "Color de la Notificación (Hex):"

#: [email protected]/prefs.js:51
#: [email protected]/prefs.js:53
msgid "Email Notification:"
msgstr "Correo de Notificación:"

#: [email protected]/prefs.js:73
#: [email protected]/prefs.js:75
msgid "Chat Notification:"
msgstr "Notificación Chat:"

#: [email protected]/prefs.js:95
#: [email protected]/prefs.js:97
msgid "Micro Blogging Notification:"
msgstr "Notificación Microblog:"

16 changes: 10 additions & 6 deletions po/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Messaging Menu Version 4\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-11-11 14:49+0100\n"
"PO-Revision-Date: 2022-11-11 15:30+0100\n"
"POT-Creation-Date: 2022-11-14 22:57+0100\n"
"PO-Revision-Date: 2022-11-14 22:59+0100\n"
"Last-Translator: Christian Lauinger <[email protected]>\n"
"Language-Team: French\n"
"Language: fr\n"
Expand All @@ -30,19 +30,23 @@ msgstr "Contacts"
msgid "Settings"
msgstr "Reglages"

#: [email protected]/prefs.js:18
#: [email protected]/prefs.js:8
msgid "Notification Color (RGB):"
msgstr "Couleur de la Notification (RGB):"

#: [email protected]/prefs.js:20
msgid "Notification Color (Hex):"
msgstr "Couleur de la Notification (Hex):"

#: [email protected]/prefs.js:51
#: [email protected]/prefs.js:53
msgid "Email Notification:"
msgstr "Email de Notification:"

#: [email protected]/prefs.js:73
#: [email protected]/prefs.js:75
msgid "Chat Notification:"
msgstr "Notification de Chat:"

#: [email protected]/prefs.js:95
#: [email protected]/prefs.js:97
msgid "Micro Blogging Notification:"
msgstr "Notification Microblog:"

25 changes: 25 additions & 0 deletions po/hu.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ msgid ""
msgstr ""
"Project-Id-Version: Messaging Menu Version 4\n"
"Report-Msgid-Bugs-To: \n"
<<<<<<< HEAD
"POT-Creation-Date: 2022-11-11 14:49+0100\n"
"PO-Revision-Date: 2022-11-11 15:27+0100\n"
=======
"POT-Creation-Date: 2022-11-14 22:57+0100\n"
"PO-Revision-Date: 2022-11-14 22:59+0100\n"
>>>>>>> e868b24... Color chooser
"Last-Translator: Christian Lauinger <[email protected]>\n"
"Language-Team: Hungarian\n"
"Language: hu\n"
Expand All @@ -30,6 +35,7 @@ msgstr "Kapcsolatok"
msgid "Settings"
msgstr "Beállítások"

<<<<<<< HEAD
#: [email protected]/prefs.js:18
msgid "Notification Color (Hex):"
msgstr "Értesítési szín (Hex):"
Expand All @@ -43,6 +49,25 @@ msgid "Chat Notification:"
msgstr "Chat értesítés:"

#: [email protected]/prefs.js:95
=======
#: [email protected]/prefs.js:8
msgid "Notification Color (RGB):"
msgstr "Értesítési szín (RGB):"

#: [email protected]/prefs.js:20
msgid "Notification Color (Hex):"
msgstr "Értesítési szín (Hex):"

#: [email protected]/prefs.js:53
msgid "Email Notification:"
msgstr "Email értesítés:"

#: [email protected]/prefs.js:75
msgid "Chat Notification:"
msgstr "Chat értesítés:"

#: [email protected]/prefs.js:97
>>>>>>> e868b24... Color chooser
msgid "Micro Blogging Notification:"
msgstr "Mikro-blogging értesítés:"

Loading

0 comments on commit e2397dd

Please sign in to comment.