Upload files to 'UI'

This commit is contained in:
Jeison Yehuda Amihud (Blender Dumbass) 2020-12-09 02:31:21 +00:00
parent dd639270d5
commit 07cf222227

View file

@ -5,6 +5,7 @@
import os
import math
import threading
# GTK module ( Graphical interface
import gi
@ -113,6 +114,8 @@ def animate(name, win, v1=0, v2=None, time=10, force=False):
# This function will make animating values over time possible. For smooth
# Transisions and things like this it's going to be very usefull.
# Let's clear mess in case they I'm lazy to make all the things
if v2 == None:
v2 = v1
@ -133,6 +136,9 @@ def animate(name, win, v1=0, v2=None, time=10, force=False):
start = win.animations[name][3]
frame = win.current["frame"]
if time == 0:
return v2
# If animation is over.
if start + time < frame:
return v2
@ -219,8 +225,8 @@ def image(layer, win ,path, x, y, width=0, height=0, fit="crop"):
win.images[path] = "LOADING-IMAGE"
if not win.imageload:
win.imageload = True
if win.imageload < 10:
win.imageload += 1
def loadimage(layer, win ,path, x, y, width, height, fit):
# Loading the image into the cairo.
@ -232,14 +238,21 @@ def image(layer, win ,path, x, y, width=0, height=0, fit="crop"):
# If it's not png it's gonna take few steps
# Let's first of all see if it's a blend file.
part = path.replace("/", "_").replace(" ", "_")
if path.endswith(".blend") or path.endswith(".blend1"):
IF = os.system("python3 "+os.getcwd()+"/UI/blender-thumbnailer.py "\
+path+" /tmp/vcstudio_blender_thumbnail.png")
+path+" /tmp/vcstudio_blender_thumbnail"+part+".png")
if not IF:
load1 = GdkPixbuf.Pixbuf.new_from_file("/tmp/vcstudio_blender_thumbnail.png")
load1 = GdkPixbuf.Pixbuf.new_from_file("/tmp/vcstudio_blender_thumbnail"+part+".png")
else:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"\
+win.settings["Theme"]+"/icons/blender.png")
os.remove("/tmp/vcstudio_blender_thumbnail"+part+".png")
else:
# if video
@ -250,12 +263,13 @@ def image(layer, win ,path, x, y, width=0, height=0, fit="crop"):
if video:
IF = os.system("totem-video-thumbnailer -s "+str(width)+" "+path\
+" /tmp/vcstudio_video_thumbnail.png")
+" /tmp/vcstudio_video_thumbnail"+part+".png")
if not IF:
load1 = GdkPixbuf.Pixbuf.new_from_file("/tmp/vcstudio_video_thumbnail.png")
load1 = GdkPixbuf.Pixbuf.new_from_file("/tmp/vcstudio_video_thumbnail"+part+".png")
else:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"\
+win.settings["Theme"]+"/icons/video.png")
os.remove("/tmp/vcstudio_video_thumbnail"+part+".png")
else:
# if image
image = False
@ -333,9 +347,11 @@ def image(layer, win ,path, x, y, width=0, height=0, fit="crop"):
# Saving it into the win.images
win.images[path] = imagesurface
win.imageload = False
win.imageload -= 1
GLib.timeout_add(1, loadimage, layer, win ,path, x, y, width, height, fit)
#GLib.timeout_add(1, loadimage, layer, win ,path, x, y, width, height, fit)
t = threading.Thread(target=loadimage, args=(layer, win ,path, x, y, width, height, fit))
t.start()
#loading it back
else:
@ -408,7 +424,7 @@ def tooltip(win, text):
def scroll_area(layer, win, name, x, y, width, height, maxlength,
bar=False,sideways=False, mmb=False, mmb_only=False,
url=""):
url="", strenght=50):
# This function going to handle all the scrolling windows. Making it so it's
# relativelly simple to set up big widgets with in small areas.
@ -431,9 +447,9 @@ def scroll_area(layer, win, name, x, y, width, height, maxlength,
and win.current['my'] in range(y, y+height) :
if not mmb_only:
if not sideways:
amount = win.current["scroll"][1]*50
amount = win.current["scroll"][1]*strenght
else:
amount = win.current["scroll"][0]*50
amount = win.current["scroll"][0]*strenght
if mmb_only:
mmb = True
@ -529,7 +545,7 @@ def scroll_area(layer, win, name, x, y, width, height, maxlength,
if win.current["LMB"]:
if int(win.current['LMB'][0]) in range(int(Lx), int(Lx+LSx)) \
and int(win.current['LMB'][1]) in range(int(Ly), int(Lx+(height-60))) :
and int(win.current['LMB'][1]) in range(int(y), int(y+(height-60))) :
UI_color.set(layer, win, "button_clicked")
@ -686,6 +702,7 @@ def text(outlayer, win, name, x, y, width, height, set_text="", parse=False, fil
if 65293 in win.current["keys"] or 65421 in win.current["keys"]:
win.current["key_letter"] = ""
prevlen = len(win.text[name]["text"])
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
regularclean = True