2023-03-20 05:18:49 +00:00
|
|
|
# Python imports
|
|
|
|
|
|
|
|
# Lib imports
|
|
|
|
import gi
|
|
|
|
gi.require_version('Gtk', '3.0')
|
|
|
|
from gi.repository import Gtk
|
|
|
|
from gi.repository import Gio
|
|
|
|
|
|
|
|
# Application imports
|
|
|
|
|
|
|
|
|
|
|
|
# NOTE: https://github.com/rwaldron/gtksourceview/blob/master/tests/test-widget.py
|
|
|
|
|
|
|
|
|
2023-03-26 06:07:35 +00:00
|
|
|
class GeneralInfoWidget:
|
|
|
|
""" docstring for StatusInfoWidget. """
|
2023-03-20 05:18:49 +00:00
|
|
|
|
|
|
|
def __init__(self):
|
2023-03-26 06:07:35 +00:00
|
|
|
super(GeneralInfoWidget, self).__init__()
|
2023-03-20 05:18:49 +00:00
|
|
|
|
2023-03-26 06:07:35 +00:00
|
|
|
_GLADE_FILE = f"{settings.get_ui_widgets_path()}/general_info_ui.glade"
|
2023-03-20 05:18:49 +00:00
|
|
|
self._builder = Gtk.Builder()
|
|
|
|
self._builder.add_from_file(_GLADE_FILE)
|
|
|
|
|
|
|
|
self._setup_styling()
|
|
|
|
self._setup_signals()
|
|
|
|
self._subscribe_to_events()
|
|
|
|
self._load_widgets()
|
|
|
|
|
|
|
|
|
|
|
|
def _setup_styling(self):
|
|
|
|
...
|
|
|
|
|
|
|
|
def _setup_signals(self):
|
|
|
|
...
|
|
|
|
|
|
|
|
def _subscribe_to_events(self):
|
|
|
|
event_system.subscribe("set_bottom_labels", self.set_bottom_labels)
|
|
|
|
event_system.subscribe("set_path_label", self._set_path_label)
|
|
|
|
event_system.subscribe("set_encoding_label", self._set_encoding_label)
|
|
|
|
event_system.subscribe("set_line_char_label", self._set_line_char_label)
|
|
|
|
event_system.subscribe("set_file_type_label", self._set_file_type_label)
|
|
|
|
|
|
|
|
|
|
|
|
def _load_widgets(self):
|
|
|
|
builder = settings.get_builder()
|
|
|
|
|
2023-03-26 06:07:35 +00:00
|
|
|
self.bottom_status_info = self._builder.get_object("general_info")
|
|
|
|
self.bottom_path_label = self._builder.get_object("path_label")
|
|
|
|
self.bottom_encoding_label = self._builder.get_object("encoding_label")
|
|
|
|
self.bottom_line_char_label = self._builder.get_object("line_char_label")
|
|
|
|
self.bottom_file_type_label = self._builder.get_object("file_type_label")
|
2023-03-20 05:18:49 +00:00
|
|
|
|
|
|
|
builder.expose_object(f"bottom_status_info", self.bottom_status_info)
|
|
|
|
builder.expose_object(f"bottom_path_label", self.bottom_path_label)
|
|
|
|
builder.expose_object(f"bottom_encoding_label", self.bottom_encoding_label)
|
|
|
|
builder.expose_object(f"bottom_line_char_label", self.bottom_line_char_label)
|
|
|
|
builder.expose_object(f"bottom_file_type_label", self.bottom_file_type_label)
|
|
|
|
|
|
|
|
self.bottom_path_label.set_hexpand(True)
|
|
|
|
self._set_line_char_label()
|
|
|
|
|
|
|
|
builder.get_object("core_widget").add(self.bottom_status_info)
|
|
|
|
|
|
|
|
|
2023-03-26 06:07:35 +00:00
|
|
|
def set_bottom_labels(self, path = None, line_char = None, file_type = None, encoding_type = None):
|
|
|
|
self._set_path_label(path)
|
|
|
|
self._set_line_char_label()
|
|
|
|
self._set_file_type_label(file_type)
|
|
|
|
self._set_encoding_label()
|
2023-03-20 05:18:49 +00:00
|
|
|
|
2023-03-26 06:07:35 +00:00
|
|
|
def _set_path_label(self, gfile = ""):
|
|
|
|
if isinstance(gfile, str):
|
|
|
|
self.bottom_path_label.set_text( gfile )
|
|
|
|
self.bottom_path_label.set_tooltip_text( gfile )
|
|
|
|
else:
|
|
|
|
self.bottom_path_label.set_text( gfile.get_path() )
|
|
|
|
self.bottom_path_label.set_tooltip_text( gfile.get_path() )
|
2023-03-20 05:18:49 +00:00
|
|
|
|
2023-03-26 06:07:35 +00:00
|
|
|
def _set_line_char_label(self, line_char = "1:1"):
|
|
|
|
self.bottom_line_char_label.set_text(line_char)
|
2023-03-20 05:18:49 +00:00
|
|
|
|
2023-03-26 06:07:35 +00:00
|
|
|
def _set_file_type_label(self, file_type = "buffer"):
|
|
|
|
self.bottom_file_type_label.set_text(file_type)
|
2023-03-20 05:18:49 +00:00
|
|
|
|
2023-03-26 06:07:35 +00:00
|
|
|
def _set_encoding_label(self, encoding_type = "utf-8"):
|
|
|
|
self.bottom_encoding_label.set_text(encoding_type)
|