diff options
Diffstat (limited to 'grc/gui/NotebookPage.py')
-rw-r--r-- | grc/gui/NotebookPage.py | 68 |
1 files changed, 27 insertions, 41 deletions
diff --git a/grc/gui/NotebookPage.py b/grc/gui/NotebookPage.py index 9a76897fe6..e15617aec9 100644 --- a/grc/gui/NotebookPage.py +++ b/grc/gui/NotebookPage.py @@ -17,17 +17,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ -import gi -gi.require_version('Gtk', '3.0') -from gi.repository import Gtk -from gi.repository import GObject - -import Actions -from StateCache import StateCache -from Constants import MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT -from DrawingArea import DrawingArea import os +from gi.repository import Gtk, Gdk, GObject + +from . import Actions +from .StateCache import StateCache +from .Constants import MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT +from .DrawingArea import DrawingArea + class NotebookPage(Gtk.HBox): """A page in the notebook.""" @@ -40,49 +38,46 @@ class NotebookPage(Gtk.HBox): main_window: main window file_path: path to a flow graph file """ + Gtk.HBox.__init__(self) + + self.main_window = main_window self._flow_graph = flow_graph self.process = None - #import the file - self.main_window = main_window + + # import the file self.file_path = file_path initial_state = flow_graph.get_parent().parse_flow_graph(file_path) + self.get_flow_graph().import_data(initial_state) self.state_cache = StateCache(initial_state) self.saved = True - #import the data to the flow graph - self.get_flow_graph().import_data(initial_state) - #initialize page gui - GObject.GObject.__init__(self) - self.show() - #tab box to hold label and close button - self.tab = Gtk.HBox(homogeneous=False, spacing=0) - #setup tab label + + # tab box to hold label and close button self.label = Gtk.Label() - self.tab.pack_start(self.label, False, False, 0) - #setup button image image = Gtk.Image() image.set_from_stock('gtk-close', Gtk.IconSize.MENU) - #setup image box image_box = Gtk.HBox(homogeneous=False, spacing=0) image_box.pack_start(image, True, False, 0) - #setup the button button = Gtk.Button() button.connect("clicked", self._handle_button) button.set_relief(Gtk.ReliefStyle.NONE) button.add(image_box) - #button size - #w, h = Gtk.icon_size_lookup_for_settings(button.get_settings(), Gtk.IconSize.MENU) - #button.set_size_request(w+6, h+6) - self.tab.pack_start(button, False, False, 0) - self.tab.show_all() - #setup scroll window and drawing area + + tab = self.tab = Gtk.HBox(homogeneous=False, spacing=0) + tab.pack_start(self.label, False, False, 0) + tab.pack_start(button, False, False, 0) + tab.show_all() + + # setup scroll window and drawing area + self.drawing_area = DrawingArea(self.get_flow_graph()) + self.scrolled_window = Gtk.ScrolledWindow() self.scrolled_window.set_size_request(MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT) - self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) + self.scrolled_window.set_policy(Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS) self.scrolled_window.connect('key-press-event', self._handle_scroll_window_key_press) - self.drawing_area = DrawingArea(self.get_flow_graph()) self.scrolled_window.add_with_viewport(self.drawing_area) self.pack_start(self.scrolled_window, True, True, 0) - #inject drawing area into flow graph + + # inject drawing area into flow graph self.get_flow_graph().drawing_area = self.drawing_area self.show_all() @@ -125,15 +120,6 @@ class NotebookPage(Gtk.HBox): """ self.label.set_markup(markup) - def get_tab(self): - """ - Get the gtk widget for this page's tab. - - Returns: - gtk widget - """ - return self.tab - def get_proc(self): """ Get the subprocess for the flow graph. |