moved controls to dir; added open files button example; css transparency changes

This commit is contained in:
itdominator 2024-03-16 22:36:04 -05:00
parent a0f32a7c00
commit bdb9c157f7
5 changed files with 110 additions and 5 deletions

View File

@ -6,7 +6,8 @@ gi.require_version('Gtk', '3.0')
from gi.repository import Gtk from gi.repository import Gtk
# Application imports # Application imports
from ..widgets.transparency_scale import TransparencyScale from ..widgets.controls.open_files_button import OpenFilesButton
from ..widgets.controls.transparency_scale import TransparencyScale
@ -36,14 +37,15 @@ class HeaderContainer(Gtk.Box):
def _load_widgets(self): def _load_widgets(self):
button = Gtk.Button(label = "Interactive Debug") button = Gtk.Button(label = "Interactive Debug")
button.connect("clicked", self._interactive_debug) button.connect("clicked", self._interactive_debug)
self.add(TransparencyScale()) self.add( OpenFilesButton() )
self.add( TransparencyScale() )
self.add(button) self.add(button)
def _interactive_debug(self, widget = None, eve = None): def _interactive_debug(self, widget = None, eve = None):
event_system.emit("load-interactive-debug") event_system.emit("load-interactive-debug")
def tggl_top_main_menubar(self): def tggl_top_main_menubar(self):
self.hide() if self.is_visible() else self.show() self.hide() if self.is_visible() else self.show()

View File

@ -0,0 +1,3 @@
"""
Widgets.Controls Module
"""

View File

@ -0,0 +1,86 @@
# Python imports
import os
# Lib imports
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import Gio
# Application imports
class OpenFilesButton(Gtk.Button):
"""docstring for OpenFilesButton."""
def __init__(self):
super(OpenFilesButton, self).__init__()
self._setup_styling()
self._setup_signals()
self._subscribe_to_events()
self._load_widgets()
def _setup_styling(self):
self.set_label("Open File(s)...")
self.set_image( Gtk.Image.new_from_icon_name("gtk-open", 4) )
self.set_always_show_image(True)
self.set_image_position(1) # Left - 0, Right = 1
self.set_hexpand(False)
def _setup_signals(self):
self.connect("button-release-event", self._open_files)
def _subscribe_to_events(self):
event_system.subscribe("open_files", self._open_files)
def _load_widgets(self):
...
def _open_files(self, widget = None, eve = None, gfile = None):
start_dir = None
_gfiles = []
if gfile and gfile.query_exists():
start_dir = gfile.get_parent()
chooser = Gtk.FileChooserDialog("Open File(s)...", None,
Gtk.FileChooserAction.OPEN,
(
Gtk.STOCK_CANCEL,
Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN,
Gtk.ResponseType.OK
)
)
chooser.set_select_multiple(True)
try:
folder = widget.get_current_file().get_parent() if not start_dir else start_dir
chooser.set_current_folder( folder.get_path() )
except Exception as e:
...
response = chooser.run()
if not response == Gtk.ResponseType.OK:
chooser.destroy()
return _gfiles
filenames = chooser.get_filenames()
if not filenames:
chooser.destroy()
return _gfiles
for file in filenames:
path = file if os.path.isabs(file) else os.path.abspath(file)
_gfiles.append( Gio.File.new_for_path(path) )
chooser.destroy()
logger.debug(_gfiles)
return _gfiles

View File

@ -37,7 +37,7 @@ class TransparencyScale(Gtk.Scale):
def _load_widgets(self): def _load_widgets(self):
adjust = self.get_adjustment() adjust = self.get_adjustment()
adjust.set_lower(0) adjust.set_lower(0)
adjust.set_upper(99) adjust.set_upper(100)
adjust.set_value(settings.theming.transparency) adjust.set_value(settings.theming.transparency)
adjust.set_step_increment(1.0) adjust.set_step_increment(1.0)

View File

@ -1,3 +1,16 @@
/* ---- Make most desired things base transparent ---- */
popover,
popover > *,
scrolledwindow > *,
textview > *,
.main-window > .base-container > .body-container,
.main-window > .base-container > .body-container > .left-container,
.main-window > .base-container > .body-container > .center-container,
.main-window > .base-container > .body-container > .right-container {
background: rgba(0, 0, 0, 0.0);
color: rgba(255, 255, 255, 1);
}
.base-container { .base-container {
margin: 10px; margin: 10px;
} }
@ -128,3 +141,4 @@ XfdesktopIconView.view:active {
.mw_transparency_97 { background: rgba(39, 43, 52, 0.97); } .mw_transparency_97 { background: rgba(39, 43, 52, 0.97); }
.mw_transparency_98 { background: rgba(39, 43, 52, 0.98); } .mw_transparency_98 { background: rgba(39, 43, 52, 0.98); }
.mw_transparency_99 { background: rgba(39, 43, 52, 0.99); } .mw_transparency_99 { background: rgba(39, 43, 52, 0.99); }
.mw_transparency_100 { background: rgba(39, 43, 52, 1.00); }