Exemplo n.º 1
0
 def __init__(self):
     self.__screenshots = []
     self.__current = None
     self.added = Event()
     self.closed = Event()
     self.changed = Event()
     self.current_changed = Event()
Exemplo n.º 2
0
class CompletedScreenshot(Screenshot):
  global_counter = 0

  def __init__(self, pixbuf, filename=None):
    self.__filename = filename
    self.__pixbuf = pixbuf
    self.__dirty = True
    self.__capture_time = datetime.now()
    self.__uuid = uuid.uuid4()
    self.dirty_state_change = Event()
    CompletedScreenshot.global_counter += 1

  def get_uuid(self):
    return str(self.__uuid)

  def get_pixbuf(self):
    return self.__pixbuf

  def get_filename(self):
    return self.__filename

  def get_title(self):
    if self.__filename:
      return os.path.basename(self.__filename)
    return _("unnamed %d" % CompletedScreenshot.global_counter)

  def set_title(self, title):
    self.__title = title

  def get_capture_time(self):
    return self.__capture_time

  def mark_clean(self):
    self.__dirty = False
    self.dirty_state_change.dispatch(self.__dirty)

  def mark_dirty(self):
    self.__dirty = True
    self.dirty_state_change.dispatch(self.__dirty)

  def is_dirty(self):
    return self.__dirty

  def is_clean(self):
    return not self.__dirty

  def save_as(self, filename):
    new = CompletedScreenshot(self.__pixbuf, filename)
    new.mark_clean()
    new.__capture_time = self.__capture_time
    root, ext = os.path.splitext(filename)
    self.__pixbuf.savev(new_filename, ext[1:], (), ())
    return new
Exemplo n.º 3
0
 def __init__(self, pixbuf, filename=None):
   self.__filename = filename
   self.__pixbuf = pixbuf
   self.__dirty = True
   self.__capture_time = datetime.now()
   self.__uuid = uuid.uuid4()
   self.dirty_state_change = Event()
   CompletedScreenshot.global_counter += 1
Exemplo n.º 4
0
class Ekrano():
  """ Entry point class. """

  def __init__(self):
    self.settings = Settings()
    self.pre_started = Event()
    self.started = Event()

  def start(self):
    self.settings.load()
    self.load_plugins()
    self.pre_started.dispatch()
    self.app = Application(self)
    self.app.run(sys.argv)
    self.started.dispatch()

  def load_plugins(self):
    # To be developed...
    self.__plugins = {}
    pass

  def unload_plugins(self):
    for name, instance in self.__plugins.items():
      instance.unload()
Exemplo n.º 5
0
 def __init__(self):
   self.settings = Settings()
   self.pre_started = Event()
   self.started = Event()
Exemplo n.º 6
0
class Session:
    """ A session abstracts a set of viewed screenshots. """

    def __init__(self):
        self.__screenshots = []
        self.__current = None
        self.added = Event()
        self.closed = Event()
        self.changed = Event()
        self.current_changed = Event()

    def add(self, screenshot):
        self.__screenshots.append(screenshot)
        self.added.dispatch(screenshot)
        self.changed.dispatch()

    def close(self, screenshot):
        self.__screenshots.remove(screenshot)
        self.closed.dispatch(screenshot)
        self.changed.dispatch()

    def close_current(self):
        if self.has_current():
            self.close(self.__current)

    def close_all(self):
        while self.get_count() > 0:
            self.close(self.__screenshots[0])

    def get_current(self):
        return self.__current

    def set_current(self, current):
        self.__current = current
        self.current_changed.dispatch()
        self.changed.dispatch()

    def has_current(self):
        return self.__current != None

    def all(self):
        return self.__screenshots.copy()

    def get_count(self):
        return len(self.__screenshots)

    def is_empty(self):
        return self.get_count() > 0