Package Gnumed :: Package timelinelib :: Package config :: Module preferences |
[frames] | no frames]

# Source Code for Module Gnumed.timelinelib.config.preferences

     1  # Copyright (C) 2009, 2010, 2011  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 -class PreferencesEditor(object):
    20
    21 -    def __init__(self, dialog, config):
    22          self.dialog = dialog
    23          self.config = config
    24          self.weeks_map = ((0, "monday"), (1, "sunday"))
    25
    26 -    def initialize_controls(self):
    27          self.dialog.set_checkbox_enable_wide_date_range(
    28              self.config.get_use_wide_date_range())
    29          self.dialog.set_checkbox_use_inertial_scrolling(
    30              self.config.get_use_inertial_scrolling())
    31          self.dialog.set_checkbox_open_recent_at_startup(
    32              self.config.get_open_recent_at_startup())
    33          index = self._week_index(self.config.week_start)
    34          self.dialog.set_week_start(index)
    35
    36 -    def on_use_wide_date_range_changed(self, value):
    37          self.config.set_use_wide_date_range(value)
    38
    39 -    def on_use_inertial_scrolling_changed(self, value):
    40          self.config.set_use_inertial_scrolling(value)
    41
    42 -    def on_open_recent_changed(self, value):
    43          self.config.set_open_recent_at_startup(value)
    44
    45 -    def on_week_start_changed(self, value):
    46          self.config.week_start = self._index_week(value)
    47
    48 -    def _week_index(self, week):
    49          for (i, w) in self.weeks_map:
    50              if w == week:
    51                  return i
    52          raise ValueError("Unknown week '%s'." % week)
    53
    54 -    def _index_week(self, index):
    55          for (i, w) in self.weeks_map:
    56              if i == index:
    57                  return w
    58          raise ValueError("Unknown week index '%s'." % index)
    59