Gnumed.timelinelib.wxgui.frames.mainframe.controllerapi

Package Gnumed :: Package timelinelib :: Package wxgui :: Package frames :: Package mainframe :: Module controllerapi |
[frames] | no frames]

# Source Code for Module Gnumed.timelinelib.wxgui.frames.mainframe.controllerapi

      1  # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018  Rickard Lindberg, Roger Lindberg
      2  #
      3  # This file is part of Timeline.
      4  #
      5  # Timeline is free software: you can redistribute it and/or modify
      6  # it under the terms of the GNU General Public License as published by
      7  # the Free Software Foundation, either version 3 of the License, or
      8  # (at your option) any later version.
      9  #
     10  # Timeline is distributed in the hope that it will be useful,
     11  # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  # GNU General Public License for more details.
     14  #
     15  # You should have received a copy of the GNU General Public License
     16  # along with Timeline.  If not, see <http://www.gnu.org/licenses/>.
     17
     18
     19  import os.path
     20
     21  import wx
     22
     23  from timelinelib.meta.about import APPLICATION_NAME
     24  import timelinelib.wxgui.frames.mainframe.guicreator as guic
     25
     26
     27 -class MainFrameApiUsedByController(object):
     28
     29 -    def set_timeline_readonly(self):
     30          self._set_readonly_text_in_status_bar()
     31          self.enable_disable_menus()
     32
     33 -    def update_open_recent_submenu(self):
     34          self._clear_recent_menu_items()
     35          self._create_recent_menu_items()
     36
     37 -    def display_timeline(self, timeline):
     38          self.timeline = timeline
     39          self.menu_controller.on_timeline_change(timeline)
     40          self.main_panel.display_timeline(timeline)
     41          self._set_title()
     42          self._set_readonly_text_in_status_bar()
     43
     49
     50      # Also used by TinmelineView
     51 -    def enable_disable_menus(self):
     52          self.menu_controller.enable_disable_menus(self.main_panel.timeline_panel_visible())
     53          self._enable_disable_one_selected_event_menus()
     54          self._enable_disable_measure_distance_between_two_events_menu()
     55          self._enable_disable_searchbar()
     56          self._enable_disable_undo()
     57
     58 -    def _set_title(self):
     59          if self.timeline is None:
     60              self.SetTitle(APPLICATION_NAME)
     61          else:
     62              self.SetTitle("%s (%s) - %s" % (
     63                  os.path.basename(self.timeline.path),
     64                  os.path.dirname(os.path.abspath(self.timeline.path)),
     65                  APPLICATION_NAME))
     66
     67 -    def _set_readonly_text_in_status_bar(self):
     68          if self.controller.timeline_is_readonly():
     69              text = _("read-only")
     70          else:
     71              text = ""
     72          self.status_bar_adapter.set_read_only_text(text)
     73
     80
     97
    103
    109
    113
    118
    126
    127 -    def _mnu_file_open_recent_item_on_click(self, event):
    128          path = self.open_recent_map[event.GetId()]
    129          self.controller.open_timeline_if_exists(path)
    130
    131 -    def _enable_disable_one_selected_event_menus(self):
    132          nbr_of_selected_events = self.main_panel.get_nbr_of_selected_events()
    133          one_event_selected = nbr_of_selected_events == 1
    134          some_event_selected = nbr_of_selected_events > 0
    135          mnu_edit_event = self. _timeline_menu.FindItemById(guic.ID_EDIT_EVENT)
    136          mnu_duplicate_event = self. _timeline_menu.FindItemById(guic.ID_DUPLICATE_EVENT)
    137          mnu_set_category = self. _timeline_menu.FindItemById(guic.ID_SET_CATEGORY_ON_SELECTED)
    138          mnu_edit_event.Enable(one_event_selected)
    139          mnu_duplicate_event.Enable(one_event_selected)
    140          mnu_set_category.Enable(some_event_selected)
    141          self._timeline_menu.FindItemById(guic.ID_MOVE_EVENT_UP).Enable(one_event_selected)
    142          self._timeline_menu.FindItemById(guic.ID_MOVE_EVENT_DOWN).Enable(one_event_selected)
    143
    148
    149 -    def _enable_disable_searchbar(self):
    150          if self.timeline is None:
    151              self.main_panel.show_searchbar(False)
    152
    153 -    def _enable_disable_undo(self):
    154          mnu_undo = self._timeline_menu.FindItemById(guic.ID_UNDO)
    155          mnu_redo = self._timeline_menu.FindItemById(guic.ID_REDO)
    156          if self.timeline is not None:
    157              mnu_undo.Enable(self.timeline.undo_enabled())
    158              mnu_redo.Enable(self.timeline.redo_enabled())
    159          else:
    160              mnu_undo.Enable(False)
    161              mnu_redo.Enable(False)
    162