Bugfixes, translation
This commit is contained in:
@@ -17,7 +17,8 @@ const Gio = imports.gi.Gio;
|
||||
const MessageTray = imports.ui.messageTray;
|
||||
const St = imports.gi.St;
|
||||
const Main = imports.ui.main;
|
||||
|
||||
const Gettext = imports.gettext;
|
||||
const GLib = imports.gi.GLib;
|
||||
|
||||
|
||||
/******************** Constants ********************/
|
||||
@@ -44,6 +45,15 @@ function CinnamonDynamicWallpaperExtension(uuid) {
|
||||
}
|
||||
|
||||
|
||||
function _(str) {
|
||||
let customTranslation = Gettext.dgettext(UUID, str);
|
||||
if (customTranslation !== str) {
|
||||
return customTranslation;
|
||||
}
|
||||
return Gettext.gettext(str);
|
||||
}
|
||||
|
||||
|
||||
CinnamonDynamicWallpaperExtension.prototype = {
|
||||
|
||||
/******************** Lifecycle ********************/
|
||||
@@ -56,12 +66,14 @@ CinnamonDynamicWallpaperExtension.prototype = {
|
||||
_init: function(uuid) {
|
||||
this.settings = new Settings.ExtensionSettings(this, uuid);
|
||||
|
||||
Gettext.bindtextdomain(UUID, GLib.get_home_dir() + '/.local/share/locale');
|
||||
|
||||
// Check for the first startup
|
||||
if (this.settings.getValue("first_start")) {
|
||||
if (!this.settings.getValue("first_start")) {
|
||||
|
||||
// Welcome notification
|
||||
this.showNotification("Welcome to Cinnamon Dynamic Wallpaper",
|
||||
"Check the preferences to choose a dynamic wallpaper", true)
|
||||
this.showNotification(_("Welcome to Cinnamon Dynamic Wallpaper"),
|
||||
_("Check the preferences to choose a dynamic wallpaper"), true)
|
||||
|
||||
// Hide the notification on system restart
|
||||
this.settings.setValue("first_start", false)
|
||||
@@ -98,8 +110,8 @@ CinnamonDynamicWallpaperExtension.prototype = {
|
||||
try {
|
||||
Util.spawnCommandLine("/usr/bin/env python3 " + DIRECTORY.path + "/src/main.py loop")
|
||||
} catch(e) {
|
||||
this.showNotification("Error!",
|
||||
"Cinnamon Dynamic Wallpaper got an error while running the loop script. Please create an issue on GitHub.")
|
||||
this.showNotification(_("Error!"),
|
||||
_("Cinnamon Dynamic Wallpaper got an error while running the loop script. Please create an issue on GitHub."))
|
||||
}
|
||||
|
||||
// Refresh every 60 seconds
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import sys, datetime
|
||||
import sys
|
||||
from view.main_window import *
|
||||
from model.main_view_model import *
|
||||
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import os, time
|
||||
from PIL import Image
|
||||
# GTK
|
||||
from gi.repository import Gio, Gdk
|
||||
|
||||
# Packages
|
||||
import os, time, gi, locale
|
||||
from PIL import Image
|
||||
|
||||
# Local scripts
|
||||
from service.cinnamon_pref_handler import *
|
||||
from service.suntimes import *
|
||||
from service.time_bar_chart import *
|
||||
from service.location import *
|
||||
from enums.PeriodSourceEnum import *
|
||||
|
||||
|
||||
class Main_View_Model:
|
||||
""" The main ViewModel for the application
|
||||
"""
|
||||
@@ -38,6 +43,13 @@ class Main_View_Model:
|
||||
|
||||
self.background_settings = Gio.Settings.new("org.cinnamon.desktop.background")
|
||||
|
||||
|
||||
# Language support
|
||||
self.UUID = "cinnamon-dynamic-wallpaper@TobiZog"
|
||||
self.localeDir = os.path.expanduser("~") + "/.local/share/locale"
|
||||
locale.bindtextdomain(self.UUID, self.localeDir)
|
||||
|
||||
|
||||
# Other Variables
|
||||
self.display = Gdk.Display.get_default()
|
||||
self.screen_height = self.display.get_monitor(0).get_geometry().height
|
||||
|
||||
@@ -32,6 +32,7 @@ class Cinnamon_Pref_Handler:
|
||||
with open(self.pref_location, "r") as pref_file:
|
||||
self.pref_data = json.load(pref_file)
|
||||
|
||||
self.first_start = self.extract_json('first_start')
|
||||
self.picture_aspect = self.extract_json('picture_aspect')
|
||||
self.dynamic_background_color = self.extract_json('dynamic_background_color')
|
||||
self.image_source = self.extract_json('image_source')
|
||||
@@ -93,6 +94,7 @@ class Cinnamon_Pref_Handler:
|
||||
def store_preferences(self):
|
||||
""" Store the values of the Preference object to the JSON file
|
||||
"""
|
||||
self.value_to_json('first_start', self.first_start)
|
||||
self.value_to_json('picture_aspect', self.picture_aspect)
|
||||
self.value_to_json('dynamic_background_color', self.dynamic_background_color)
|
||||
self.value_to_json('image_source', self.image_source)
|
||||
|
||||
@@ -8,8 +8,8 @@ gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk, GdkPixbuf
|
||||
|
||||
# Packages
|
||||
import subprocess, threading, time, locale
|
||||
from datetime import timedelta, datetime, date
|
||||
import subprocess, threading, time
|
||||
from datetime import timedelta, datetime
|
||||
|
||||
# Local scripts
|
||||
from model.main_view_model import *
|
||||
@@ -17,11 +17,6 @@ from view.dialogs import *
|
||||
from enums.ImageSourceEnum import *
|
||||
from enums.PeriodSourceEnum import *
|
||||
|
||||
UUID = "cinnamon-dynamic-wallpaper@TobiZog"
|
||||
|
||||
localeDir = os.path.expanduser("~") + "/.local/share/locale"
|
||||
locale.bindtextdomain(UUID, localeDir)
|
||||
|
||||
|
||||
class Main_Window:
|
||||
############################################################
|
||||
@@ -39,7 +34,7 @@ class Main_Window:
|
||||
|
||||
# Glade
|
||||
self.builder = Gtk.Builder()
|
||||
self.builder.set_translation_domain(UUID)
|
||||
self.builder.set_translation_domain(self.view_model.UUID)
|
||||
self.builder.add_from_file(self.view_model.GLADE_URI)
|
||||
self.builder.connect_signals(self)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user