Embedded xscreensaver demo
This commit is contained in:
parent
b628285521
commit
bf13e3882e
Binary file not shown.
BIN
images/pic5.png
BIN
images/pic5.png
Binary file not shown.
Before Width: | Height: | Size: 944 KiB After Width: | Height: | Size: 668 KiB |
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os, cairo, sys, gi, re, threading, subprocess, hashlib
|
||||
import os, cairo, sys, gi, re, threading, subprocess, hashlib, signal, time
|
||||
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('Gdk', '3.0')
|
||||
|
@ -20,25 +20,16 @@ class GWinWrap:
|
|||
def __init__(self):
|
||||
self.builder = gtk.Builder()
|
||||
self.builder.add_from_file("resources/GWinWrap.glade")
|
||||
self.builder.connect_signals(self)
|
||||
|
||||
# Get window and connect signals
|
||||
self.window = self.builder.get_object("Main")
|
||||
self.builder.connect_signals(self)
|
||||
self.window.connect("delete-event", gtk.main_quit)
|
||||
self.screen = self.window.get_screen()
|
||||
self.visual = self.screen.get_rgba_visual()
|
||||
if self.visual != None and self.screen.is_composited():
|
||||
self.window.set_visual(self.visual)
|
||||
self.stateSaver = SaveStateToXWinWarp()
|
||||
self.sttngsSver = SaveGWinWrapSettings()
|
||||
window = self.builder.get_object("Main")
|
||||
monitors = self.setWindowData(window)
|
||||
window.connect("delete-event", gtk.main_quit)
|
||||
|
||||
self.window.set_app_paintable(True)
|
||||
self.window.connect("draw", self.area_draw)
|
||||
|
||||
# bind css file
|
||||
cssProvider = gtk.CssProvider()
|
||||
cssProvider.load_from_path('resources/stylesheet.css')
|
||||
screen = gdk.Screen.get_default()
|
||||
styleContext = gtk.StyleContext()
|
||||
styleContext.add_provider_for_screen(screen, cssProvider, gtk.STYLE_PROVIDER_PRIORITY_USER)
|
||||
print(monitors[1])
|
||||
|
||||
# Add filter to allow only folders to be selected
|
||||
dialog = self.builder.get_object("selectedDirDialog")
|
||||
|
@ -48,9 +39,6 @@ class GWinWrap:
|
|||
# Get reference to remove and add it back...
|
||||
self.gridLabel = self.builder.get_object("gridLabel")
|
||||
|
||||
self.stateSaver = SaveStateToXWinWarp()
|
||||
self.sttngsSver = SaveGWinWrapSettings()
|
||||
|
||||
self.focusedImg = gtk.Image()
|
||||
self.usrHome = os.path.expanduser('~')
|
||||
self.xScreenVal = None
|
||||
|
@ -80,10 +68,28 @@ class GWinWrap:
|
|||
self.defPath = None
|
||||
self.player = None
|
||||
self.imgVwr = None
|
||||
self.xScrnDemoPid = None
|
||||
|
||||
self.retrieveSettings()
|
||||
self.window.show()
|
||||
window.show()
|
||||
|
||||
def setWindowData(self, window):
|
||||
screen = window.get_screen()
|
||||
visual = screen.get_rgba_visual()
|
||||
if visual != None and screen.is_composited():
|
||||
window.set_visual(visual)
|
||||
|
||||
window.set_app_paintable(True)
|
||||
window.connect("draw", self.area_draw)
|
||||
|
||||
# bind css file
|
||||
cssProvider = gtk.CssProvider()
|
||||
cssProvider.load_from_path('resources/stylesheet.css')
|
||||
screen = gdk.Screen.get_default()
|
||||
styleContext = gtk.StyleContext()
|
||||
styleContext.add_provider_for_screen(screen, cssProvider, gtk.STYLE_PROVIDER_PRIORITY_USER)
|
||||
|
||||
return self.getMonitorData(screen)
|
||||
|
||||
def area_draw(self, widget, cr):
|
||||
cr.set_source_rgba(0, 0, 0, 0.64)
|
||||
|
@ -91,7 +97,18 @@ class GWinWrap:
|
|||
cr.paint()
|
||||
cr.set_operator(cairo.OPERATOR_OVER)
|
||||
|
||||
def getMonitorData(self, screen):
|
||||
monitors = []
|
||||
wxhxny = []
|
||||
|
||||
for m in range(screen.get_n_monitors()):
|
||||
monitors.append(screen.get_monitor_geometry(m))
|
||||
|
||||
wxhxny.append(monitors)
|
||||
for monitor in monitors:
|
||||
wxhxny.append(str(monitor.width) + "x" + str(monitor.height) + "+" + str(monitor.x) + "+" + str(monitor.y))
|
||||
|
||||
return wxhxny
|
||||
|
||||
|
||||
def setNewDir(self, widget, data=None):
|
||||
|
@ -125,7 +142,7 @@ class GWinWrap:
|
|||
if file.lower().endswith(('.mkv', '.avi', '.flv', '.mov', '.m4v', '.mpg', '.wmv', '.mpeg', '.mp4', '.webm')):
|
||||
fileHash = hashlib.sha256(str.encode(fullPathFile)).hexdigest()
|
||||
hashImgpth = self.usrHome + "/.thumbnails/normal/" + fileHash + ".png"
|
||||
if os.path.isfile(hashImgpth) == False:
|
||||
if isfile(hashImgpth) == False:
|
||||
self.generateThumbnail(fullPathFile, hashImgpth)
|
||||
|
||||
thumbnl = self.createGtkImage(hashImgpth, [310, 310])
|
||||
|
@ -219,11 +236,11 @@ class GWinWrap:
|
|||
|
||||
def mouseOver(self, widget, eve, args):
|
||||
hand_cursor = gdk.Cursor(gdk.CursorType.HAND2)
|
||||
self.window.get_window().set_cursor(hand_cursor)
|
||||
self.builder.get_object("Main").get_window().set_cursor(hand_cursor)
|
||||
|
||||
def mouseOut(self, widget, eve, args):
|
||||
watch_cursor = gdk.Cursor(gdk.CursorType.LEFT_PTR)
|
||||
self.window.get_window().set_cursor(watch_cursor)
|
||||
self.builder.get_object("Main").get_window().set_cursor(watch_cursor)
|
||||
|
||||
def toggleXscreenUsageField(self, widget, data=None):
|
||||
useXscreenSaver = self.builder.get_object("useXScrnList")
|
||||
|
@ -291,8 +308,30 @@ class GWinWrap:
|
|||
|
||||
def previewXscreen(self, widget, eve):
|
||||
if eve.type == gdk.EventType.DOUBLE_BUTTON_PRESS:
|
||||
preview = self.xscrPth + "/" + self.xScreenVal + "&"
|
||||
os.system(preview)
|
||||
# Must be actualized before getting window
|
||||
demoWindow = self.builder.get_object("xScrnPreviewPopWindow")
|
||||
self.helpLabel.set_markup("<span foreground=\"#e0cc64\"></span>")
|
||||
|
||||
if self.xScrnDemoPid:
|
||||
os.kill(self.xScrnDemoPid, signal.SIGTERM) #or signal.SIGKILL
|
||||
self.xScrnDemoPid = None
|
||||
|
||||
if demoWindow.get_visible() == False:
|
||||
demoWindow.show_all()
|
||||
demoWindow.popup()
|
||||
|
||||
time.sleep(.800) # 800 mili-seconds to ensure first process dead
|
||||
xScreenPreview = self.builder.get_object("xScreenPreview")
|
||||
demoXscrnSaver = self.xscrPth + self.xScreenVal
|
||||
window = xScreenPreview.get_window()
|
||||
xid = window.get_xid()
|
||||
process = subprocess.Popen([demoXscrnSaver, "-window-id", str(xid)])
|
||||
self.xScrnDemoPid = process.pid
|
||||
|
||||
def closeDemoWindow(self, widget, data=None):
|
||||
self.builder.get_object("xScrnPreviewPopWindow").popdown()
|
||||
os.kill(self.xScrnDemoPid, signal.SIGTERM) #or signal.SIGKILL
|
||||
self.xScrnDemoPid = None
|
||||
|
||||
def clearSelection(self, widget, data=None):
|
||||
self.clear()
|
||||
|
|
|
@ -115,12 +115,10 @@
|
|||
<object class="GtkFileChooserButton" id="selectedDirDialog">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="focus_on_click">False</property>
|
||||
<property name="tooltip_text" translatable="yes">Chose Dream Scene / Image Directory</property>
|
||||
<property name="action">select-folder</property>
|
||||
<property name="create_folders">False</property>
|
||||
<property name="filter">Folders</property>
|
||||
<property name="preview_widget_active">False</property>
|
||||
<property name="title" translatable="yes">Dream Scene / Image Dir</property>
|
||||
<signal name="file-set" handler="setNewDir" swapped="no"/>
|
||||
</object>
|
||||
|
@ -629,7 +627,6 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="image">closePopupImage</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="closePopup" swapped="no"/>
|
||||
</object>
|
||||
|
@ -817,4 +814,69 @@
|
|||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkPopover" id="xScrnPreviewPopWindow">
|
||||
<property name="width_request">640</property>
|
||||
<property name="height_request">525</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_right">350</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="relative_to">helpLabel</property>
|
||||
<property name="position">bottom</property>
|
||||
<property name="modal">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Close XScreenSaver Demo Window</property>
|
||||
<property name="image">closePopupImage</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="closeDemoWindow" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkAspectFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">none</property>
|
||||
<child>
|
||||
<object class="GtkDrawingArea" id="xScreenPreview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os, cairo, sys, gi, re, threading, subprocess, hashlib
|
||||
import os, cairo, sys, gi, re, threading, subprocess, hashlib, signal, time
|
||||
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('Gdk', '3.0')
|
||||
|
@ -68,6 +68,7 @@ class GWinWrap:
|
|||
self.defPath = None
|
||||
self.player = None
|
||||
self.imgVwr = None
|
||||
self.xScrnDemoPid = None
|
||||
|
||||
self.retrieveSettings()
|
||||
window.show()
|
||||
|
@ -307,8 +308,30 @@ class GWinWrap:
|
|||
|
||||
def previewXscreen(self, widget, eve):
|
||||
if eve.type == gdk.EventType.DOUBLE_BUTTON_PRESS:
|
||||
preview = self.xscrPth + "/" + self.xScreenVal + "&"
|
||||
os.system(preview)
|
||||
# Must be actualized before getting window
|
||||
demoWindow = self.builder.get_object("xScrnPreviewPopWindow")
|
||||
self.helpLabel.set_markup("<span foreground=\"#e0cc64\"></span>")
|
||||
|
||||
if self.xScrnDemoPid:
|
||||
os.kill(self.xScrnDemoPid, signal.SIGTERM) #or signal.SIGKILL
|
||||
self.xScrnDemoPid = None
|
||||
|
||||
if demoWindow.get_visible() == False:
|
||||
demoWindow.show_all()
|
||||
demoWindow.popup()
|
||||
|
||||
time.sleep(.800) # 800 mili-seconds to ensure first process dead
|
||||
xScreenPreview = self.builder.get_object("xScreenPreview")
|
||||
demoXscrnSaver = self.xscrPth + self.xScreenVal
|
||||
window = xScreenPreview.get_window()
|
||||
xid = window.get_xid()
|
||||
process = subprocess.Popen([demoXscrnSaver, "-window-id", str(xid)])
|
||||
self.xScrnDemoPid = process.pid
|
||||
|
||||
def closeDemoWindow(self, widget, data=None):
|
||||
self.builder.get_object("xScrnPreviewPopWindow").popdown()
|
||||
os.kill(self.xScrnDemoPid, signal.SIGTERM) #or signal.SIGKILL
|
||||
self.xScrnDemoPid = None
|
||||
|
||||
def clearSelection(self, widget, data=None):
|
||||
self.clear()
|
||||
|
|
|
@ -627,7 +627,6 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="image">closePopupImage</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="closePopup" swapped="no"/>
|
||||
</object>
|
||||
|
@ -815,4 +814,69 @@
|
|||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkPopover" id="xScrnPreviewPopWindow">
|
||||
<property name="width_request">640</property>
|
||||
<property name="height_request">525</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_right">350</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="relative_to">helpLabel</property>
|
||||
<property name="position">bottom</property>
|
||||
<property name="modal">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="tooltip_text" translatable="yes">Close XScreenSaver Demo Window</property>
|
||||
<property name="image">closePopupImage</property>
|
||||
<property name="always_show_image">True</property>
|
||||
<signal name="clicked" handler="closeDemoWindow" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkAspectFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">none</property>
|
||||
<child>
|
||||
<object class="GtkDrawingArea" id="xScreenPreview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue