add socket server thread to receive remote call,and try add skin design on it
@ -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)
|
||||
|
||||
|
||||
@ -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()
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
|
Before Width: | Height: | Size: 198 B |
@ -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()
|
||||
@ -17,7 +17,6 @@ from UI.util_funcs import midRect
|
||||
# ------------------------
|
||||
|
||||
import myvars # icons_path
|
||||
from icons import preload
|
||||
|
||||
class ListItemIcon(IconItem):
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 306 B After Width: | Height: | Size: 306 B |
|
Before Width: | Height: | Size: 294 B After Width: | Height: | Size: 294 B |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 198 B After Width: | Height: | Size: 198 B |
|
Before Width: | Height: | Size: 875 B After Width: | Height: | Size: 875 B |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 9.1 KiB After Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 335 B After Width: | Height: | Size: 335 B |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 545 B After Width: | Height: | Size: 545 B |
|
Before Width: | Height: | Size: 286 B After Width: | Height: | Size: 286 B |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 427 B After Width: | Height: | Size: 427 B |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 316 B |
|
Before Width: | Height: | Size: 601 B After Width: | Height: | Size: 601 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 673 B After Width: | Height: | Size: 673 B |
|
Before Width: | Height: | Size: 627 B After Width: | Height: | Size: 627 B |
1
sys.py/UI/.#page.py
Symbolic link
@ -0,0 +1 @@
|
||||
guu@guu-desktop.5528:1527716105
|
||||
@ -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)
|
||||
|
||||
@ -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):
|
||||
|
||||
|
||||
@ -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= {}
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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"]
|
||||
|
||||
@ -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'])
|
||||
|
||||
@ -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"
|
||||
|
||||
|
Before Width: | Height: | Size: 334 B |
|
Before Width: | Height: | Size: 353 B |
@ -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()
|
||||
|
||||
|
||||