Browse Source

config file fix for symlinked exe

master
Stefan Naumann 5 months ago
parent
commit
4a11a3fb38
  1. 17
      src/gtplay.py
  2. 35
      src/mainWindow.py

17
src/gtplay.py

@ -1,3 +1,5 @@
#!/usr/bin/python3
## @package gtplay
# main-package
@ -16,6 +18,13 @@ import args
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
def filenameFromLink ( file ):
x = [ os.path.realpath(__file__), os.path.dirname ( os.path.realpath(__file__) ), os.path.dirname(os.path.dirname ( os.path.realpath(__file__) )) ]
for xi in x:
path = os.path.join ( xi, file )
if os.path.isfile ( path ):
return path
# parse command line arguments
arguments = args.parseArguments ( sys.argv )
@ -49,16 +58,18 @@ except:
if 1:
print ( arguments.strLogo() )
try:
cfg = config.Config.fromFile ( os.path.dirname(__file__) + "/../" + arguments.config_file );
cfg = config.Config.fromFile ( filenameFromLink ( arguments.config_file ))
except:
cfg = config.Config();
cfg._file = os.path.dirname(__file__) + "/../" + arguments.config_file;
cfg._file = filenameFromLink ( arguments.config_file )
print("No Config File found, resuming with defaults")
cfg.PlayerModeArgs ( arguments );
# create playlist and main window
print ( __file__ );
pl = Playlist ( videolist )
gladefile = os.path.dirname(__file__) + "/../data/gtplay.glade"
gladefile = filenameFromLink ( "data/gtplay.glade" )
hwnd = MainWindow ( gladefile, pl, s, cfg )
hwnd.show()

35
src/mainWindow.py

@ -5,6 +5,8 @@ import socket
import time
import re
import json
from subprocess import *
import gi
@ -51,12 +53,14 @@ class MainWindow ( object ):
self.showPlaylist = True;
## width of the playlist-view panel, last time it was closed
self.paneState = -150;
self.title = "GTPlay"
# set destructor, when the window closes and window title
self.window = self.builder.get_object ( "gtplayer" );
self.window.connect ( "destroy", self.destroy );
self.window.connect ( "window-state-event", self.WindowStateTrigger );
self.window.set_title ("GTPlay");
self.window.set_title ( self.title );
# set callbacks for buttons, dials, switches and toggles
va=self.builder.get_object ( "videoArea" )
@ -162,7 +166,8 @@ class MainWindow ( object ):
x = self.playlist.current().url;
window = self.builder.get_object ( "gtplayer" );
window.set_title(x + " | GTPlay");
self.title = x + " | GTPlay";
window.set_title( self.title );
def WindowStateTrigger( self, widget, event, data=None ):
#print (" ---- Window State event")
@ -391,7 +396,33 @@ class MainWindow ( object ):
#if ( self.player != None ):
# self.player.updatePosition(self.getWindowSpace());
def getWindowSpaceSwayInternal ( self, tree, name ):
for t in tree["nodes"]:
if t["name"] == name:
return t["rect"];
if "nodes" in t:
rect = self.getWindowSpaceSwayInternal ( t, name );
if rect != None:
return rect;
return None;
def getWindowSpaceSway ( self ):
p = Popen ( ['swaymsg', '-t', "get_tree" ], stdout=PIPE)
hwnd = p.communicate()[0]
hwnd = hwnd.decode ( "utf-8" )
tree = json.loads ( hwnd );
rect = self.getWindowSpaceSwayInternal ( tree, self.title );
print ( rect )
if rect == None:
return { "x": 0, "y": 0, "width": 1280, "height": 720 }
return rect;
def getWindowSpace ( self ):
return self.getWindowSpaceSway()
p = Popen ( ['xwininfo', '-id', str(self.window.get_window().get_xid()) ], stdout=PIPE)
hwnd = p.communicate()[0]

Loading…
Cancel
Save