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 os
import math import math
import threading
# GTK module ( Graphical interface # GTK module ( Graphical interface
import gi 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 # This function will make animating values over time possible. For smooth
# Transisions and things like this it's going to be very usefull. # 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 # Let's clear mess in case they I'm lazy to make all the things
if v2 == None: if v2 == None:
v2 = v1 v2 = v1
@ -133,6 +136,9 @@ def animate(name, win, v1=0, v2=None, time=10, force=False):
start = win.animations[name][3] start = win.animations[name][3]
frame = win.current["frame"] frame = win.current["frame"]
if time == 0:
return v2
# If animation is over. # If animation is over.
if start + time < frame: if start + time < frame:
return v2 return v2
@ -219,8 +225,8 @@ def image(layer, win ,path, x, y, width=0, height=0, fit="crop"):
win.images[path] = "LOADING-IMAGE" win.images[path] = "LOADING-IMAGE"
if not win.imageload: if win.imageload < 10:
win.imageload = True win.imageload += 1
def loadimage(layer, win ,path, x, y, width, height, fit): def loadimage(layer, win ,path, x, y, width, height, fit):
# Loading the image into the cairo. # 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 # If it's not png it's gonna take few steps
# Let's first of all see if it's a blend file. # 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 path.endswith(".blend") or path.endswith(".blend1"):
IF = os.system("python3 "+os.getcwd()+"/UI/blender-thumbnailer.py "\ 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: 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: else:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"\ load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"\
+win.settings["Theme"]+"/icons/blender.png") +win.settings["Theme"]+"/icons/blender.png")
os.remove("/tmp/vcstudio_blender_thumbnail"+part+".png")
else: else:
# if video # if video
@ -250,12 +263,13 @@ def image(layer, win ,path, x, y, width=0, height=0, fit="crop"):
if video: if video:
IF = os.system("totem-video-thumbnailer -s "+str(width)+" "+path\ IF = os.system("totem-video-thumbnailer -s "+str(width)+" "+path\
+" /tmp/vcstudio_video_thumbnail.png") +" /tmp/vcstudio_video_thumbnail"+part+".png")
if not IF: 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: else:
load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"\ load1 = GdkPixbuf.Pixbuf.new_from_file("settings/themes/"\
+win.settings["Theme"]+"/icons/video.png") +win.settings["Theme"]+"/icons/video.png")
os.remove("/tmp/vcstudio_video_thumbnail"+part+".png")
else: else:
# if image # if image
image = False 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 # Saving it into the win.images
win.images[path] = imagesurface 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 #loading it back
else: else:
@ -408,7 +424,7 @@ def tooltip(win, text):
def scroll_area(layer, win, name, x, y, width, height, maxlength, def scroll_area(layer, win, name, x, y, width, height, maxlength,
bar=False,sideways=False, mmb=False, mmb_only=False, 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 # 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. # 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) : and win.current['my'] in range(y, y+height) :
if not mmb_only: if not mmb_only:
if not sideways: if not sideways:
amount = win.current["scroll"][1]*50 amount = win.current["scroll"][1]*strenght
else: else:
amount = win.current["scroll"][0]*50 amount = win.current["scroll"][0]*strenght
if mmb_only: if mmb_only:
mmb = True mmb = True
@ -529,7 +545,7 @@ def scroll_area(layer, win, name, x, y, width, height, maxlength,
if win.current["LMB"]: if win.current["LMB"]:
if int(win.current['LMB'][0]) in range(int(Lx), int(Lx+LSx)) \ 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") UI_color.set(layer, win, "button_clicked")
@ -685,6 +701,7 @@ def text(outlayer, win, name, x, y, width, height, set_text="", parse=False, fil
if not multiline: #Removing enter key press if not multiline: #Removing enter key press
if 65293 in win.current["keys"] or 65421 in win.current["keys"]: if 65293 in win.current["keys"] or 65421 in win.current["keys"]:
win.current["key_letter"] = "" win.current["key_letter"] = ""
prevlen = len(win.text[name]["text"]) prevlen = len(win.text[name]["text"])
clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)