diff --git a/Menu/GameShell/10_Settings/Wifi/__init__.py b/Menu/GameShell/10_Settings/Wifi/__init__.py index 4341f8e..7d929cf 100644 --- a/Menu/GameShell/10_Settings/Wifi/__init__.py +++ b/Menu/GameShell/10_Settings/Wifi/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- - ## local UI import import pages import myvars @@ -10,11 +9,8 @@ try: except: print("No icons package") """ -from icons import preload def Init(main_screen): - - preload.load_icons() pages.InitPasswordPage(main_screen) pages.InitScanPage(main_screen) diff --git a/Menu/GameShell/10_Settings/Wifi/icons/__init__.py b/Menu/GameShell/10_Settings/Wifi/icons/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/Menu/GameShell/10_Settings/Wifi/icons/preload.py b/Menu/GameShell/10_Settings/Wifi/icons/preload.py deleted file mode 100644 index b4b0759..0000000 --- a/Menu/GameShell/10_Settings/Wifi/icons/preload.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- - -import pygame -from pygame.locals import * -from sys import exit -import os -import sys - -from beeprint import pp - -ICONS_PRELOAD={} - - -def load_icons(): - basepath = os.path.dirname(os.path.realpath(__file__)) - - files = os.listdir(basepath) - for i in files: - if os.path.isfile(basepath+"/"+i) and i.endswith(".png"): - keyname = i.split(".")[0] - ICONS_PRELOAD[keyname] = pygame.image.load(basepath+"/"+i).convert_alpha() diff --git a/Menu/GameShell/10_Settings/Wifi/keyboard.py b/Menu/GameShell/10_Settings/Wifi/keyboard.py index a6bfca9..8a00c52 100644 --- a/Menu/GameShell/10_Settings/Wifi/keyboard.py +++ b/Menu/GameShell/10_Settings/Wifi/keyboard.py @@ -12,12 +12,12 @@ from UI.fonts import fonts from UI.util_funcs import midRect from UI.keys_def import CurKeys from UI.icon_item import IconItem +from UI.icon_pool import MyIconPool from libs.roundrects import aa_round_rect from textarea import Textarea from text_item import TextItem -from icons import preload import myvars @@ -135,7 +135,7 @@ class Keyboard(Page): if val == "_L" or val == "_R": it = KeyboardIcon() - it._ImgSurf = preload.ICONS_PRELOAD[val] + it._ImgSurf = MyIconPool._Icons[val] it._Parent = self it._Str = val it.Init(start_x+it._ImgSurf.get_width()/2 ,start_y,it._ImgSurf.get_width(),it._ImgSurf.get_height(),0) diff --git a/Menu/GameShell/10_Settings/Wifi/net_item.py b/Menu/GameShell/10_Settings/Wifi/net_item.py index defdc83..765415d 100644 --- a/Menu/GameShell/10_Settings/Wifi/net_item.py +++ b/Menu/GameShell/10_Settings/Wifi/net_item.py @@ -8,8 +8,8 @@ from UI.label import Label from UI.fonts import fonts from UI.icon_item import IconItem from UI.multi_icon_item import MultiIconItem +from UI.icon_pool import MyIconPool -from icons import preload class NetItemMultiIcon(MultiIconItem): _CanvasHWND = None @@ -140,13 +140,13 @@ class NetItem(object): lock_icon = NetItemIcon() - lock_icon._ImgSurf = preload.ICONS_PRELOAD["lock"] + lock_icon._ImgSurf = MyIconPool._Icons["lock"] lock_icon._CanvasHWND = self._Parent._CanvasHWND lock_icon._Parent = self self._Icons["lock"] = lock_icon done_icon = NetItemIcon() - done_icon._ImgSurf = preload.ICONS_PRELOAD["done"] + done_icon._ImgSurf = MyIconPool._Icons["done"] done_icon._CanvasHWND = self._Parent._CanvasHWND done_icon._Parent = self diff --git a/Menu/GameShell/Music Player/__init__.py b/Menu/GameShell/Music Player/__init__.py index 381cbc8..86c5bfe 100644 --- a/Menu/GameShell/Music Player/__init__.py +++ b/Menu/GameShell/Music Player/__init__.py @@ -1,26 +1,14 @@ # -*- coding: utf-8 -*- import pygame -from pygame.locals import * -from sys import exit -import os -import sys - -from datetime import datetime - -import base64 -from beeprint import pp - ## local UI import import pages import myvars -from icons import preload def Init(main_screen): pages.InitPoller() - preload.load_icons() pages.InitListPage(main_screen) pages.InitMusicLibPage(main_screen) pages.InitSpectrumPage(main_screen) diff --git a/Menu/GameShell/Music Player/icons/__init__.py b/Menu/GameShell/Music Player/icons/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/Menu/GameShell/Music Player/icons/done.png b/Menu/GameShell/Music Player/icons/done.png deleted file mode 100644 index ceeadbf..0000000 Binary files a/Menu/GameShell/Music Player/icons/done.png and /dev/null differ diff --git a/Menu/GameShell/Music Player/icons/preload.py b/Menu/GameShell/Music Player/icons/preload.py deleted file mode 100644 index b4b0759..0000000 --- a/Menu/GameShell/Music Player/icons/preload.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- - -import pygame -from pygame.locals import * -from sys import exit -import os -import sys - -from beeprint import pp - -ICONS_PRELOAD={} - - -def load_icons(): - basepath = os.path.dirname(os.path.realpath(__file__)) - - files = os.listdir(basepath) - for i in files: - if os.path.isfile(basepath+"/"+i) and i.endswith(".png"): - keyname = i.split(".")[0] - ICONS_PRELOAD[keyname] = pygame.image.load(basepath+"/"+i).convert_alpha() diff --git a/Menu/GameShell/Music Player/list_item.py b/Menu/GameShell/Music Player/list_item.py index 2d2c369..e3fe554 100644 --- a/Menu/GameShell/Music Player/list_item.py +++ b/Menu/GameShell/Music Player/list_item.py @@ -17,7 +17,6 @@ from UI.util_funcs import midRect # ------------------------ import myvars # icons_path -from icons import preload class ListItemIcon(IconItem): diff --git a/Menu/GameShell/20_Retro Games/GBA.png b/skin/default/Menu/GameShell/20_Retro Games/GBA.png similarity index 100% rename from Menu/GameShell/20_Retro Games/GBA.png rename to skin/default/Menu/GameShell/20_Retro Games/GBA.png diff --git a/Menu/GameShell/20_Retro Games/MAME.png b/skin/default/Menu/GameShell/20_Retro Games/MAME.png similarity index 100% rename from Menu/GameShell/20_Retro Games/MAME.png rename to skin/default/Menu/GameShell/20_Retro Games/MAME.png diff --git a/Menu/GameShell/20_Retro Games/NES.png b/skin/default/Menu/GameShell/20_Retro Games/NES.png similarity index 100% rename from Menu/GameShell/20_Retro Games/NES.png rename to skin/default/Menu/GameShell/20_Retro Games/NES.png diff --git a/Menu/GameShell/CaveStory.png b/skin/default/Menu/GameShell/CaveStory.png similarity index 100% rename from Menu/GameShell/CaveStory.png rename to skin/default/Menu/GameShell/CaveStory.png diff --git a/Menu/GameShell/Music Player.png b/skin/default/Menu/GameShell/Music Player.png similarity index 100% rename from Menu/GameShell/Music Player.png rename to skin/default/Menu/GameShell/Music Player.png diff --git a/Menu/GameShell/PowerOFF.png b/skin/default/Menu/GameShell/PowerOFF.png similarity index 100% rename from Menu/GameShell/PowerOFF.png rename to skin/default/Menu/GameShell/PowerOFF.png diff --git a/Menu/GameShell/Retro Games.png b/skin/default/Menu/GameShell/Retro Games.png similarity index 100% rename from Menu/GameShell/Retro Games.png rename to skin/default/Menu/GameShell/Retro Games.png diff --git a/Menu/GameShell/RetroArch.png b/skin/default/Menu/GameShell/RetroArch.png similarity index 100% rename from Menu/GameShell/RetroArch.png rename to skin/default/Menu/GameShell/RetroArch.png diff --git a/Menu/GameShell/Settings.png b/skin/default/Menu/GameShell/Settings.png similarity index 100% rename from Menu/GameShell/Settings.png rename to skin/default/Menu/GameShell/Settings.png diff --git a/Menu/GameShell/Sleep.png b/skin/default/Menu/GameShell/Sleep.png similarity index 100% rename from Menu/GameShell/Sleep.png rename to skin/default/Menu/GameShell/Sleep.png diff --git a/Menu/GameShell/TinyCloud.png b/skin/default/Menu/GameShell/TinyCloud.png similarity index 100% rename from Menu/GameShell/TinyCloud.png rename to skin/default/Menu/GameShell/TinyCloud.png diff --git a/Menu/GameShell/freeDM.png b/skin/default/Menu/GameShell/freeDM.png similarity index 100% rename from Menu/GameShell/freeDM.png rename to skin/default/Menu/GameShell/freeDM.png diff --git a/sys.py/gameshell/blank.png b/skin/default/sys.py/gameshell/blank.png similarity index 100% rename from sys.py/gameshell/blank.png rename to skin/default/sys.py/gameshell/blank.png diff --git a/sys.py/gameshell/footbar_icons/footbar.png b/skin/default/sys.py/gameshell/footbar_icons/footbar.png similarity index 100% rename from sys.py/gameshell/footbar_icons/footbar.png rename to skin/default/sys.py/gameshell/footbar_icons/footbar.png diff --git a/Menu/GameShell/10_Settings/Wifi/icons/_L.png b/skin/default/sys.py/gameshell/icons/_L.png similarity index 100% rename from Menu/GameShell/10_Settings/Wifi/icons/_L.png rename to skin/default/sys.py/gameshell/icons/_L.png diff --git a/Menu/GameShell/10_Settings/Wifi/icons/_R.png b/skin/default/sys.py/gameshell/icons/_R.png similarity index 100% rename from Menu/GameShell/10_Settings/Wifi/icons/_R.png rename to skin/default/sys.py/gameshell/icons/_R.png diff --git a/sys.py/gameshell/icons/about_bg.png b/skin/default/sys.py/gameshell/icons/about_bg.png similarity index 100% rename from sys.py/gameshell/icons/about_bg.png rename to skin/default/sys.py/gameshell/icons/about_bg.png diff --git a/Menu/GameShell/10_Settings/Wifi/icons/done.png b/skin/default/sys.py/gameshell/icons/done.png similarity index 100% rename from Menu/GameShell/10_Settings/Wifi/icons/done.png rename to skin/default/sys.py/gameshell/icons/done.png diff --git a/sys.py/gameshell/icons/empty.png b/skin/default/sys.py/gameshell/icons/empty.png similarity index 100% rename from sys.py/gameshell/icons/empty.png rename to skin/default/sys.py/gameshell/icons/empty.png diff --git a/sys.py/gameshell/icons/heart.png b/skin/default/sys.py/gameshell/icons/heart.png similarity index 100% rename from sys.py/gameshell/icons/heart.png rename to skin/default/sys.py/gameshell/icons/heart.png diff --git a/sys.py/gameshell/icons/icon_sd.png b/skin/default/sys.py/gameshell/icons/icon_sd.png similarity index 100% rename from sys.py/gameshell/icons/icon_sd.png rename to skin/default/sys.py/gameshell/icons/icon_sd.png diff --git a/sys.py/gameshell/icons/light.png b/skin/default/sys.py/gameshell/icons/light.png similarity index 100% rename from sys.py/gameshell/icons/light.png rename to skin/default/sys.py/gameshell/icons/light.png diff --git a/Menu/GameShell/10_Settings/Wifi/icons/lock.png b/skin/default/sys.py/gameshell/icons/lock.png similarity index 100% rename from Menu/GameShell/10_Settings/Wifi/icons/lock.png rename to skin/default/sys.py/gameshell/icons/lock.png diff --git a/sys.py/gameshell/icons/needwifi_bg.png b/skin/default/sys.py/gameshell/icons/needwifi_bg.png similarity index 100% rename from sys.py/gameshell/icons/needwifi_bg.png rename to skin/default/sys.py/gameshell/icons/needwifi_bg.png diff --git a/sys.py/gameshell/icons/online.png b/skin/default/sys.py/gameshell/icons/online.png similarity index 100% rename from sys.py/gameshell/icons/online.png rename to skin/default/sys.py/gameshell/icons/online.png diff --git a/sys.py/gameshell/icons/rom_download.png b/skin/default/sys.py/gameshell/icons/rom_download.png similarity index 100% rename from sys.py/gameshell/icons/rom_download.png rename to skin/default/sys.py/gameshell/icons/rom_download.png diff --git a/sys.py/gameshell/icons/roundcorners.png b/skin/default/sys.py/gameshell/icons/roundcorners.png similarity index 100% rename from sys.py/gameshell/icons/roundcorners.png rename to skin/default/sys.py/gameshell/icons/roundcorners.png diff --git a/sys.py/gameshell/icons/scale.png b/skin/default/sys.py/gameshell/icons/scale.png similarity index 100% rename from sys.py/gameshell/icons/scale.png rename to skin/default/sys.py/gameshell/icons/scale.png diff --git a/sys.py/gameshell/icons/star.png b/skin/default/sys.py/gameshell/icons/star.png similarity index 100% rename from sys.py/gameshell/icons/star.png rename to skin/default/sys.py/gameshell/icons/star.png diff --git a/sys.py/gameshell/icons/sys.png b/skin/default/sys.py/gameshell/icons/sys.png similarity index 100% rename from sys.py/gameshell/icons/sys.png rename to skin/default/sys.py/gameshell/icons/sys.png diff --git a/sys.py/gameshell/icons/vol.png b/skin/default/sys.py/gameshell/icons/vol.png similarity index 100% rename from sys.py/gameshell/icons/vol.png rename to skin/default/sys.py/gameshell/icons/vol.png diff --git a/sys.py/gameshell/titlebar_icons/battery_unknown.png b/skin/default/sys.py/gameshell/titlebar_icons/battery_unknown.png similarity index 100% rename from sys.py/gameshell/titlebar_icons/battery_unknown.png rename to skin/default/sys.py/gameshell/titlebar_icons/battery_unknown.png diff --git a/sys.py/gameshell/titlebar_icons/soundvolume.png b/skin/default/sys.py/gameshell/titlebar_icons/soundvolume.png similarity index 100% rename from sys.py/gameshell/titlebar_icons/soundvolume.png rename to skin/default/sys.py/gameshell/titlebar_icons/soundvolume.png diff --git a/sys.py/gameshell/titlebar_icons/wifi.png b/skin/default/sys.py/gameshell/titlebar_icons/wifi.png similarity index 100% rename from sys.py/gameshell/titlebar_icons/wifi.png rename to skin/default/sys.py/gameshell/titlebar_icons/wifi.png diff --git a/sys.py/gameshell/titlebar_icons/withcharging.png b/skin/default/sys.py/gameshell/titlebar_icons/withcharging.png similarity index 100% rename from sys.py/gameshell/titlebar_icons/withcharging.png rename to skin/default/sys.py/gameshell/titlebar_icons/withcharging.png diff --git a/sys.py/gameshell/titlebar_icons/without_charging.png b/skin/default/sys.py/gameshell/titlebar_icons/without_charging.png similarity index 100% rename from sys.py/gameshell/titlebar_icons/without_charging.png rename to skin/default/sys.py/gameshell/titlebar_icons/without_charging.png diff --git a/truetype/NotoSansCJK-Regular.ttf b/skin/default/truetype/NotoSansCJK-Regular.ttf similarity index 100% rename from truetype/NotoSansCJK-Regular.ttf rename to skin/default/truetype/NotoSansCJK-Regular.ttf diff --git a/truetype/NotoSansMono-Regular.ttf b/skin/default/truetype/NotoSansMono-Regular.ttf similarity index 100% rename from truetype/NotoSansMono-Regular.ttf rename to skin/default/truetype/NotoSansMono-Regular.ttf diff --git a/truetype/VarelaRound-Regular.ttf b/skin/default/truetype/VarelaRound-Regular.ttf similarity index 100% rename from truetype/VarelaRound-Regular.ttf rename to skin/default/truetype/VarelaRound-Regular.ttf diff --git a/truetype/VeraMono.ttf b/skin/default/truetype/VeraMono.ttf similarity index 100% rename from truetype/VeraMono.ttf rename to skin/default/truetype/VeraMono.ttf diff --git a/sys.py/UI/.#page.py b/sys.py/UI/.#page.py new file mode 120000 index 0000000..c042f4f --- /dev/null +++ b/sys.py/UI/.#page.py @@ -0,0 +1 @@ +guu@guu-desktop.5528:1527716105 \ No newline at end of file diff --git a/sys.py/UI/fonts.py b/sys.py/UI/fonts.py index fbcf3e4..29d5e19 100644 --- a/sys.py/UI/fonts.py +++ b/sys.py/UI/fonts.py @@ -6,18 +6,19 @@ from sys import exit import os import sys -from datetime import datetime - +import config if not pygame.font.get_init(): pygame.font.init() + +skinpath = "../skin/"+config.SKIN+"/truetype" fonts_path = {} -fonts_path["varela"] = "../truetype/VarelaRound-Regular.ttf" -fonts_path["veramono"] = "../truetype/VeraMono.ttf" -fonts_path["noto"] = "../truetype/NotoSansMono-Regular.ttf" -fonts_path["notocjk"] = "../truetype/NotoSansCJK-Regular.ttf" +fonts_path["varela"] = "%s/VarelaRound-Regular.ttf" % skinpath +fonts_path["veramono"] = "%s/VeraMono.ttf" % skinpath +fonts_path["noto"] = "%s/NotoSansMono-Regular.ttf" % skinpath +fonts_path["notocjk"] = "%s/NotoSansCJK-Regular.ttf" % skinpath fonts = {} fonts["varela12"] = pygame.font.Font(fonts_path["varela"],12) diff --git a/sys.py/UI/foot_bar.py b/sys.py/UI/foot_bar.py index 19f4381..2eec276 100644 --- a/sys.py/UI/foot_bar.py +++ b/sys.py/UI/foot_bar.py @@ -6,14 +6,14 @@ import os ##local import from constants import Width,Height,ICON_TYPES,ALIGN -from util_funcs import FileExists,midRect +from util_funcs import FileExists,midRect,SkinMap from icon_item import IconItem from fonts import fonts from multi_icon_item import MultiIconItem from icon_pool import MyIconPool from libs.roundrects import aa_round_rect -icon_base_path = "gameshell/footbar_icons/" +icon_base_path = SkinMap("gameshell/footbar_icons/") class FootBarIcon(MultiIconItem): diff --git a/sys.py/UI/icon_pool.py b/sys.py/UI/icon_pool.py index 17b7412..f08058c 100644 --- a/sys.py/UI/icon_pool.py +++ b/sys.py/UI/icon_pool.py @@ -6,12 +6,12 @@ from sys import exit import os import sys - +from util_funcs import SkinMap ##pool only store surfaces class IconPool(object): - _GameShellIconPath = "gameshell/icons/" + _GameShellIconPath = SkinMap("gameshell/icons/") _Icons = {} def __init__(self): self._Icons= {} diff --git a/sys.py/UI/main_screen.py b/sys.py/UI/main_screen.py index eb1ff5f..69e6aef 100644 --- a/sys.py/UI/main_screen.py +++ b/sys.py/UI/main_screen.py @@ -19,7 +19,7 @@ from page import Page,PageStack from title_bar import TitleBar from foot_bar import FootBar from constants import Width,Height,bg_color -from util_funcs import midRect,FileExists,ReplaceSuffix,ReadTheFileContent,CmdClean,MakeExecutable +from util_funcs import midRect,FileExists,ReplaceSuffix,ReadTheFileContent,CmdClean,MakeExecutable,SkinMap from fonts import fonts from keys_def import CurKeys from label import Label @@ -353,7 +353,7 @@ class MainScreen(object): return False def ReadTheDirIntoPages(self,_dir,pglevel,cur_page): - + if FileExists(_dir) == False and os.path.isdir(_dir) == False: return @@ -371,8 +371,8 @@ class MainScreen(object): iconitem = IconItem() iconitem._CmdPath = "" iconitem.AddLabel(i2,self._IconFont) - if FileExists(_dir+"/"+i2+".png"): - iconitem._ImageName = _dir+"/"+i2+".png" + if FileExists( SkinMap(_dir+"/"+i2+".png") ): + iconitem._ImageName = SkinMap(_dir+"/"+i2+".png") else: untitled = UntitledIcon() untitled.Init() @@ -446,8 +446,8 @@ class MainScreen(object): iconitem._CmdPath = _dir+"/"+i MakeExecutable(iconitem._CmdPath) iconitem._MyType = ICON_TYPES["EXE"] - if FileExists(_dir+"/"+ReplaceSuffix(i2,"png")): - iconitem._ImageName = _dir+"/"+ReplaceSuffix(i2,"png") + if FileExists( SkinMap( _dir+"/"+ReplaceSuffix(i2,"png"))): + iconitem._ImageName = SkinMap(_dir+"/"+ReplaceSuffix(i2,"png")) else: untitled = UntitledIcon() untitled.Init() diff --git a/sys.py/UI/title_bar.py b/sys.py/UI/title_bar.py index 080d425..95c2c59 100644 --- a/sys.py/UI/title_bar.py +++ b/sys.py/UI/title_bar.py @@ -17,7 +17,7 @@ from icon_item import IconItem from multi_icon_item import MultiIconItem from icon_pool import MyIconPool -from util_funcs import midRect,SwapAndShow +from util_funcs import midRect,SwapAndShow,SkinMap from config import Battery @@ -25,7 +25,7 @@ from libs.roundrects import aa_round_rect from libs.DBUS import is_wifi_connected_now,wifi_strength -icon_base_path = "gameshell/titlebar_icons/" +icon_base_path = SkinMap("gameshell/titlebar_icons/") class TitleBar: _PosX = 0 _PosY = 0 @@ -179,13 +179,6 @@ class TitleBar: self._CanvasHWND = pygame.Surface((self._Width,self._Height)) self._HWND = screen - icon_snd = IconItem() - icon_snd._MyType = ICON_TYPES["STAT"] - icon_snd._Parent = self - icon_snd._ImageName = icon_base_path+"ic_volume_up_black.png" - icon_snd.Adjust(start_x,self._icon_height/2+(self._BarHeight-self._icon_height)/2,self._icon_width,self._icon_height,0) - icon_snd.ChangeImgSurfColor(self._IconColor) - icon_wifi_status = MultiIconItem() icon_wifi_status._MyType = ICON_TYPES["STAT"] diff --git a/sys.py/UI/util_funcs.py b/sys.py/UI/util_funcs.py index a15d523..eb72203 100644 --- a/sys.py/UI/util_funcs.py +++ b/sys.py/UI/util_funcs.py @@ -11,7 +11,24 @@ import subprocess #from beeprint import pp import string from Xlib import X,display +import config +def SkinMap(orig_file_or_dir): + DefaultSkin = "default" + + if orig_file_or_dir.startswith(".."): + ret = orig_file_or_dir.replace("..","../skin/"+config.SKIN) + if FileExists(ret) == False: + ret = orig_file_or_dir.replace("..","../skin/"+DefaultSkin) + else: + ret = "../skin/"+config.SKIN+"/sys.py/"+orig_file_or_dir + if FileExists(ret) == False: + ret = "../skin/"+DefaultSkin+"/sys.py/"+orig_file_or_dir + + if FileExists( ret ): + return ret + else: ## if not existed both in default or custom skin ,return where it is + return orig_file_or_dir def get_git_revision_hash(): return subprocess.check_output(['git', 'rev-parse', 'HEAD']) diff --git a/sys.py/config.py b/sys.py/config.py index 363b18e..5e40c83 100644 --- a/sys.py/config.py +++ b/sys.py/config.py @@ -12,4 +12,6 @@ MPD_socket = "/tmp/mpd.socket" UPDATE_URL="https://raw.githubusercontent.com/clockworkpi/CPI/master/launcher_ver.json" -VERSION="1.0" +VERSION="stable 1.0" + +SKIN="default" diff --git a/sys.py/gameshell/titlebar_icons/ic_battery_charging_full_black.png b/sys.py/gameshell/titlebar_icons/ic_battery_charging_full_black.png deleted file mode 100644 index 10561e6..0000000 Binary files a/sys.py/gameshell/titlebar_icons/ic_battery_charging_full_black.png and /dev/null differ diff --git a/sys.py/gameshell/titlebar_icons/ic_volume_up_black.png b/sys.py/gameshell/titlebar_icons/ic_volume_up_black.png deleted file mode 100644 index b1a5d34..0000000 Binary files a/sys.py/gameshell/titlebar_icons/ic_volume_up_black.png and /dev/null differ diff --git a/sys.py/run.py b/sys.py/run.py index 05e86bf..00ff168 100644 --- a/sys.py/run.py +++ b/sys.py/run.py @@ -15,6 +15,7 @@ import time import gobject +import socket import pygame from sys import exit import os @@ -29,7 +30,7 @@ else: #local UI import -from UI.constants import Width,Height,bg_color,icon_width,icon_height,DT,GMEVT,RUNEVT,RUNSYS +from UI.constants import Width,Height,bg_color,icon_width,icon_height,DT,GMEVT,RUNEVT,RUNSYS,ICON_TYPES from UI.util_funcs import ReplaceSuffix,FileExists, ReadTheFileContent,midRect,color_surface,SwapAndShow,GetExePath,X_center_mouse from UI.page import PageStack,PageSelector,Page from UI.label import Label @@ -254,6 +255,42 @@ def gobject_pygame_event_timer(main_screen): return True + +@misc.threaded +def socket_thread(main_screen): + socket_path = "/tmp/gameshell" + if os.path.exists(socket_path): + os.remove(socket_path) + + server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + server.bind(socket_path) + while True: + server.listen(1) + conn, addr = server.accept() + datagram = conn.recv(1024) + if datagram: + tokens = datagram.strip().split() + + if tokens[0].lower() == "quit": + conn.close() + on_exit_cb = getattr(main_screen,"OnExitCb",None) + if on_exit_cb != None: + if callable( on_exit_cb ): + main_screen.OnExitCb(None) + + gobject_main_loop.quit() + exit() + + if tokens[0].lower() == "poweroff": + if main_screen._CurrentPage._Name == "GameShell": + for i in main_screen._CurrentPage._Icons: + if i._MyType == ICON_TYPES["FUNC"]: + if i._Label.GetText() == "PowerOFF": + api_cb = getattr(i._CmdPath,"API",None) + if api_cb != None: + if callable(api_cb): + i._CmdPath.API(main_screen) + def big_loop(): global sound_patch @@ -284,6 +321,8 @@ def big_loop(): gobject.timeout_add(DT,gobject_pygame_event_poll_timer,main_screen) gobject.timeout_add(3000,title_bar.GObjectRoundRobin) + + socket_thread(main_screen) gobject_loop() @@ -319,6 +358,7 @@ if __name__ == '__main__': if pygame.image.get_extended() == False: print("This pygame does not support PNG") exit() + big_loop()