generated from itdominator/Python-With-Gtk-Template
Added tab switch update labels eve, improved header layout
This commit is contained in:
parent
5cf1861929
commit
de2be9af98
|
@ -7,6 +7,7 @@ from gi.repository import Gtk
|
|||
|
||||
# Application imports
|
||||
from ..controls.open_file_button import OpenFileButton
|
||||
from ..controls.save_as_button import SaveAsButton
|
||||
from ..controls.scale_up_button import ScaleUpButton
|
||||
from ..controls.scale_down_button import ScaleDownButton
|
||||
from ..controls.toggle_line_highlight import ToggleLineHighlight
|
||||
|
@ -37,11 +38,19 @@ class BannerControls(Gtk.Box):
|
|||
event_system.subscribe("tggl_top_main_menubar", self._tggl_top_main_menubar)
|
||||
|
||||
def _load_widgets(self):
|
||||
self.add(OpenFileButton())
|
||||
self.add(ScaleUpButton())
|
||||
self.add(ScaleDownButton())
|
||||
self.add(ToggleLineHighlight())
|
||||
self.pack_start(OpenFileButton(), False, False, 0)
|
||||
self.pack_start(SaveAsButton(), False, False, 0)
|
||||
|
||||
center_box = Gtk.ButtonBox()
|
||||
center_box.add(ScaleUpButton())
|
||||
center_box.add(ScaleDownButton())
|
||||
center_box.add(ToggleLineHighlight())
|
||||
center_box.set_margin_left(15)
|
||||
center_box.set_margin_right(15)
|
||||
self.set_center_widget(center_box)
|
||||
|
||||
self.pack_end(ThemeButton(), False, False, 0)
|
||||
|
||||
|
||||
def _tggl_top_main_menubar(self):
|
||||
self.show() if not self.is_visible() else self.hide()
|
||||
|
|
|
@ -36,7 +36,6 @@ class BottomStatusInfoWidget:
|
|||
|
||||
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)
|
||||
|
@ -69,7 +68,7 @@ class BottomStatusInfoWidget:
|
|||
self.bottom_path_label.set_tooltip_text( gfile.get_path() )
|
||||
|
||||
self.bottom_encoding_label.set_text("utf-8")
|
||||
self.bottom_line_char_label.set_text("0:0")
|
||||
self.bottom_line_char_label.set_text("1:1")
|
||||
self.bottom_file_type_label.set_text( info.get_content_type() )
|
||||
|
||||
def _set_path_label(self):
|
||||
|
|
|
@ -36,6 +36,7 @@ class EditorNotebook(EditorEventsMixin, EditorControllerMixin, Gtk.Notebook):
|
|||
self.set_scrollable(True)
|
||||
|
||||
def _setup_signals(self):
|
||||
self.connect("switch-page", self._switch_page_update)
|
||||
# self.connect("button-press-event", self._dbl_click_create_view)
|
||||
...
|
||||
|
||||
|
@ -86,6 +87,13 @@ class EditorNotebook(EditorEventsMixin, EditorControllerMixin, Gtk.Notebook):
|
|||
if eve.type == Gdk.EventType.DOUBLE_BUTTON_PRESS and eve.button == 1: # l-click
|
||||
...
|
||||
|
||||
def _switch_page_update(self, notebook, page, page_num):
|
||||
source_view = page.get_source_view()
|
||||
gfile = source_view.get_current_file()
|
||||
if gfile:
|
||||
source_view.load_file_info( gfile )
|
||||
source_view.update_cursor_position()
|
||||
|
||||
def create_view(self, widget = None, eve = None, gfile = None):
|
||||
container = SourceViewContainer(self.close_tab)
|
||||
|
||||
|
|
|
@ -34,8 +34,6 @@ class SourceView(SourceViewEventsMixin, GtkSource.View):
|
|||
self._file_loader = None
|
||||
self._buffer = self.get_buffer()
|
||||
|
||||
|
||||
|
||||
self._file_filter_text = Gtk.FileFilter()
|
||||
self._file_filter_text.set_name("Text Files")
|
||||
# TODO: Need to externalize to settings file...
|
||||
|
|
|
@ -12,6 +12,9 @@ from gi.repository import GtkSource
|
|||
|
||||
|
||||
class SourceViewEventsMixin:
|
||||
def get_current_file(self):
|
||||
return self._current_file
|
||||
|
||||
def set_buffer_language(self, language = "python3"):
|
||||
self._buffer.set_language( self._language_manager.get_language(language) )
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@ class OpenFileButton(Gtk.Button):
|
|||
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_margin_left(5)
|
||||
self.set_margin_right(5)
|
||||
self.set_hexpand(False)
|
||||
|
||||
def _setup_signals(self):
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
|
||||
# Application imports
|
||||
|
||||
|
||||
|
||||
class SaveAsButton(Gtk.Button):
|
||||
def __init__(self):
|
||||
super(SaveAsButton, self).__init__()
|
||||
|
||||
self._setup_styling()
|
||||
self._setup_signals()
|
||||
self._subscribe_to_events()
|
||||
self._load_widgets()
|
||||
|
||||
|
||||
def _setup_styling(self):
|
||||
self.set_label("Save As")
|
||||
self.set_image( Gtk.Image.new_from_icon_name("gtk-save-as", 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("released", self._emit_save_as_eve)
|
||||
|
||||
def _subscribe_to_events(self):
|
||||
...
|
||||
|
||||
def _load_widgets(self):
|
||||
...
|
||||
|
||||
def _emit_save_as_eve(self, widget, eve = None):
|
||||
event_system.emit('keyboard_save_file')
|
|
@ -24,8 +24,6 @@ class ScaleDownButton(Gtk.Button):
|
|||
self.set_image( Gtk.Image.new_from_icon_name("gtk-remove", 4) )
|
||||
self.set_always_show_image(True)
|
||||
self.set_image_position(1) # Left - 0, Right = 1
|
||||
# self.set_margin_left(5)
|
||||
# self.set_margin_right(5)
|
||||
self.set_hexpand(False)
|
||||
|
||||
def _setup_signals(self):
|
||||
|
|
|
@ -24,8 +24,6 @@ class ScaleUpButton(Gtk.Button):
|
|||
self.set_image( Gtk.Image.new_from_icon_name("gtk-add", 4) )
|
||||
self.set_always_show_image(True)
|
||||
self.set_image_position(1) # Left - 0, Right = 1
|
||||
self.set_margin_left(5)
|
||||
# self.set_margin_right(5)
|
||||
self.set_hexpand(False)
|
||||
|
||||
def _setup_signals(self):
|
||||
|
|
|
@ -21,11 +21,9 @@ class ToggleLineHighlight(Gtk.Button):
|
|||
|
||||
def _setup_styling(self):
|
||||
self.set_label("Line Highlight")
|
||||
# self.set_image( Gtk.Image.new_from_icon_name("gtk-add", 4) )
|
||||
self.set_image( Gtk.Image.new_from_icon_name("gtk-select-font", 4) )
|
||||
self.set_always_show_image(True)
|
||||
self.set_image_position(1) # Left - 0, Right = 1
|
||||
# self.set_margin_left(5)
|
||||
# self.set_margin_right(5)
|
||||
self.set_hexpand(False)
|
||||
|
||||
def _setup_signals(self):
|
||||
|
|
Loading…
Reference in New Issue