pm_newprojectLayer.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. # THIS FILE IS A PART OF VCStudio
  2. # PYTHON 3
  3. # This a console project manager.
  4. import os
  5. # GTK module ( Graphical interface
  6. import gi
  7. gi.require_version('Gtk', '3.0')
  8. from gi.repository import Gtk
  9. from gi.repository import GLib
  10. from gi.repository import Gdk
  11. import cairo
  12. # Own modules
  13. from settings import settings
  14. from settings import talk
  15. from project_manager import pm_project
  16. #UI modules
  17. from UI import UI_elements
  18. from UI import UI_color
  19. def layer(win):
  20. # Making the layer
  21. surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, win.current['w'],
  22. win.current['h'])
  23. layer = cairo.Context(surface)
  24. #text setting
  25. layer.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
  26. UI_color.set(layer, win, "dark_overdrop")
  27. layer.rectangle(
  28. 0,
  29. 0,
  30. win.current["w"],
  31. win.current["h"],
  32. )
  33. layer.fill()
  34. # So it's going to be like a little window in the center of the VCStudio
  35. # with a simple UI. Probably like 2 things. Folder and a projectname.
  36. UI_color.set(layer, win, "node_background")
  37. UI_elements.roundrect(layer, win,
  38. win.current["w"]/2-250,
  39. win.current["h"]/2-150,
  40. 500,
  41. 300,
  42. 10)
  43. # Title of the operation. Incase the user forgot.
  44. UI_elements.text(layer, win, "new_project_title",
  45. win.current["w"]/2-250,
  46. win.current["h"]/2-110,
  47. 500,
  48. 30,
  49. 10,
  50. fill=False,
  51. centered=True,
  52. editable=False)
  53. win.text["new_project_title"]["text"] = talk.text("createnewproject_tooltip")
  54. # Folder. It's so VCStudio would know WHERE does user want to create the
  55. # final project.
  56. def do():
  57. folderchooser = Gtk.FileChooserDialog(talk.text("select_folder"),
  58. None,
  59. Gtk.FileChooserAction.SELECT_FOLDER,
  60. (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
  61. Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
  62. folderchooser.set_default_response(Gtk.ResponseType.OK)
  63. response = folderchooser.run()
  64. if response == Gtk.ResponseType.OK:
  65. get = folderchooser.get_filename()
  66. settings.write("New-Project-Folder", get)
  67. win.settings["New-Project-Folder"] = get
  68. folderchooser.destroy()
  69. UI_elements.roundrect(layer, win,
  70. win.current["w"]/2-240,
  71. win.current["h"]/2-30,
  72. 480,
  73. 40,
  74. 10,
  75. button=do,
  76. icon="folder",
  77. tip=talk.text("pm_new_project_folder_tooltip"))
  78. choseF = "Select Folder"
  79. if "New-Project-Folder" in win.settings:
  80. choseF = win.settings["New-Project-Folder"]
  81. UI_elements.text(layer, win, "new_project_folder",
  82. win.current["w"]/2-190,
  83. win.current["h"]/2-30,
  84. 430,
  85. 40,
  86. set_text=choseF,
  87. fill=False,
  88. editable=False
  89. )
  90. # Name of the project folder. Aka Name of the project
  91. UI_elements.text(layer, win, "new_project_name",
  92. win.current["w"]/2-240,
  93. win.current["h"]/2+20,
  94. 480,
  95. 40,
  96. set_text=talk.text("new_project_name"))
  97. #win.textactive = "new_project_name"
  98. # Okay and Cancel buttons
  99. def do():
  100. pm_project.new(win.text["new_project_name"]["text"])
  101. win.url = "project_manager"
  102. win.textactive = ""
  103. win.text["new_project_name"]["text"] = talk.text("new_project_name")
  104. UI_elements.roundrect(layer, win,
  105. win.current["w"]/2+170,
  106. win.current["h"]/2+110,
  107. 40,
  108. 40,
  109. 10,
  110. button=do,
  111. icon="ok",
  112. tip=talk.text("checked"))
  113. def do():
  114. win.url = "project_manager"
  115. win.textactive = ""
  116. win.text["new_project_name"]["text"] = talk.text("new_project_name")
  117. UI_elements.roundrect(layer, win,
  118. win.current["w"]/2+210,
  119. win.current["h"]/2+110,
  120. 40,
  121. 40,
  122. 10,
  123. button=do,
  124. icon="cancel",
  125. tip=talk.text("cancel"))
  126. return surface