2021-06-15 19:07:52 +02:00
|
|
|
####################################
|
|
|
|
# #
|
|
|
|
# COPYRIGHT NOTICE #
|
|
|
|
# #
|
|
|
|
# This file is a part of Victori- #
|
|
|
|
# ous Children Studio Organizer. #
|
|
|
|
# Or simply VCStudio. Copyright #
|
|
|
|
# of J.Y.Amihud. But don't be sad #
|
|
|
|
# because I released the entire #
|
|
|
|
# project under a GNU GPL license. #
|
|
|
|
# You may use Version 3 or later. #
|
|
|
|
# See www.gnu.org/licenses if your #
|
|
|
|
# copy has no License file. Please #
|
|
|
|
# note. Ones I used the GPL v2 for #
|
|
|
|
# it. It's no longer the case. #
|
|
|
|
# #
|
|
|
|
####################################
|
2020-11-26 16:50:17 +01:00
|
|
|
|
|
|
|
import os
|
2021-06-15 19:07:52 +02:00
|
|
|
import urllib3
|
2020-11-26 16:50:17 +01:00
|
|
|
|
|
|
|
# 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
|
2020-12-11 18:16:55 +01:00
|
|
|
from settings import oscalls
|
2020-11-26 16:50:17 +01:00
|
|
|
from project_manager import pm_project
|
2021-06-14 18:12:52 +02:00
|
|
|
from project_manager import update_reader
|
2020-11-26 16:50:17 +01:00
|
|
|
|
|
|
|
#UI modules
|
|
|
|
from UI import UI_elements
|
|
|
|
from UI import UI_color
|
2021-06-15 19:07:52 +02:00
|
|
|
from UI import UI_Markdown
|
2020-11-26 16:50:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
def layer(win):
|
2021-06-14 18:12:52 +02:00
|
|
|
|
|
|
|
# Sometimes the user didn't want the software to check for updates automatically.
|
|
|
|
# In this case we want to check for updates when he click on the update button.
|
|
|
|
|
|
|
|
if not win.settings["check-for-updates"]:
|
|
|
|
GLib.timeout_add(1 , update_reader.get_update_info, win)
|
2020-11-26 16:50:17 +01:00
|
|
|
|
|
|
|
# Making the layer
|
|
|
|
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, win.current['w'],
|
|
|
|
win.current['h'])
|
|
|
|
layer = cairo.Context(surface)
|
|
|
|
|
|
|
|
|
|
|
|
#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()
|
|
|
|
|
2021-06-15 19:07:52 +02:00
|
|
|
# This is the Markdown UI object.
|
|
|
|
|
|
|
|
UI_Markdown.draw(layer, win, "update_markdown",
|
|
|
|
20,
|
|
|
|
100,
|
|
|
|
win.current["w"]-40,
|
|
|
|
win.current["h"]-200)
|
2020-11-26 16:50:17 +01:00
|
|
|
|
|
|
|
UI_color.set(layer, win, "node_background")
|
|
|
|
UI_elements.roundrect(layer, win,
|
2021-06-15 19:07:52 +02:00
|
|
|
50,
|
|
|
|
win.current["h"]-80,
|
|
|
|
win.current["w"]-100,
|
|
|
|
50,
|
2020-11-26 16:50:17 +01:00
|
|
|
10)
|
|
|
|
|
|
|
|
# Exit button
|
|
|
|
def do():
|
|
|
|
win.url = "project_manager"
|
|
|
|
win.textactive = ""
|
2021-06-15 19:07:52 +02:00
|
|
|
|
2020-11-26 16:50:17 +01:00
|
|
|
UI_elements.roundrect(layer, win,
|
2021-06-15 19:07:52 +02:00
|
|
|
55,
|
|
|
|
win.current["h"]-75,
|
2020-11-26 16:50:17 +01:00
|
|
|
40,
|
|
|
|
40,
|
|
|
|
10,
|
|
|
|
button=do,
|
|
|
|
icon="cancel",
|
|
|
|
tip=talk.text("cancel"))
|
2021-06-15 19:07:52 +02:00
|
|
|
|
2021-01-11 20:07:16 +01:00
|
|
|
# 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,
|
2021-06-15 19:07:52 +02:00
|
|
|
110,
|
|
|
|
win.current["h"]-75,
|
|
|
|
250,
|
2021-01-11 20:07:16 +01:00
|
|
|
40,
|
|
|
|
10,
|
|
|
|
button=do,
|
|
|
|
icon=ic,
|
|
|
|
tip=talk.text("update_all_tooltip"))
|
2021-06-15 19:07:52 +02:00
|
|
|
|
2021-01-11 20:07:16 +01:00
|
|
|
UI_color.set(layer, win, "text_normal")
|
|
|
|
layer.set_font_size(15)
|
|
|
|
layer.move_to(
|
2021-06-15 19:07:52 +02:00
|
|
|
150,
|
|
|
|
win.current["h"]-50)
|
2021-01-11 20:07:16 +01:00
|
|
|
layer.show_text(talk.text("update_all")+" "+str(len(win.update["get_all_files"]))+" "+talk.text("files"))
|
2021-06-15 19:07:52 +02:00
|
|
|
|
2020-11-26 16:50:17 +01:00
|
|
|
# Install Updates button
|
|
|
|
try:
|
2021-01-11 20:07:16 +01:00
|
|
|
if win.update["count"] or win.settings["Update_all"]:
|
2020-11-26 16:50:17 +01:00
|
|
|
def do():
|
|
|
|
win.url = "install_updates"
|
|
|
|
win.update["frame"] = win.current["frame"]
|
|
|
|
|
|
|
|
|
|
|
|
UI_elements.roundrect(layer, win,
|
2021-06-15 19:07:52 +02:00
|
|
|
win.current["w"]-100,
|
|
|
|
win.current["h"]-75,
|
2020-11-26 16:50:17 +01:00
|
|
|
40,
|
|
|
|
40,
|
|
|
|
10,
|
|
|
|
button=do,
|
|
|
|
icon="ok",
|
|
|
|
tip=talk.text("update_install"))
|
|
|
|
except:
|
2021-06-15 19:07:52 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
# At the top of the Update window there is a selector bar to
|
|
|
|
# select various versions. They will load the page into the
|
|
|
|
# little browser below.
|
|
|
|
|
|
|
|
# For this wee need to clip it.
|
|
|
|
|
2020-11-26 16:50:17 +01:00
|
|
|
# Clipping everything
|
|
|
|
UI_elements.roundrect(layer, win,
|
2021-06-15 19:07:52 +02:00
|
|
|
50,
|
|
|
|
20,
|
|
|
|
win.current["w"]-100,
|
|
|
|
80,
|
2020-11-26 16:50:17 +01:00
|
|
|
10,
|
|
|
|
fill=False)
|
|
|
|
layer.clip()
|
|
|
|
|
|
|
|
clip = [
|
2021-06-15 19:07:52 +02:00
|
|
|
50,
|
|
|
|
20,
|
|
|
|
win.current["w"]-100,
|
|
|
|
80]
|
2020-11-26 16:50:17 +01:00
|
|
|
|
|
|
|
# Setting up the scroll
|
|
|
|
if "pm_update" not in win.scroll:
|
|
|
|
win.scroll["pm_update"] = 0
|
|
|
|
|
2021-06-15 19:07:52 +02:00
|
|
|
current_X = 0 # The max scroll value
|
|
|
|
|
2020-11-26 16:50:17 +01:00
|
|
|
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"]
|
|
|
|
|
2021-06-15 19:07:52 +02:00
|
|
|
|
|
|
|
|
2020-11-26 16:50:17 +01:00
|
|
|
|
|
|
|
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,
|
2021-06-15 19:07:52 +02:00
|
|
|
current_X + 50 + win.scroll["pm_update"],
|
|
|
|
20,
|
|
|
|
300,
|
2020-11-26 16:50:17 +01:00
|
|
|
40,
|
|
|
|
10)
|
|
|
|
|
|
|
|
UI_color.set(layer, win, "text_normal")
|
|
|
|
layer.set_font_size(20)
|
2021-06-15 19:07:52 +02:00
|
|
|
layer.move_to(current_X + 60 + win.scroll["pm_update"],
|
|
|
|
45)
|
2020-11-26 16:50:17 +01:00
|
|
|
layer.show_text(str(version)+" "+sufix)
|
|
|
|
|
|
|
|
def do():
|
2021-06-15 19:07:52 +02:00
|
|
|
|
|
|
|
# We gonna attempt at previewing the update information in the window
|
|
|
|
# and only if it's not going to work, we gonna launch the browser with
|
|
|
|
# the link. Or do some weird. Like giving a generated page about the
|
|
|
|
# stuff.
|
|
|
|
|
|
|
|
openlink = "wiki/updates/"+str(version)+".md"
|
|
|
|
|
|
|
|
if not os.path.exists(os.getcwd()+"/"+openlink):
|
|
|
|
|
|
|
|
# In case the folder is not there yet
|
|
|
|
|
|
|
|
try:
|
|
|
|
os.mkdir("wiki/updates")
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Now we are getting the file
|
|
|
|
|
|
|
|
try:
|
|
|
|
http = urllib3.PoolManager()
|
|
|
|
resp = http.request('GET', "https://notabug.org/jyamihud/VCStudio/raw/master/"+openlink)
|
|
|
|
|
|
|
|
# Sometimes we might get a 404 error page
|
|
|
|
|
|
|
|
if not resp.data.decode("utf-8").startswith("<!DOCTYPE html>"):
|
|
|
|
|
|
|
|
s = open(openlink, "wb")
|
|
|
|
s.write(resp.data)
|
|
|
|
s.close()
|
|
|
|
else:
|
|
|
|
1/0 # Else we want to execute the exception
|
|
|
|
except:
|
|
|
|
|
|
|
|
# We gonna make a simple 404 page
|
|
|
|
# And load it
|
|
|
|
|
|
|
|
openlink = "/tmp/404-error-"+str(version)+".md"
|
|
|
|
s = open(openlink, "w")
|
|
|
|
s.write("# Version "+str(version)+" No page :(\n\n")
|
|
|
|
s.write("You can try")
|
|
|
|
s.write("![](../../settings/themes/OldSchool/icons/lbry.png)")
|
|
|
|
s.write("[the LBRY link]("+link.replace("(","%28").replace(")","%29")+").\n\n")
|
|
|
|
s.write("![](../../settings/themes/OldSchool/icons/question.png) [What is LBRY?](../../wiki/extra/LBRY.md)")
|
|
|
|
s.close()
|
|
|
|
|
|
|
|
|
|
|
|
win.current["mdfs"]["update_markdown"] = openlink # Loading MD file into viever
|
|
|
|
win.current["update_markdown_files"] = files # Files, for list of updates
|
2020-11-26 16:50:17 +01:00
|
|
|
|
|
|
|
UI_elements.roundrect(layer, win,
|
2021-06-15 19:07:52 +02:00
|
|
|
current_X + 50 + win.scroll["pm_update"],
|
|
|
|
20,
|
|
|
|
300,
|
2020-11-26 16:50:17 +01:00
|
|
|
40,
|
|
|
|
10,
|
|
|
|
button=do,
|
|
|
|
tip=talk.text("update_read_version_notes"),
|
|
|
|
fill=False,
|
|
|
|
clip=clip)
|
|
|
|
layer.stroke()
|
2021-06-15 19:07:52 +02:00
|
|
|
|
|
|
|
# Loading markdown page at start of the update window
|
|
|
|
if not win.current["mdfs"]["update_markdown"]:
|
|
|
|
do()
|
2020-11-26 16:50:17 +01:00
|
|
|
|
2021-06-15 19:07:52 +02:00
|
|
|
current_X = current_X + 310
|
|
|
|
|
|
|
|
# And finally the scroller for the top bar.
|
2020-11-26 16:50:17 +01:00
|
|
|
UI_elements.scroll_area(layer, win, "pm_update",
|
2021-06-15 19:07:52 +02:00
|
|
|
50,
|
|
|
|
20,
|
|
|
|
win.current["w"]-100,
|
|
|
|
80,
|
|
|
|
current_X,
|
2020-11-26 16:50:17 +01:00
|
|
|
bar=True,
|
|
|
|
mmb=True,
|
2021-06-15 19:07:52 +02:00
|
|
|
sideways=True,
|
2020-11-26 16:50:17 +01:00
|
|
|
url="update_layer"
|
|
|
|
)
|
2021-06-15 19:07:52 +02:00
|
|
|
|
2020-11-26 16:50:17 +01:00
|
|
|
|
|
|
|
return surface
|