Blender-Pipeline/project_manager/pm_updateLayer.py
Jeison Yehuda Amihud (Blender Dumbass) c4df06615d Updater Now Can Re-Install the Full VCStudio
I made some mistakes in the names of the Versions. For the updater.
And so I need a way to fix it. So users could install the updates regardless
of their version. I think I'm going to push a silent update for this. And
change the names of the versions. So users could click update all for the
next one. Or something like this. I don't know. Wait. Let's give users a
day or two. I gonna update with the wrong names this time. Fully
documented. Then update the number. So 21.1 will be 21.01 which is
the more reasonable name. LOL. Anyways. Here is this. LOL.
2021-01-11 19:07:16 +00:00

277 lines
7.8 KiB
Python

# THIS FILE IS A PART OF VCStudio
# PYTHON 3
import os
# GTK module ( Graphical interface
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GLib
from gi.repository import Gdk
import cairo
# Own modules
from settings import settings
from settings import talk
from settings import oscalls
from project_manager import pm_project
#UI modules
from UI import UI_elements
from UI import UI_color
def layer(win):
# Making the layer
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, win.current['w'],
win.current['h'])
layer = cairo.Context(surface)
print("NEW FILES:", win.update["get_files"])
print("ALL FILES:", win.update["get_all_files"])
#text setting
layer.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
UI_color.set(layer, win, "dark_overdrop")
layer.rectangle(
0,
0,
win.current["w"],
win.current["h"],
)
layer.fill()
# So it's going to be like a little window in the center of the VCStudio
# with a simple UI. Probably like 2 things. Folder and a projectname.
UI_color.set(layer, win, "node_background")
UI_elements.roundrect(layer, win,
win.current["w"]/2-250,
100,
500,
win.current["h"]-200,
10)
# Exit button
def do():
win.url = "project_manager"
win.textactive = ""
UI_elements.roundrect(layer, win,
win.current["w"]/2+210,
win.current["h"]-140,
40,
40,
10,
button=do,
icon="cancel",
tip=talk.text("cancel"))
# Setting to get all files. Sometimes you need a way to restore the entire
# program. Or sometimes I make mistakes. And want give myself and others a
# simple way to refresh the system. So here I gonna make a button that will
# tell the updater to ignore the update version and download the whole
# package. All 300 something files. ( It's 2021/01 at the time. )
# Also not so long ago I made Version naming mistakes. So some kind of way
# to download versions should exist. Here we go.
if "Update_all" not in win.settings:
win.settings["Update_all"] = False
settings.write("Update_all", False)
if win.settings["Update_all"]:
ic = "checked"
else:
ic = "unchecked"
def do():
win.settings["Update_all"] = not win.settings["Update_all"]
settings.write("Update_all", win.settings["Update_all"])
UI_elements.roundrect(layer, win,
win.current["w"]/2-250,
win.current["h"]-140,
420,
40,
10,
button=do,
icon=ic,
tip=talk.text("update_all_tooltip"))
UI_color.set(layer, win, "text_normal")
layer.set_font_size(15)
layer.move_to(
win.current["w"]/2-200,
win.current["h"]-115)
layer.show_text(talk.text("update_all")+" "+str(len(win.update["get_all_files"]))+" "+talk.text("files"))
# Install Updates button
try:
if win.update["count"] or win.settings["Update_all"]:
def do():
win.url = "install_updates"
win.update["frame"] = win.current["frame"]
UI_elements.roundrect(layer, win,
win.current["w"]/2+170,
win.current["h"]-140,
40,
40,
10,
button=do,
icon="ok",
tip=talk.text("update_install"))
except:
pass
# Clipping everything
UI_elements.roundrect(layer, win,
win.current["w"]/2-250,
100,
500,
win.current["h"]-260,
10,
fill=False)
layer.clip()
clip = [
win.current["w"]/2-250,
100,
500,
win.current["h"]-260]
# Setting up the scroll
if "pm_update" not in win.scroll:
win.scroll["pm_update"] = 0
current_Y = 0 # The max scroll value
for version in win.update["versions"]:
is_open = win.update["versions"][version]["open"]
files = win.update["versions"][version]["files"]
link = win.update["versions"][version]["link"]
if version == win.version:
UI_color.set(layer, win, "node_imagefile")
sufix = talk.text("update_current")
elif version < win.version:
UI_color.set(layer, win, "node_badfile")
sufix = talk.text("update_previous")
elif version > win.version:
UI_color.set(layer, win, "node_blendfile")
sufix = talk.text("update_available")
UI_elements.roundrect(layer, win,
win.current["w"]/2-240,
110 + current_Y + win.scroll["pm_update"],
450,
40,
10)
UI_color.set(layer, win, "text_normal")
layer.set_font_size(20)
layer.move_to(win.current["w"]/2-180,
current_Y + win.scroll["pm_update"] + 140)
layer.show_text(str(version)+" "+sufix)
def do():
oscalls.Open(link)
UI_elements.roundrect(layer, win,
win.current["w"]/2-200,
110 + current_Y + win.scroll["pm_update"],
410,
40,
10,
button=do,
tip=talk.text("update_read_version_notes"),
fill=False,
clip=clip)
layer.stroke()
# Open and Close button. A little side triangle thingy.
if is_open:
icon = "open"
expandcall = talk.text("Compress")
else:
icon = "closed"
expandcall = talk.text("Expand")
def do():
win.update["versions"][version]["open"] = not is_open
UI_elements.roundrect(layer, win,
win.current["w"]/2-240,
110 + current_Y + win.scroll["pm_update"],
40,
40,
10,
button=do,
icon=icon,
tip=expandcall,
clip=clip)
current_Y = current_Y + 50
if is_open:
for filename in files:
UI_color.set(layer, win, "button_active")
layer.move_to(win.current["w"]/2-227, 102 + current_Y + win.scroll["pm_update"])
layer.line_to(win.current["w"]/2-227, 152 + current_Y + win.scroll["pm_update"])
layer.stroke()
UI_color.set(layer, win, "text_normal")
layer.set_font_size(15)
layer.move_to(win.current["w"]/2-210,
current_Y + win.scroll["pm_update"] + 140)
layer.show_text(str(filename))
def do():
gitlink = "https://notabug.org/jyamihud/VCStudio/commits/master/"
oscalls.Open(gitlink+filename)
UI_elements.roundrect(layer, win,
win.current["w"]/2-220,
110 + current_Y + win.scroll["pm_update"],
430,
40,
10,
button=do,
tip=talk.text("update_see_history"),
fill=False,
clip=clip)
layer.stroke()
current_Y = current_Y + 50
UI_elements.scroll_area(layer, win, "pm_update",
int(win.current["w"]/2-250),
100,
500,
win.current["h"]-260,
current_Y,
bar=True,
mmb=True,
url="update_layer"
)
return surface