Finalized switch to Fixed widget

This commit is contained in:
itdominator 2023-04-08 20:52:03 -05:00
parent 1306bed11d
commit 6daeabe66e
3 changed files with 10 additions and 28 deletions

View File

@ -14,12 +14,10 @@ from .template.dynamic_widget_template import DynamicWidget
class DragArea(GtkSource.View):
# class DragArea(Gtk.Fixed):
class DragArea(Gtk.Fixed):
def __init__(self):
super(DragArea, self).__init__()
self.buffer = self.get_buffer()
self._children_content = []
self._setup_styling()
@ -30,7 +28,6 @@ class DragArea(GtkSource.View):
def _setup_styling(self):
self.set_size_request(1800, 1800)
self.set_cursor_visible(False)
def _setup_signals(self):
...
@ -42,9 +39,7 @@ class DragArea(GtkSource.View):
...
def _move_callback(self, widget = None, x = None, y = None):
# self.move(widget.get_parent(), x, y)
self.move_child(widget.get_parent(), x, y)
self.move(widget.get_parent(), x, y)
def wrap_widget_in_trap(self, widget):
eve_trap_box = Gtk.EventBox()
@ -71,9 +66,7 @@ class DragArea(GtkSource.View):
widget_wrapped = self.wrap_widget_in_trap(widget)
self._children_content.append(widget)
# self.put(widget_wrapped, x, y)
self.add_child_in_window(widget_wrapped, Gtk.TextWindowType.WIDGET, x, y)
self.put(widget_wrapped, x, y)
def add_fixed_base_widgets(self, name = None, date = None, update_header_callback = None):
entry = Gtk.Entry(text = name)
@ -88,10 +81,8 @@ class DragArea(GtkSource.View):
entry.set_width_chars(25)
entry.set_max_length(25)
# self.put(wrapped_entry, 30, 30)
# self.put(wrapped_date, 30, 65)
self.add_child_in_window(wrapped_entry, Gtk.TextWindowType.WIDGET, 30, 30)
self.add_child_in_window(wrapped_date, Gtk.TextWindowType.WIDGET, 30, 65)
self.put(wrapped_entry, 30, 30)
self.put(wrapped_date, 30, 65)
def add_or_select_widget(self, widget = None, eve = None):
dynamic_widget = DynamicWidget(self._move_callback, None, eve.x, eve.y)

View File

@ -51,14 +51,12 @@ class Page(Gtk.ScrolledWindow):
def _load_widgets(self):
self._drag_area = DragArea()
viewport = Gtk.Viewport()
eve_box = Gtk.EventBox()
self._drag_area.connect("button-press-event", self._press_event)
self.connect("motion-notify-event", self._motion_event)
self._drag_area.connect("button-release-event", self._release_event)
eve_box.connect("button-release-event", self._release_event)
viewport.add(self._drag_area)
self.add(viewport)
eve_box.add(self._drag_area)
self.add(eve_box)
def get_tab_widget(self):
return self._tab_widget
@ -94,13 +92,6 @@ class Page(Gtk.ScrolledWindow):
self._tab_widget.set_tab_label(self._name)
settings.update_manifest(self._manifest_pth, self._name, self._date)
def _press_event(self, widget = None, eve = None):
self.mouse_held = True
def _motion_event(self, widget = None, eve = None):
if self.mouse_held and not self.was_dragging:
self.was_dragging = True
def _release_event(self, widget = None, eve = None):
self.mouse_held = False
if self.was_dragging:

View File

@ -89,7 +89,7 @@ class Pages(Gtk.Notebook):
settings.set_active_page(path)
def _change_section_name(self, widget = None, eve = None):
if eve.button == 1: # NOTE: If left click
if eve.button == 3: # NOTE: If right click
label = widget.get_children()[0] # NOTE: Pull from event box
parent = self.get_parent()
data = [parent._manifest_pth, parent._name, parent._date]