From 10062514900184746ff472fc460584458d94bc02 Mon Sep 17 00:00:00 2001 From: DYefremov Date: Fri, 12 Mar 2021 10:24:09 +0300 Subject: [PATCH] added new appearance options [list font, picons size] --- app/settings.py | 83 +++- app/ui/main_app_window.py | 42 +- app/ui/main_helper.py | 4 +- app/ui/settings_dialog.glade | 875 ++++++++++++++++++++++------------- app/ui/settings_dialog.py | 61 ++- app/ui/uicommons.py | 10 +- 6 files changed, 685 insertions(+), 390 deletions(-) diff --git a/app/settings.py b/app/settings.py index 1ceefeba..55a4e136 100644 --- a/app/settings.py +++ b/app/settings.py @@ -30,8 +30,11 @@ class Defaults(Enum): USE_COLORS = True NEW_COLOR = "rgb(255,230,204)" EXTRA_COLOR = "rgb(179,230,204)" + TOOLTIP_LOGO_SIZE = 96 + LIST_PICON_SIZE = 32 FAV_CLICK_MODE = 0 PLAY_STREAMS_MODE = 1 if IS_DARWIN else 0 + STREAM_LIB = "gst" PROFILE_FOLDER_DEFAULT = False RECORDS_PATH = DATA_PATH + "records/" ACTIVATE_TRANSCODING = False @@ -436,6 +439,14 @@ class Settings: def play_streams_mode(self, value): self._settings["play_streams_mode"] = value + @property + def stream_lib(self): + return self._settings.get("stream_lib", Defaults.STREAM_LIB.value) + + @stream_lib.setter + def stream_lib(self, value): + self._settings["stream_lib"] = value + # *********** EPG ************ # @property @@ -513,30 +524,6 @@ class Settings: def enable_send_to(self, value): self._settings["enable_send_to"] = value - @property - def use_colors(self): - return self._settings.get("use_colors", Defaults.USE_COLORS.value) - - @use_colors.setter - def use_colors(self, value): - self._settings["use_colors"] = value - - @property - def new_color(self): - return self._settings.get("new_color", Defaults.NEW_COLOR.value) - - @new_color.setter - def new_color(self, value): - self._settings["new_color"] = value - - @property - def extra_color(self): - return self._settings.get("extra_color", Defaults.EXTRA_COLOR.value) - - @extra_color.setter - def extra_color(self, value): - self._settings["extra_color"] = value - @property def fav_click_mode(self): return self._settings.get("fav_click_mode", Defaults.FAV_CLICK_MODE.value) @@ -581,6 +568,54 @@ class Settings: # *********** Appearance *********** # + @property + def list_font(self): + return self._settings.get("list_font", "") + + @list_font.setter + def list_font(self, value): + self._settings["list_font"] = value + + @property + def list_picon_size(self): + return self._settings.get("list_picon_size", Defaults.LIST_PICON_SIZE.value) + + @list_picon_size.setter + def list_picon_size(self, value): + self._settings["list_picon_size"] = value + + @property + def tooltip_logo_size(self): + return self._settings.get("tooltip_logo_size", Defaults.TOOLTIP_LOGO_SIZE.value) + + @tooltip_logo_size.setter + def tooltip_logo_size(self, value): + self._settings["tooltip_logo_size"] = value + + @property + def use_colors(self): + return self._settings.get("use_colors", Defaults.USE_COLORS.value) + + @use_colors.setter + def use_colors(self, value): + self._settings["use_colors"] = value + + @property + def new_color(self): + return self._settings.get("new_color", Defaults.NEW_COLOR.value) + + @new_color.setter + def new_color(self, value): + self._settings["new_color"] = value + + @property + def extra_color(self): + return self._settings.get("extra_color", Defaults.EXTRA_COLOR.value) + + @extra_color.setter + def extra_color(self, value): + self._settings["extra_color"] = value + @property def dark_mode(self): return self._settings.get("dark_mode", False) diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py index eb5b3c72..5af5806a 100644 --- a/app/ui/main_app_window.py +++ b/app/ui/main_app_window.py @@ -36,7 +36,7 @@ from .search import SearchProvider from .service_details_dialog import ServiceDetailsDialog, Action from .settings_dialog import show_settings_dialog from .uicommons import (Gtk, Gdk, UI_RESOURCES_PATH, LOCKED_ICON, HIDE_ICON, IPTV_ICON, MOVE_KEYS, KeyboardKey, Column, - FavClickMode, MOD_MASK) + FavClickMode, MOD_MASK, APP_FONT) class Application(Gtk.Application): @@ -206,7 +206,9 @@ class Application(Gtk.Application): self._links_transmitter = None self._control_box = None self._ftp_client = None - # Colors + # Appearance + self._current_font = APP_FONT + self._picons_size = self._settings.list_picon_size self._use_colors = False self._NEW_COLOR = None # Color for new services in the main list self._EXTRA_COLOR = None # Color for services with a extra name for the bouquet @@ -340,7 +342,7 @@ class Application(Gtk.Application): self.set_accels() self.init_drag_and_drop() - self.init_colors() + self.init_appearance() if self._settings.load_last_config: config = self._settings.get("last_config") or {} @@ -497,11 +499,21 @@ class Application(Gtk.Application): self._fav_view.get_selection().set_select_function(lambda *args: self._select_enabled) self._bouquets_view.get_selection().set_select_function(lambda *args: self._select_enabled) - def init_colors(self, update=False): - """ Initialisation of background colors for the services. + def init_appearance(self, update=False): + """ Appearance initialisation. If update=False - first call on program start, else - after options changes! """ + if self._current_font != self._settings.list_font: + from gi.repository import Pango + + font_desc = Pango.FontDescription.from_string(self._settings.list_font) + list(map(lambda v: v.modify_font(font_desc), (self._services_view, self._fav_view, self._bouquets_view))) + self._current_font = self._settings.list_font + + if self._picons_size != self._settings.list_picon_size: + self.update_picons_size() + if self._s_type is SettingsType.ENIGMA_2: self._use_colors = self._settings.use_colors @@ -517,6 +529,15 @@ class Application(Gtk.Application): self._NEW_COLOR = new_rgb self._EXTRA_COLOR = extra_rgb + @run_idle + def update_picons_size(self): + self._picons_size = self._settings.list_picon_size + update_picons_data(self._settings.picons_local_path, self._picons, self._picons_size) + self._fav_model.foreach(lambda m, p, itr: m.set_value(itr, Column.FAV_PICON, self._picons.get( + self._services.get(m.get_value(itr, Column.FAV_ID)).picon_id, None))) + self._services_model.foreach(lambda m, p, itr: m.set_value(itr, Column.SRV_PICON, self._picons.get( + m.get_value(itr, Column.SRV_PICON_ID), None))) + def update_background_colors(self, new_color, extra_color): if extra_color != self._EXTRA_COLOR: for row in self._fav_model: @@ -977,7 +998,8 @@ class Application(Gtk.Application): target_column = Column.FAV_ID if target is ViewTarget.FAV else Column.SRV_FAV_ID srv = self._services.get(model[path][target_column], None) if srv and srv.picon_id: - tooltip.set_icon(get_picon_pixbuf(self._settings.picons_local_path + srv.picon_id, size=96)) + tooltip.set_icon(get_picon_pixbuf(self._settings.picons_local_path + srv.picon_id, + size=self._settings.tooltip_logo_size)) tooltip.set_text( self.get_hint_for_bq_list(srv) if target is ViewTarget.FAV else self.get_hint_for_srv_list(srv)) view.set_tooltip_row(tooltip, path) @@ -1439,7 +1461,7 @@ class Application(Gtk.Application): yield True services = get_services(data_path, prf, self.get_format_version() if prf is SettingsType.ENIGMA_2 else 0) yield True - update_picons_data(self._settings.picons_local_path, self._picons) + update_picons_data(self._settings.picons_local_path, self._picons, self._picons_size) yield True except FileNotFoundError as e: msg = get_message("Please, download files from receiver or setup your path for read data!") @@ -1868,7 +1890,7 @@ class Application(Gtk.Application): c_gen = self.clear_current_data() yield from c_gen - self.init_colors(True) + self.init_appearance(True) self.init_profiles() yield True gen = self.init_http_api() @@ -2429,7 +2451,7 @@ class Application(Gtk.Application): def on_player_box_realize(self, widget): if not self._player: try: - self._player = Player.make(name="gst", + self._player = Player.make(name=self._settings.stream_lib, mode=self._settings.play_streams_mode, widget=widget, buf_cb=self.on_player_duration_changed, @@ -3050,7 +3072,7 @@ class Application(Gtk.Application): @run_task def update_picons(self): - update_picons_data(self._settings.picons_local_path, self._picons) + update_picons_data(self._settings.picons_local_path, self._picons, self._picons_size) append_picons(self._picons, self._services_model) def on_assign_picon(self, view, src_path=None, dst_path=None): diff --git a/app/ui/main_helper.py b/app/ui/main_helper.py index 68eb576c..52a6dddf 100644 --- a/app/ui/main_helper.py +++ b/app/ui/main_helper.py @@ -353,12 +353,12 @@ def scroll_to(index, view, paths=None): # ***************** Picons *********************# -def update_picons_data(path, picons): +def update_picons_data(path, picons, size=32): if not os.path.exists(path): return for file in os.listdir(path): - pf = get_picon_pixbuf(path + file) + pf = get_picon_pixbuf(path + file, size) if pf: picons[file] = pf diff --git a/app/ui/settings_dialog.glade b/app/ui/settings_dialog.glade index fa69bdfd..71bf7357 100644 --- a/app/ui/settings_dialog.glade +++ b/app/ui/settings_dialog.glade @@ -3,7 +3,7 @@ The MIT License (MIT) -Copyright (c) 2018-2020 Dmitriy Yefremov +Copyright (c) 2018-2021 Dmitriy Yefremov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -32,8 +32,14 @@ Author: Dmitriy Yefremov - + + + 8 + 100 + 1 + 10 + @@ -44,6 +50,11 @@ Author: Dmitriy Yefremov + + True + False + document-revert + True False @@ -1420,15 +1431,15 @@ Author: Dmitriy Yefremov True False + 5 + 5 + 5 vertical 5 True False - 5 - 5 - 5 0.019999999552965164 in @@ -1860,8 +1871,6 @@ Author: Dmitriy Yefremov True False - 5 - 5 0.019999999552965164 in @@ -1937,6 +1946,65 @@ Author: Dmitriy Yefremov 1 + + + True + False + 0.019999999552965164 + in + + + True + False + center + 5 + 5 + + + GStreamer + True + True + False + True + vlc_lib_button + + + False + True + 0 + + + + + VLC Player + True + True + False + True + gst_lib_button + + + False + True + 1 + + + + + + + True + False + Use to play streams: + + + + + False + True + 2 + + streaming @@ -1948,15 +2016,16 @@ Author: Dmitriy Yefremov True False + 5 + 5 + 5 + 5 vertical + 5 True False - 5 - 5 - 5 - 5 0 in @@ -2022,10 +2091,6 @@ Author: Dmitriy Yefremov True False - 5 - 5 - 5 - 5 0 in @@ -2080,10 +2145,6 @@ Author: Dmitriy Yefremov True False - 5 - 5 - 5 - 5 0 in @@ -2138,6 +2199,7 @@ Author: Dmitriy Yefremov True True + end 1 @@ -2156,14 +2218,279 @@ Author: Dmitriy Yefremov 2 + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + 5 + 5 + + + True + True + end + + + 1 + 0 + + + + + True + True + end + + + 1 + 1 + + + + + True + False + 1 + True + Before saving + 0 + + + 0 + 0 + + + + + True + False + Before downloading from the receiver + 0 + + + 0 + 1 + + + + + + + True + False + Backup: + + + + + False + True + 3 + + + + + program + Program + 3 + + + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + + + True + False + start + True + Font in the lists: + + + False + True + 0 + + + + + True + False + + + True + True + True + Reset + set_default_font_image + True + + + + True + True + 0 + + + + + True + True + False + Sans 12 + + True + False + + + True + True + end + 1 + + + + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + 5 + + + True + False + start + True + Picons size in the lists: + + + 0 + 0 + + + + + True + False + start + Logo size in tooltips: + + + 0 + 1 + + + + + True + False + 0 + + 96 + 128 + 220 + + + + 1 + 1 + + + + + 85 + True + False + 0 + + 32 + 48 + 64 + 72 + 96 + + + + 1 + 0 + + + + + False + True + 1 + + + + + + + + + + False + True + 0 + + True False - 5 - 5 - 5 - 5 0 in @@ -2172,13 +2499,13 @@ Author: Dmitriy Yefremov False 5 5 + 5 5 vertical True False - 5 5 @@ -2289,110 +2616,11 @@ Author: Dmitriy Yefremov False True - 3 + 1 - - - True - False - 5 - 5 - 5 - 0.019999999552965164 - in - - - True - False - 5 - 5 - 5 - 5 - 5 - - - True - True - end - - - 1 - 0 - - - - - True - True - end - - - 1 - 1 - - - - - True - False - 1 - True - Before saving - 0 - - - 0 - 0 - - - - - True - False - Before downloading from the receiver - 0 - - - 0 - 1 - - - - - - - True - False - Backup: - - - - - False - True - 4 - - - - - program - Program - 3 - - - - - False - 5 - 5 - 5 - 5 - vertical - 5 - True False 0 in @@ -2488,12 +2716,11 @@ Author: Dmitriy Yefremov False True - 0 + 2 - - True + False 0 in @@ -2503,8 +2730,6 @@ Author: Dmitriy Yefremov False 5 5 - 5 - 5 True @@ -2551,12 +2776,11 @@ Author: Dmitriy Yefremov False True - 1 + 3 - - True + False False 0 @@ -2577,8 +2801,6 @@ Author: Dmitriy Yefremov False 5 5 - 5 - 5 True @@ -2652,7 +2874,7 @@ Author: Dmitriy Yefremov False True - 0 + 1 @@ -2671,8 +2893,6 @@ Author: Dmitriy Yefremov False Preview center - 2 - 2 2 2 0 @@ -2685,144 +2905,129 @@ Author: Dmitriy Yefremov False True - end - 1 - - - - - - - - - - False - True - 2 - - - - - True - False - center - - - True - False - Gtk3 Themes and Icons: - - - False - True - 0 - - - - - www.gnome-look.org - True - True - True - none - https://www.gnome-look.org/ - - - False - True - 1 - - - - - False - True - end - 3 - - - - - True - False - False - 0 - in - - - True - False - 5 - 5 - 5 - 5 - - - True - False - Icon Theme: - - - False - True - 0 - - - - - True - False - - - - False - True - end - 1 - - - - - True - True - True - Add - - - - True - False - gtk-add - - - - - False - True - end 2 - + True - True - True - Remove - + False + 5 + 5 - + True False - gtk-remove + Icon Theme: + + False + True + 0 + + + + + True + False + + + + False + True + end + 1 + + + + + True + True + True + Add + + + + True + False + gtk-add + + + + + False + True + end + 2 + + + + + True + True + True + Remove + + + + True + False + gtk-remove + + + + + False + True + end + 3 + + + + + False + True + 3 + + + + + True + False + center + + + True + False + Gtk3 Themes and Icons: + + + False + True + 0 + + + + + www.gnome-look.org + True + True + True + none + https://www.gnome-look.org/ + + + False + True + 1 + False True end - 3 + 4 @@ -2832,7 +3037,7 @@ Author: Dmitriy Yefremov - False + True True 4 @@ -2853,7 +3058,7 @@ Author: Dmitriy Yefremov 5 5 vertical - 10 + 5 True @@ -3019,6 +3224,7 @@ Author: Dmitriy Yefremov True False Play IPTV or other stream in the program(Ctrl + P) + True True click_mode_disabled_button @@ -3035,6 +3241,7 @@ Author: Dmitriy Yefremov True False Switch the channel and watch in the program(Ctrl + W) + True True click_mode_stream_button @@ -3079,80 +3286,80 @@ Author: Dmitriy Yefremov 2 - - - True - False - 0.019999999552965164 - in - - - True - False - 5 - 5 - 5 - 5 - 5 - - - True - False - start - Enable experimental features - - - False - True - 0 - - - - - True - True - end - center - - - - False - True - end - 2 - - - - - - - - - - False - True - 3 - - - - - True - False - 15 - EXPERIMENTAL! - - - False - True - 4 - - True False vertical 10 + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + 5 + 5 + + + True + False + start + Enable experimental features + + + False + True + 0 + + + + + True + True + end + center + + + + False + True + end + 2 + + + + + + + + + + False + True + 0 + + + + + True + False + 15 + EXPERIMENTAL! + + + False + True + 1 + + True @@ -3204,7 +3411,7 @@ Author: Dmitriy Yefremov False True - 0 + 2 @@ -3330,7 +3537,7 @@ Author: Dmitriy Yefremov False True - 1 + 3 @@ -3385,14 +3592,14 @@ Author: Dmitriy Yefremov False True - 2 + 4 False True - 8 + 3 diff --git a/app/ui/settings_dialog.py b/app/ui/settings_dialog.py index 9630a902..2f690f2a 100644 --- a/app/ui/settings_dialog.py +++ b/app/ui/settings_dialog.py @@ -6,7 +6,7 @@ from app.connections import test_telnet, test_ftp, TestException, test_http, Htt from app.settings import SettingsType, Settings, PlayStreamsMode from app.ui.dialogs import show_dialog, DialogType, get_message, get_chooser_dialog from .main_helper import update_entry_data, scroll_to, get_picon_pixbuf -from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH, FavClickMode, DEFAULT_ICON +from .uicommons import Gtk, Gdk, UI_RESOURCES_PATH, FavClickMode, DEFAULT_ICON, APP_FONT def show_settings_dialog(transient, options): @@ -50,6 +50,7 @@ class SettingsDialog: "on_apply_presets": self.on_apply_presets, "on_digit_entry_changed": self.on_digit_entry_changed, "on_view_popup_menu": self.on_view_popup_menu, + "on_list_font_reset": self.on_list_font_reset, "on_theme_changed": self.on_theme_changed, "on_theme_add": self.on_theme_add, "on_theme_remove": self.on_theme_remove, @@ -124,18 +125,23 @@ class SettingsDialog: self._play_in_built_radio_button = builder.get_object("play_in_built_radio_button") self._play_in_window_radio_button = builder.get_object("play_in_window_radio_button") self._get_m3u_radio_button = builder.get_object("get_m3u_radio_button") + self._gst_lib_button = builder.get_object("gst_lib_button") + self._vlc_lib_button = builder.get_object("vlc_lib_button") # Program self._before_save_switch = builder.get_object("before_save_switch") self._before_downloading_switch = builder.get_object("before_downloading_switch") - self._enable_experimental_box = builder.get_object("enable_experimental_box") - self._colors_grid = builder.get_object("colors_grid") - self._set_color_switch = builder.get_object("set_color_switch") - self._new_color_button = builder.get_object("new_color_button") - self._extra_color_button = builder.get_object("extra_color_button") self._load_on_startup_switch = builder.get_object("load_on_startup_switch") self._bouquet_hints_switch = builder.get_object("bouquet_hints_switch") self._services_hints_switch = builder.get_object("services_hints_switch") self._lang_combo_box = builder.get_object("lang_combo_box") + # Appearance + self._list_font_button = builder.get_object("list_font_button") + self._picons_size_button = builder.get_object("picons_size_button") + self._tooltip_logo_size_button = builder.get_object("tooltip_logo_size_button") + self._colors_grid = builder.get_object("colors_grid") + self._set_color_switch = builder.get_object("set_color_switch") + self._new_color_button = builder.get_object("new_color_button") + self._extra_color_button = builder.get_object("extra_color_button") # Extra self._support_http_api_switch = builder.get_object("support_http_api_switch") self._enable_yt_dl_switch = builder.get_object("enable_yt_dl_switch") @@ -178,19 +184,19 @@ class SettingsDialog: self.init_profiles() if self._settings.is_darwin: - # Appearance - self._appearance_box = builder.get_object("appearance_box") - self._appearance_box.set_visible(True) + # Themes + self._layout_switch = builder.get_object("layout_switch") + self._layout_switch.bind_property("active", builder.get_object("bouquet_box"), "sensitive") + self._layout_switch.set_active(self._ext_settings.alternate_layout) + self._theme_frame = builder.get_object("theme_frame") + self._theme_frame.set_visible(True) self._theme_thumbnail_image = builder.get_object("theme_thumbnail_image") self._theme_combo_box = builder.get_object("theme_combo_box") self._icon_theme_combo_box = builder.get_object("icon_theme_combo_box") self._dark_mode_switch = builder.get_object("dark_mode_switch") - self._layout_switch = builder.get_object("layout_switch") - self._layout_switch.bind_property("active", builder.get_object("bouquet_box"), "sensitive") self._themes_support_switch = builder.get_object("themes_support_switch") - self._themes_support_switch.bind_property("active", builder.get_object("gtk_theme_frame"), "sensitive") - self._themes_support_switch.bind_property("active", builder.get_object("icon_theme_frame"), "sensitive") - self.init_appearance() + self._themes_support_switch.bind_property("active", self._theme_frame, "sensitive") + self.init_themes() @run_idle def init_ui_elements(self, s_type): @@ -269,6 +275,7 @@ class SettingsDialog: self._before_downloading_switch.set_active(self._settings.backup_before_downloading) self.set_fav_click_mode(self._settings.fav_click_mode) self.set_play_stream_mode(self._settings.play_streams_mode) + self.set_stream_lib(self._settings.stream_lib) self._load_on_startup_switch.set_active(self._settings.load_last_config) self._bouquet_hints_switch.set_active(self._settings.show_bq_hints) self._services_hints_switch.set_active(self._settings.show_srv_hints) @@ -276,6 +283,9 @@ class SettingsDialog: self._transcoding_switch.set_active(self._settings.activate_transcoding) self._presets_combo_box.set_active_id(self._settings.active_preset) self.on_transcoding_preset_changed(self._presets_combo_box) + self._picons_size_button.set_active_id(str(self._settings.list_picon_size)) + self._tooltip_logo_size_button.set_active_id(str(self._settings.tooltip_logo_size)) + self._list_font_button.set_font(self._settings.list_font) if self._s_type is SettingsType.ENIGMA_2: self._enable_exp_switch.set_active(self._settings.is_enable_experimental) @@ -331,6 +341,7 @@ class SettingsDialog: self._ext_settings.backup_before_downloading = self._before_downloading_switch.get_active() self._ext_settings.fav_click_mode = self.get_fav_click_mode() self._ext_settings.play_streams_mode = self.get_play_stream_mode() + self._ext_settings.stream_lib = self.get_stream_lib() self._ext_settings.language = self._lang_combo_box.get_active_id() self._ext_settings.load_last_config = self._load_on_startup_switch.get_active() self._ext_settings.show_bq_hints = self._bouquet_hints_switch.get_active() @@ -340,6 +351,9 @@ class SettingsDialog: self._ext_settings.records_path = self._record_data_dir_field.get_text() self._ext_settings.activate_transcoding = self._transcoding_switch.get_active() self._ext_settings.active_preset = self._presets_combo_box.get_active_id() + self._ext_settings.list_picon_size = int(self._picons_size_button.get_active_id()) + self._ext_settings.tooltip_logo_size = int(self._tooltip_logo_size_button.get_active_id()) + self._ext_settings.list_font = self._list_font_button.get_font() if self._ext_settings.is_darwin: self._ext_settings.dark_mode = self._dark_mode_switch.get_active() @@ -620,6 +634,13 @@ class SettingsDialog: return self._settings.play_streams_mode + def set_stream_lib(self, mode): + self._vlc_lib_button.set_active(mode == "vlc") + self._gst_lib_button.set_active(mode == "gst") + + def get_stream_lib(self): + return "gst" if self._gst_lib_button.get_active() else "vlc" + def on_transcoding_preset_changed(self, button): presets = self._settings.transcoding_presets prs = presets.get(button.get_active_id()) @@ -664,6 +685,11 @@ class SettingsDialog: if event.get_event_type() == Gdk.EventType.BUTTON_PRESS and event.button == Gdk.BUTTON_SECONDARY: menu.popup(None, None, None, None, event.button, event.time) + def on_list_font_reset(self, button): + self._list_font_button.set_font(APP_FONT) + + # ******************* Themes *********************** # + def on_theme_changed(self, button): if self._main_stack.get_visible_child_name() != "appearance": return @@ -702,7 +728,7 @@ class SettingsDialog: response = get_chooser_dialog(self._dialog, self._settings, "Themes Archive [*.xz, *.zip]", ("*.xz", "*.zip")) if response in (Gtk.ResponseType.CANCEL, Gtk.ResponseType.DELETE_EVENT): return - self._appearance_box.set_sensitive(False) + self._theme_frame.set_sensitive(False) self.unpack_theme(response, path, button) @run_task @@ -719,7 +745,6 @@ class SettingsDialog: log("Unpacking end.") finally: self.update_theme_button(button, dst) - self._appearance_box.set_sensitive(True) @run_idle def update_theme_button(self, button, dst): @@ -732,6 +757,7 @@ class SettingsDialog: button.append(theme, theme) button.set_active_id(theme) self.show_info_message("Done!", Gtk.MessageType.INFO) + self._theme_frame.set_sensitive(True) @run_idle def remove_theme(self, button, path): @@ -755,9 +781,8 @@ class SettingsDialog: button.set_active(0) @run_idle - def init_appearance(self): + def init_themes(self): self._dark_mode_switch.set_active(self._ext_settings.dark_mode) - self._layout_switch.set_active(self._ext_settings.alternate_layout) t_support = self._ext_settings.is_themes_support self._themes_support_switch.set_active(t_support) if t_support: diff --git a/app/ui/uicommons.py b/app/ui/uicommons.py index 9acd13de..b476fcee 100644 --- a/app/ui/uicommons.py +++ b/app/ui/uicommons.py @@ -2,7 +2,6 @@ import locale import os from enum import Enum, IntEnum from functools import lru_cache -from app.settings import Settings, SettingsException, IS_DARWIN import gi @@ -11,6 +10,8 @@ gi.require_version("Gdk", "3.0") gi.require_version("Notify", "0.7") from gi.repository import Gtk, Gdk, Notify +from app.settings import Settings, SettingsException, IS_DARWIN + # Init notify Notify.init("DemonEditor") # Setting mod mask for the keyboard depending on the platform. @@ -20,6 +21,7 @@ UI_RESOURCES_PATH = "app/ui/" if os.path.exists("app/ui/") else "/usr/share/demo IS_GNOME_SESSION = int(bool(os.environ.get("GNOME_DESKTOP_SESSION_ID"))) # Translation. TEXT_DOMAIN = "demon-editor" +APP_FONT = None try: settings = Settings.get_instance() @@ -30,8 +32,12 @@ else: if UI_RESOURCES_PATH == "app/ui/": locale.bindtextdomain(TEXT_DOMAIN, UI_RESOURCES_PATH + "lang") + st = Gtk.Settings().get_default() + APP_FONT = st.get_property("gtk-font-name") + if not settings.list_font: + settings.list_font = APP_FONT + if settings.is_themes_support: - st = Gtk.Settings().get_default() st.set_property("gtk-theme-name", settings.theme) st.set_property("gtk-icon-theme-name", settings.icon_theme)