Exemplo n.º 1
0
 def update_info(self, selected):
     """Update the info box using the currently <selected> books from
     the _BookArea.
     """
     self._open_button.set_sensitive(False)
     if selected:
         book = self._library.book_area.get_book_at_path(selected[0])
         name = self._library.backend.get_book_name(book)
         dir_path = os.path.dirname(
             self._library.backend.get_book_path(book))
         format_ = self._library.backend.get_book_format(book)
         pages = self._library.backend.get_book_pages(book)
         size = self._library.backend.get_book_size(book)
     else:
         name = dir_path = format_ = pages = size = None
     if len(selected) == 1:
         self._open_button.set_sensitive(True)
     if name is not None:
         self._namelabel.set_text(encoding.to_unicode(name))
     else:
         self._namelabel.set_text('')
     if pages is not None:
         self._pageslabel.set_text(_('%d pages') % pages)
     else:
         self._pageslabel.set_text('')
     if format_ is not None and size is not None:
         self._filelabel.set_text('%s, %s' %
                                  (archive.get_name(format_), '%.1f MiB' %
                                   (size / 1048576.0)))
     else:
         self._filelabel.set_text('')
     if dir_path is not None:
         self._dirlabel.set_text(encoding.to_unicode(dir_path))
     else:
         self._dirlabel.set_text('')
Exemplo n.º 2
0
 def update_info(self, selected):
     """Update the info box using the currently <selected> books from
     the _BookArea.
     """
     self._open_button.set_sensitive(False)
     if selected:
         book = self._library.book_area.get_book_at_path(selected[0])
         name = self._library.backend.get_book_name(book)
         dir_path = os.path.dirname(
                 self._library.backend.get_book_path(book))
         format_ = self._library.backend.get_book_format(book)
         pages = self._library.backend.get_book_pages(book)
         size = self._library.backend.get_book_size(book)
     else:
         name = dir_path = format_ = pages = size = None
     if len(selected) == 1:
         self._open_button.set_sensitive(True)
     if name is not None:
         self._namelabel.set_text(encoding.to_unicode(name))
     else:
         self._namelabel.set_text('')
     if pages is not None:
         self._pageslabel.set_text(_('{} pages').format(pages))
     else:
         self._pageslabel.set_text('')
     if format_ is not None and size is not None:
         self._filelabel.set_text('{}, {}'.format(archive.get_name(format_),
                                                  '{:.1f} MiB'.format(size / 1048576.0)))
     else:
         self._filelabel.set_text('')
     if dir_path is not None:
         self._dirlabel.set_text(encoding.to_unicode(dir_path))
     else:
         self._dirlabel.set_text('')
Exemplo n.º 3
0
 def update_title(self):
     """Set the title acording to current state."""
     if self.displayed_double():
         title = encoding.to_unicode('[{:d},{:d} / {:d}]  {} - Comix'.format(self.file_handler.get_current_page(),
                                                                             self.file_handler.get_current_page() + 1,
                                                                             self.file_handler.get_number_of_pages(),
                                                                             self.file_handler.get_pretty_current_filename()))
     else:
         title = encoding.to_unicode('[{:d} / {:d}]  {} - Comix'.format(self.file_handler.get_current_page(),
                                                                        self.file_handler.get_number_of_pages(),
                                                                        self.file_handler.get_pretty_current_filename()))
     if self.slideshow.is_running():
         title = '[{}] {}'.format(_('SLIDESHOW'), title)
     self.set_title(title)
Exemplo n.º 4
0
    def __init__(self, window):
        gtk.Dialog.__init__(self, _('Comments'), window, 0,
                            (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
        self.set_has_separator(False)
        self.set_resizable(True)
        self.connect('response', _close_dialog)
        self.set_default_response(gtk.RESPONSE_CLOSE)
        self.set_default_size(600, 550)

        notebook = gtk.Notebook()
        notebook.set_scrollable(True)
        self.set_border_width(4)
        notebook.set_border_width(6)
        self.vbox.pack_start(notebook)
        tag = gtk.TextTag()
        tag.set_property('editable', False)
        tag.set_property('editable-set', True)
        tag.set_property('family', 'Monospace')
        tag.set_property('family-set', True)
        tag.set_property('scale', 0.9)
        tag.set_property('scale-set', True)
        tag_table = gtk.TextTagTable()
        tag_table.add(tag)

        for num in range(1, window.file_handler.get_number_of_comments() + 1):
            page = gtk.VBox(False)
            page.set_border_width(8)
            scrolled = gtk.ScrolledWindow()
            scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            page.pack_start(scrolled)
            outbox = gtk.EventBox()
            scrolled.add_with_viewport(outbox)
            inbox = gtk.EventBox()
            inbox.set_border_width(6)
            outbox.add(inbox)
            name = os.path.basename(window.file_handler.get_comment_name(num))
            text = window.file_handler.get_comment_text(num)
            if text is None:
                text = _('Could not read {}').format(num)
            text_buffer = gtk.TextBuffer(tag_table)
            text_buffer.set_text(encoding.to_unicode(text))
            text_buffer.apply_tag(tag, *text_buffer.get_bounds())
            text_view = gtk.TextView(text_buffer)
            inbox.add(text_view)
            bg_color = text_view.get_default_attributes().bg_color
            outbox.modify_bg(gtk.STATE_NORMAL, bg_color)
            tab_label = gtk.Label(encoding.to_unicode(name))
            notebook.insert_page(page, tab_label)

        self.show_all()
Exemplo n.º 5
0
    def __init__(self, window):
        gtk.Dialog.__init__(self, _('Comments'), window, 0,
                            (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
        self.set_has_separator(False)
        self.set_resizable(True)
        self.connect('response', _close_dialog)
        self.set_default_response(gtk.RESPONSE_CLOSE)
        self.set_default_size(600, 550)

        notebook = gtk.Notebook()
        notebook.set_scrollable(True)
        self.set_border_width(4)
        notebook.set_border_width(6)
        self.vbox.pack_start(notebook)
        tag = gtk.TextTag()
        tag.set_property('editable', False)
        tag.set_property('editable-set', True)
        tag.set_property('family', 'Monospace')
        tag.set_property('family-set', True)
        tag.set_property('scale', 0.9)
        tag.set_property('scale-set', True)
        tag_table = gtk.TextTagTable()
        tag_table.add(tag)

        for num in range(1, window.file_handler.get_number_of_comments() + 1):
            page = gtk.VBox(False)
            page.set_border_width(8)
            scrolled = gtk.ScrolledWindow()
            scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            page.pack_start(scrolled)
            outbox = gtk.EventBox()
            scrolled.add_with_viewport(outbox)
            inbox = gtk.EventBox()
            inbox.set_border_width(6)
            outbox.add(inbox)
            name = os.path.basename(window.file_handler.get_comment_name(num))
            text = window.file_handler.get_comment_text(num)
            if text is None:
                text = _('Could not read {}').format(num)
            text_buffer = gtk.TextBuffer(tag_table)
            text_buffer.set_text(encoding.to_unicode(text))
            text_buffer.apply_tag(tag, *text_buffer.get_bounds())
            text_view = gtk.TextView(text_buffer)
            inbox.add(text_view)
            bg_color = text_view.get_default_attributes().bg_color
            outbox.modify_bg(gtk.STATE_NORMAL, bg_color)
            tab_label = gtk.Label(encoding.to_unicode(name))
            notebook.insert_page(page, tab_label)

        self.show_all()
Exemplo n.º 6
0
 def set_filename(self, filename):
     """Set the filename to be displayed to <filename>. Call this before
     set_main_info().
     """
     label = labels.BoldLabel(encoding.to_unicode(filename))
     label.set_alignment(0, 0.5)
     self._mainbox.pack_start(label, False, False)
     self._mainbox.pack_start(gtk.VBox())  # Just to add space (better way?)
Exemplo n.º 7
0
 def set_filename(self, filename):
     """Set the filename to be displayed to <filename>. Call this before
     set_main_info().
     """
     label = labels.BoldLabel(encoding.to_unicode(filename))
     label.set_alignment(0, 0.5)
     self._mainbox.pack_start(label, False, False)
     self._mainbox.pack_start(gtk.VBox())  # Just to add space (better way?)
Exemplo n.º 8
0
 def update_title(self):
     """Set the title acording to current state."""
     if self.displayed_double():
         title = encoding.to_unicode(
             '[{:d},{:d} / {:d}]  {} - Comix'.format(
                 self.file_handler.get_current_page(),
                 self.file_handler.get_current_page() + 1,
                 self.file_handler.get_number_of_pages(),
                 self.file_handler.get_pretty_current_filename()))
     else:
         title = encoding.to_unicode('[{:d} / {:d}]  {} - Comix'.format(
             self.file_handler.get_current_page(),
             self.file_handler.get_number_of_pages(),
             self.file_handler.get_pretty_current_filename()))
     if self.slideshow.is_running():
         title = '[{}] {}'.format(_('SLIDESHOW'), title)
     self.set_title(title)
Exemplo n.º 9
0
 def get_pretty_current_filename(self):
     """Return a string with the name of the currently viewed file that is
     suitable for printing.
     """
     if self.archive_type is not None:
         name = os.path.basename(self._base_path)
     else:
         name = os.path.join(os.path.basename(self._base_path),
                             os.path.basename(self._image_files[self._current_image_index]))
     return encoding.to_unicode(name)
Exemplo n.º 10
0
 def get_book_name(self, book):
     """Return the name of <book>, or None if <book> isn't in the
     library.
     """
     cur = self._con.execute('''SELECT name FROM Book
         WHERE id = ?''', (book,))
     name = cur.fetchone()
     if name is None:
         return None
     return encoding.to_unicode(name)
Exemplo n.º 11
0
 def get_pretty_current_filename(self):
     """Return a string with the name of the currently viewed file that is
     suitable for printing.
     """
     if self.archive_type is not None:
         name = os.path.basename(self._base_path)
     else:
         name = os.path.join(os.path.basename(self._base_path),
                             os.path.basename(self._image_files[self._current_image_index]))
     return encoding.to_unicode(name)
Exemplo n.º 12
0
 def get_book_name(self, book):
     """Return the name of <book>, or None if <book> isn't in the
     library.
     """
     cur = self._con.execute(
         '''SELECT name FROM Book
         WHERE id = ?''', (book, ))
     name = cur.fetchone()
     if name is None:
         return None
     return encoding.to_unicode(name)
Exemplo n.º 13
0
    def __init__(self, library, paths, collection):
        """Adds the books at <paths> to the library, and also to the
        <collection>, unless it is None.
        """
        gtk.Dialog.__init__(self, _('Adding books'), library, gtk.DIALOG_MODAL,
                            (gtk.STOCK_STOP, gtk.RESPONSE_CLOSE))
        self._destroy = False
        self.set_size_request(400, -1)
        self.set_has_separator(False)
        self.set_resizable(False)
        self.set_border_width(4)
        self.connect('response', self._response)
        self.set_default_response(gtk.RESPONSE_CLOSE)

        main_box = gtk.VBox(False, 5)
        main_box.set_border_width(6)
        self.vbox.pack_start(main_box, False, False)
        hbox = gtk.HBox(False, 10)
        main_box.pack_start(hbox, False, False, 5)
        left_box = gtk.VBox(True, 5)
        right_box = gtk.VBox(True, 5)
        hbox.pack_start(left_box, False, False)
        hbox.pack_start(right_box, False, False)

        label = labels.BoldLabel('%s:' % _('Added books'))
        label.set_alignment(1.0, 1.0)
        left_box.pack_start(label, True, True)
        number_label = gtk.Label('0')
        number_label.set_alignment(0, 1.0)
        right_box.pack_start(number_label, True, True)

        bar = gtk.ProgressBar()
        main_box.pack_start(bar, False, False)

        added_label = labels.ItalicLabel()
        added_label.set_alignment(0, 0.5)
        added_label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
        main_box.pack_start(added_label, False, False)
        self.show_all()

        total_paths = float(len(paths))
        total_added = 0
        for i, path in enumerate(paths):
            if library.backend.add_book(path, collection):
                total_added += 1
                number_label.set_text('%d' % total_added)
            added_label.set_text(
                _("Adding '%s'...") % encoding.to_unicode(path))
            bar.set_fraction((i + 1) / total_paths)
            while gtk.events_pending():
                gtk.main_iteration(False)
            if self._destroy:
                return
        self._response()
Exemplo n.º 14
0
    def __init__(self, library, paths, collection):
        """Adds the books at <paths> to the library, and also to the
        <collection>, unless it is None.
        """
        gtk.Dialog.__init__(self, _('Adding books'), library,
                            gtk.DIALOG_MODAL, (gtk.STOCK_STOP, gtk.RESPONSE_CLOSE))
        self._destroy = False
        self.set_size_request(400, -1)
        self.set_has_separator(False)
        self.set_resizable(False)
        self.set_border_width(4)
        self.connect('response', self._response)
        self.set_default_response(gtk.RESPONSE_CLOSE)

        main_box = gtk.VBox(False, 5)
        main_box.set_border_width(6)
        self.vbox.pack_start(main_box, False, False)
        hbox = gtk.HBox(False, 10)
        main_box.pack_start(hbox, False, False, 5)
        left_box = gtk.VBox(True, 5)
        right_box = gtk.VBox(True, 5)
        hbox.pack_start(left_box, False, False)
        hbox.pack_start(right_box, False, False)

        label = labels.BoldLabel('{}:'.format(_('Added books')))
        label.set_alignment(1.0, 1.0)
        left_box.pack_start(label, True, True)
        number_label = gtk.Label('0')
        number_label.set_alignment(0, 1.0)
        right_box.pack_start(number_label, True, True)

        bar = gtk.ProgressBar()
        main_box.pack_start(bar, False, False)

        added_label = labels.ItalicLabel()
        added_label.set_alignment(0, 0.5)
        added_label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
        main_box.pack_start(added_label, False, False)
        self.show_all()

        total_paths = float(len(paths))
        total_added = 0
        for i, path in enumerate(paths):
            if library.backend.add_book(path, collection):
                total_added += 1
                number_label.set_text('{:d}'.format(total_added))
            added_label.set_text(_("Adding '{}'...").format(encoding.to_unicode(path)))
            bar.set_fraction((i + 1) / total_paths)
            while gtk.events_pending():
                gtk.main_iteration(False)
            if self._destroy:
                return
        self._response()
Exemplo n.º 15
0
 def fetch_images(self):
     """Load all the images in the archive or directory."""
     for page in range(1, self._edit_dialog.file_handler.get_number_of_pages() + 1):
         thumb = self._edit_dialog.file_handler.get_thumbnail(
                 page, 67, 100, create=False)
         thumb = image.add_border(thumb, 1, 0x555555FF)
         path = self._edit_dialog.file_handler.get_path_to_page(page)
         self._liststore.append([thumb,
                                 encoding.to_unicode(os.path.basename(path)), path])
         if page % 10 == 0:
             while gtk.events_pending():
                 gtk.main_iteration(False)
             if self._edit_dialog.kill:
                 return
Exemplo n.º 16
0
 def fetch_images(self):
     """Load all the images in the archive or directory."""
     for page in range(
             1,
             self._edit_dialog.file_handler.get_number_of_pages() + 1):
         thumb = self._edit_dialog.file_handler.get_thumbnail(page,
                                                              67,
                                                              100,
                                                              create=False)
         thumb = image.add_border(thumb, 1, 0x555555FF)
         path = self._edit_dialog.file_handler.get_path_to_page(page)
         self._liststore.append(
             [thumb,
              encoding.to_unicode(os.path.basename(path)), path])
         if page % 10 == 0:
             while gtk.events_pending():
                 gtk.main_iteration(False)
             if self._edit_dialog.kill:
                 return
Exemplo n.º 17
0
 def _update_preview(self, *args):
     path = self.filechooser.get_preview_filename()
     if path and os.path.isfile(path):
         pixbuf = thumbnail.get_thumbnail(path, prefs['create thumbnails'])
         if pixbuf is None:
             self._preview_image.clear()
             self._namelabel.set_text('')
             self._sizelabel.set_text('')
         else:
             pixbuf = image.add_border(pixbuf, 1)
             self._preview_image.set_from_pixbuf(pixbuf)
             self._namelabel.set_text(
                 encoding.to_unicode(os.path.basename(path)))
             self._sizelabel.set_text('%.1f KiB' %
                                      (os.stat(path).st_size / 1024.0))
     else:
         self._preview_image.clear()
         self._namelabel.set_text('')
         self._sizelabel.set_text('')
Exemplo n.º 18
0
 def _update_preview(self, *args):
     path = self.filechooser.get_preview_filename()
     if path and os.path.isfile(path):
         pixbuf = thumbnail.get_thumbnail(path, prefs['create thumbnails'])
         if pixbuf is None:
             self._preview_image.clear()
             self._namelabel.set_text('')
             self._sizelabel.set_text('')
         else:
             pixbuf = image.add_border(pixbuf, 1)
             self._preview_image.set_from_pixbuf(pixbuf)
             self._namelabel.set_text(encoding.to_unicode(
                     os.path.basename(path)))
             self._sizelabel.set_text(
                     '{:.1f} KiB'.format(os.stat(path).st_size / 1024.0))
     else:
         self._preview_image.clear()
         self._namelabel.set_text('')
         self._sizelabel.set_text('')
Exemplo n.º 19
0
    def __init__(self, parent, total_thumbs):
        self._total_thumbs = total_thumbs
        self._destroy = False
        gtk.Dialog.__init__(self, _('Removing thumbnails'), parent, 0,
                            (gtk.STOCK_STOP, gtk.RESPONSE_CLOSE))
        self.set_size_request(400, -1)
        self.set_has_separator(False)
        self.set_resizable(False)
        self.set_border_width(4)
        self.connect('response', self._response)
        self.set_default_response(gtk.RESPONSE_CLOSE)
        main_box = gtk.VBox(False, 5)
        main_box.set_border_width(6)
        self.vbox.pack_start(main_box, False, False)

        hbox = gtk.HBox(False, 10)
        main_box.pack_start(hbox, False, False, 5)
        left_box = gtk.VBox(True, 5)
        right_box = gtk.VBox(True, 5)
        hbox.pack_start(left_box, False, False)
        hbox.pack_start(right_box, False, False)

        label = labels.BoldLabel('{}:'.format(_('Number of removed thumbnails')))
        label.set_alignment(1.0, 1.0)
        left_box.pack_start(label, True, True)
        number_label = gtk.Label('0')
        number_label.set_alignment(0, 1.0)
        right_box.pack_start(number_label, True, True)

        label = labels.BoldLabel('{}:'.format(_('Total size of removed thumbnails')))
        label.set_alignment(1.0, 1.0)
        left_box.pack_start(label, True, True)
        size_label = gtk.Label('0.0 MiB')
        size_label.set_alignment(0, 1.0)
        right_box.pack_start(size_label, True, True)

        bar = gtk.ProgressBar()
        main_box.pack_start(bar, False, False)

        removing_label = labels.ItalicLabel()
        removing_label.set_alignment(0, 0.5)
        removing_label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
        main_box.pack_start(removing_label, False, False)

        self.show_all()

        iteration = 0.0
        removed_thumbs = 0
        thumbs_size = 0
        for subdir in ('normal', 'large'):
            dir_path = os.path.join(_thumb_base, subdir)
            if not os.path.isdir(dir_path) or not os.access(dir_path, os.X_OK):
                continue
            for entry in os.listdir(dir_path):
                if self._destroy:
                    return
                iteration += 1
                entry_path = os.path.join(dir_path, entry)
                if not os.path.isfile(entry_path) or not os.access(entry_path,
                                                                   os.W_OK | os.R_OK):
                    continue
                try:
                    im_info = Image.open(entry_path).info
                    thumb_mtime = int(im_info['Thumb::MTime'])
                    src_path = _uri_to_path(im_info['Thumb::URI'])
                    broken = False
                except Exception:
                    src_path = '?'
                    broken = True
                else:
                    try:
                        src_mtime = os.stat(src_path).st_mtime
                    except Exception:
                        src_mtime = None
                # Thumb is orphaned, outdated or invalid.
                if broken or not os.path.isfile(src_path) or src_mtime != thumb_mtime:
                    size = os.stat(entry_path).st_size
                    try:
                        os.remove(entry_path)
                    except Exception:
                        continue
                    removed_thumbs += 1
                    thumbs_size += size
                    number_label.set_text('{:d}'.format(removed_thumbs))
                    size_label.set_text('{:.1f} MiB'.format(thumbs_size / 1048576.0))
                    if broken:
                        src_path = '?'
                    else:
                        src_path = encoding.to_unicode(src_path)
                    removing_label.set_text(_("Removed thumbnail for '{}'".format(src_path)))
                if iteration % 50 == 0:
                    bar.set_fraction(min(1, iteration / self._total_thumbs))
                while gtk.events_pending():
                    gtk.main_iteration(False)

        self._response()
Exemplo n.º 20
0
    def __init__(self, parent, total_thumbs):
        self._total_thumbs = total_thumbs
        self._destroy = False
        gtk.Dialog.__init__(self, _('Removing thumbnails'), parent, 0,
                            (gtk.STOCK_STOP, gtk.RESPONSE_CLOSE))
        self.set_size_request(400, -1)
        self.set_has_separator(False)
        self.set_resizable(False)
        self.set_border_width(4)
        self.connect('response', self._response)
        self.set_default_response(gtk.RESPONSE_CLOSE)
        main_box = gtk.VBox(False, 5)
        main_box.set_border_width(6)
        self.vbox.pack_start(main_box, False, False)

        hbox = gtk.HBox(False, 10)
        main_box.pack_start(hbox, False, False, 5)
        left_box = gtk.VBox(True, 5)
        right_box = gtk.VBox(True, 5)
        hbox.pack_start(left_box, False, False)
        hbox.pack_start(right_box, False, False)

        label = labels.BoldLabel('%s:' % _('Number of removed thumbnails'))
        label.set_alignment(1.0, 1.0)
        left_box.pack_start(label, True, True)
        number_label = gtk.Label('0')
        number_label.set_alignment(0, 1.0)
        right_box.pack_start(number_label, True, True)

        label = labels.BoldLabel('%s:' % _('Total size of removed thumbnails'))
        label.set_alignment(1.0, 1.0)
        left_box.pack_start(label, True, True)
        size_label = gtk.Label('0.0 MiB')
        size_label.set_alignment(0, 1.0)
        right_box.pack_start(size_label, True, True)

        bar = gtk.ProgressBar()
        main_box.pack_start(bar, False, False)

        removing_label = labels.ItalicLabel()
        removing_label.set_alignment(0, 0.5)
        removing_label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
        main_box.pack_start(removing_label, False, False)

        self.show_all()

        iteration = 0.0
        removed_thumbs = 0
        thumbs_size = 0
        for subdir in ('normal', 'large'):
            dir_path = os.path.join(_thumb_base, subdir)
            if not os.path.isdir(dir_path) or not os.access(dir_path, os.X_OK):
                continue
            for entry in os.listdir(dir_path):
                if self._destroy:
                    return
                iteration += 1
                entry_path = os.path.join(dir_path, entry)
                if not os.path.isfile(entry_path) or not os.access(
                        entry_path, os.W_OK | os.R_OK):
                    continue
                try:
                    im_info = Image.open(entry_path).info
                    thumb_mtime = int(im_info['Thumb::MTime'])
                    src_path = _uri_to_path(im_info['Thumb::URI'])
                    broken = False
                except Exception:
                    src_path = '?'
                    broken = True
                else:
                    try:
                        src_mtime = os.stat(src_path).st_mtime
                    except Exception:
                        src_mtime = None
                # Thumb is orphaned, outdated or invalid.
                if broken or not os.path.isfile(
                        src_path) or src_mtime != thumb_mtime:
                    size = os.stat(entry_path).st_size
                    try:
                        os.remove(entry_path)
                    except Exception:
                        continue
                    removed_thumbs += 1
                    thumbs_size += size
                    number_label.set_text('%d' % removed_thumbs)
                    size_label.set_text('%.1f MiB' % (thumbs_size / 1048576.0))
                    if broken:
                        src_path = '?'
                    else:
                        src_path = encoding.to_unicode(src_path)
                    removing_label.set_text(
                        _("Removed thumbnail for '%s'") % src_path)
                if iteration % 50 == 0:
                    bar.set_fraction(min(1, iteration / self._total_thumbs))
                while gtk.events_pending():
                    gtk.main_iteration(False)

        self._response()
Exemplo n.º 21
0
    def __init__(self, window):

        gtk.Dialog.__init__(self, _('Properties'), window, 0,
                            (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))

        self.set_resizable(False)
        self.set_has_separator(False)
        self.connect('response', _close_dialog)
        self.set_default_response(gtk.RESPONSE_CLOSE)
        notebook = gtk.Notebook()
        self.set_border_width(4)
        notebook.set_border_width(6)
        self.vbox.pack_start(notebook, False, False, 0)

        if window.file_handler.archive_type is not None:
            # ------------------------------------------------------------
            # Archive tab
            # ------------------------------------------------------------
            page = _Page()
            thumb = window.file_handler.get_thumbnail(1, width=200, height=128)
            page.set_thumbnail(thumb)
            filename = window.file_handler.get_pretty_current_filename()
            page.set_filename(filename)
            try:
                stats = os.stat(window.file_handler.get_path_to_base())
                main_info = (
                    _('{:d} pages').format(window.file_handler.get_number_of_pages()),
                    _('{:d} comments').format(window.file_handler.get_number_of_comments()),
                    archive.get_name(window.file_handler.archive_type),
                    '{:.1f} MiB'.format(stats.st_size / 1048576.0))
                page.set_main_info(main_info)
                try:
                    uid = pwd.getpwuid(stats.st_uid)[0]
                except Exception:
                    uid = str(stats.st_uid)
                secondary_info = (
                    (_('Location'), encoding.to_unicode(os.path.dirname(
                            window.file_handler.get_path_to_base()))),
                    (_('Accessed'), time.strftime('%Y-%m-%d, %H:%M:%S',
                                                  time.localtime(stats.st_atime))),
                    (_('Modified'), time.strftime('%Y-%m-%d, %H:%M:%S',
                                                  time.localtime(stats.st_mtime))),
                    (_('Permissions'), oct(stat.S_IMODE(stats.st_mode))),
                    (_('Owner'), uid))
                page.set_secondary_info(secondary_info)
            except Exception:
                pass
            notebook.append_page(page, gtk.Label(_('Archive')))

        # ----------------------------------------------------------------
        # Image tab
        # ----------------------------------------------------------------
        path = window.file_handler.get_path_to_page()
        page = _Page()
        thumb = window.file_handler.get_thumbnail(width=200, height=128)
        page.set_thumbnail(thumb)
        filename = os.path.basename(path)
        page.set_filename(filename)
        try:
            stats = os.stat(path)
            width, height = window.file_handler.get_size()
            main_info = (
                '{:d}x{:d} px'.format(width, height),
                window.file_handler.get_mime_name(),
                '{:.1f} KiB'.format(stats.st_size / 1024.0))
            page.set_main_info(main_info)
            try:
                uid = pwd.getpwuid(stats.st_uid)[0]
            except Exception:
                uid = str(stats.st_uid)
            secondary_info = (
                (_('Location'), encoding.to_unicode(os.path.dirname(path))),
                (_('Accessed'), time.strftime('%Y-%m-%d, %H:%M:%S',
                                              time.localtime(stats.st_atime))),
                (_('Modified'), time.strftime('%Y-%m-%d, %H:%M:%S',
                                              time.localtime(stats.st_mtime))),
                (_('Permissions'), oct(stat.S_IMODE(stats.st_mode))),
                (_('Owner'), uid))
            page.set_secondary_info(secondary_info)
        except Exception:
            pass
        notebook.append_page(page, gtk.Label(_('Image')))
        self.show_all()
Exemplo n.º 22
0
 def set_filename(self, filename):
     """Update the filename."""
     self._filename = encoding.to_unicode(filename)
Exemplo n.º 23
0
 def set_root(self, root):
     """Set the name of the root (directory or archive)."""
     self._root = encoding.to_unicode(root)
Exemplo n.º 24
0
 def set_message(self, message):
     """Set a specific message (such as an error message) on the statusbar,
     replacing whatever was there earlier.
     """
     self.pop(0)
     self.push(0, u' {}'.format(encoding.to_unicode(message)))
Exemplo n.º 25
0
    def __init__(self, window):
        self._num_thumbs = 0
        gtk.Dialog.__init__(self, _('Thumbnail maintenance'), window, 0,
                            (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
        button = self.add_button(_('Cleanup'), gtk.RESPONSE_OK)
        button.set_image(
            gtk.image_new_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_BUTTON))
        self.set_has_separator(False)
        self.set_resizable(False)
        self.set_border_width(4)
        self.connect('response', self._response)
        self.set_default_response(gtk.RESPONSE_OK)
        main_box = gtk.VBox(False, 5)
        main_box.set_border_width(6)
        self.vbox.pack_start(main_box, False, False)

        label = labels.BoldLabel(_('Cleanup thumbnails'))
        label.set_alignment(0, 0.5)
        attrlist = label.get_attributes()
        attrlist.insert(
            pango.AttrScale(pango.SCALE_LARGE, 0, len(label.get_text())))
        label.set_attributes(attrlist)
        main_box.pack_start(label, False, False, 2)
        main_box.pack_start(gtk.HSeparator(), False, False, 5)

        label = labels.ItalicLabel(
            _('Thumbnails for files (such as image '
              'files and comic book archives) are stored '
              'in your home directory. Many different '
              'applications use and create these thumbnails,'
              ' but sometimes thumbnails remain even though '
              'the original files have been removed - wasting '
              'space. This dialog can cleanup your stored '
              'thumbnails by removing orphaned and outdated '
              'thumbnails.'))
        label.set_alignment(0, 0.5)
        label.set_line_wrap(True)
        main_box.pack_start(label, False, False, 10)

        hbox = gtk.HBox(False, 10)
        main_box.pack_start(hbox, False, False)
        left_box = gtk.VBox(True, 5)
        right_box = gtk.VBox(True, 5)
        hbox.pack_start(left_box, False, False)
        hbox.pack_start(right_box, False, False)

        label = labels.BoldLabel('%s:' % _('Thumbnail directory'))
        label.set_alignment(1.0, 1.0)
        left_box.pack_start(label, True, True)
        label = gtk.Label('%s' % encoding.to_unicode(_thumb_base))
        label.set_alignment(0, 1.0)
        right_box.pack_start(label, True, True)

        label = labels.BoldLabel('%s:' % _('Total number of thumbnails'))
        label.set_alignment(1.0, 1.0)
        left_box.pack_start(label, True, True)
        self._num_thumbs_label = gtk.Label(_('Calculating...'))
        self._num_thumbs_label.set_alignment(0, 1.0)
        right_box.pack_start(self._num_thumbs_label, True, True)

        label = labels.BoldLabel('%s:' % _('Total size of thumbnails'))
        label.set_alignment(1.0, 1.0)
        left_box.pack_start(label, True, True)
        self._size_thumbs_label = gtk.Label(_('Calculating...'))
        self._size_thumbs_label.set_alignment(0, 1.0)
        right_box.pack_start(self._size_thumbs_label, True, True)

        label = labels.ItalicLabel(
            _('Do you want to cleanup orphaned and outdated thumbnails now?'))
        label.set_alignment(0, 0.5)
        main_box.pack_start(label, False, False, 10)

        self.show_all()
        while gtk.events_pending():
            gtk.main_iteration(False)
        self._update_num_and_size()
Exemplo n.º 26
0
    def __init__(self, window):
        self._num_thumbs = 0
        gtk.Dialog.__init__(self, _('Thumbnail maintenance'), window, 0,
                            (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
        button = self.add_button(_('Cleanup'), gtk.RESPONSE_OK)
        button.set_image(gtk.image_new_from_stock(
                gtk.STOCK_CLEAR, gtk.ICON_SIZE_BUTTON))
        self.set_has_separator(False)
        self.set_resizable(False)
        self.set_border_width(4)
        self.connect('response', self._response)
        self.set_default_response(gtk.RESPONSE_OK)
        main_box = gtk.VBox(False, 5)
        main_box.set_border_width(6)
        self.vbox.pack_start(main_box, False, False)

        label = labels.BoldLabel(_('Cleanup thumbnails'))
        label.set_alignment(0, 0.5)
        attrlist = label.get_attributes()
        attrlist.insert(pango.AttrScale(pango.SCALE_LARGE, 0,
                                        len(label.get_text())))
        label.set_attributes(attrlist)
        main_box.pack_start(label, False, False, 2)
        main_box.pack_start(gtk.HSeparator(), False, False, 5)

        label = labels.ItalicLabel(_('Thumbnails for files (such as image '
                                     'files and comic book archives) are stored '
                                     'in your home directory. Many different '
                                     'applications use and create these thumbnails,'
                                     ' but sometimes thumbnails remain even though '
                                     'the original files have been removed - wasting '
                                     'space. This dialog can cleanup your stored '
                                     'thumbnails by removing orphaned and outdated '
                                     'thumbnails.'))
        label.set_alignment(0, 0.5)
        label.set_line_wrap(True)
        main_box.pack_start(label, False, False, 10)

        hbox = gtk.HBox(False, 10)
        main_box.pack_start(hbox, False, False)
        left_box = gtk.VBox(True, 5)
        right_box = gtk.VBox(True, 5)
        hbox.pack_start(left_box, False, False)
        hbox.pack_start(right_box, False, False)

        label = labels.BoldLabel('{}:'.format(_('Thumbnail directory')))
        label.set_alignment(1.0, 1.0)
        left_box.pack_start(label, True, True)
        label = gtk.Label(u'{}'.format(encoding.to_unicode(_thumb_base)))
        label.set_alignment(0, 1.0)
        right_box.pack_start(label, True, True)

        label = labels.BoldLabel('{}:'.format(_('Total number of thumbnails')))
        label.set_alignment(1.0, 1.0)
        left_box.pack_start(label, True, True)
        self._num_thumbs_label = gtk.Label(_('Calculating...'))
        self._num_thumbs_label.set_alignment(0, 1.0)
        right_box.pack_start(self._num_thumbs_label, True, True)

        label = labels.BoldLabel('{}:'.format(_('Total size of thumbnails')))
        label.set_alignment(1.0, 1.0)
        left_box.pack_start(label, True, True)
        self._size_thumbs_label = gtk.Label(_('Calculating...'))
        self._size_thumbs_label.set_alignment(0, 1.0)
        right_box.pack_start(self._size_thumbs_label, True, True)

        label = labels.ItalicLabel(
                _('Do you want to cleanup orphaned and outdated thumbnails now?'))
        label.set_alignment(0, 0.5)
        main_box.pack_start(label, False, False, 10)

        self.show_all()
        while gtk.events_pending():
            gtk.main_iteration(False)
        self._update_num_and_size()
Exemplo n.º 27
0
 def set_status_message(self, message):
     """Set a specific message on the statusbar, replacing whatever was
     there earlier.
     """
     self._statusbar.pop(0)
     self._statusbar.push(0, ' %s' % encoding.to_unicode(message))
Exemplo n.º 28
0
    def __init__(self, window):

        gtk.Dialog.__init__(self, _('Properties'), window, 0,
                            (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))

        self.set_resizable(False)
        self.set_has_separator(False)
        self.connect('response', _close_dialog)
        self.set_default_response(gtk.RESPONSE_CLOSE)
        notebook = gtk.Notebook()
        self.set_border_width(4)
        notebook.set_border_width(6)
        self.vbox.pack_start(notebook, False, False, 0)

        if window.file_handler.archive_type is not None:
            # ------------------------------------------------------------
            # Archive tab
            # ------------------------------------------------------------
            page = _Page()
            thumb = window.file_handler.get_thumbnail(1, width=200, height=128)
            page.set_thumbnail(thumb)
            filename = window.file_handler.get_pretty_current_filename()
            page.set_filename(filename)
            try:
                stats = os.stat(window.file_handler.get_path_to_base())
                main_info = (_('%d pages') %
                             window.file_handler.get_number_of_pages(),
                             _('%d comments') %
                             window.file_handler.get_number_of_comments(),
                             archive.get_name(
                                 window.file_handler.archive_type),
                             '%.1f MiB' % (stats.st_size / 1048576.0))
                page.set_main_info(main_info)
                try:
                    uid = pwd.getpwuid(stats.st_uid)[0]
                except Exception:
                    uid = str(stats.st_uid)
                secondary_info = (
                    (_('Location'),
                     encoding.to_unicode(
                         os.path.dirname(
                             window.file_handler.get_path_to_base()))),
                    (_('Accessed'),
                     time.strftime('%Y-%m-%d, %H:%M:%S',
                                   time.localtime(stats.st_atime))),
                    (_('Modified'),
                     time.strftime('%Y-%m-%d, %H:%M:%S',
                                   time.localtime(stats.st_mtime))),
                    (_('Permissions'),
                     oct(stat.S_IMODE(stats.st_mode))), (_('Owner'), uid))
                page.set_secondary_info(secondary_info)
            except Exception:
                pass
            notebook.append_page(page, gtk.Label(_('Archive')))

        # ----------------------------------------------------------------
        # Image tab
        # ----------------------------------------------------------------
        path = window.file_handler.get_path_to_page()
        page = _Page()
        thumb = window.file_handler.get_thumbnail(width=200, height=128)
        page.set_thumbnail(thumb)
        filename = os.path.basename(path)
        page.set_filename(filename)
        try:
            stats = os.stat(path)
            width, height = window.file_handler.get_size()
            main_info = ('%dx%d px' % (width, height),
                         window.file_handler.get_mime_name(),
                         '%.1f KiB' % (stats.st_size / 1024.0))
            page.set_main_info(main_info)
            try:
                uid = pwd.getpwuid(stats.st_uid)[0]
            except Exception:
                uid = str(stats.st_uid)
            secondary_info = ((_('Location'),
                               encoding.to_unicode(os.path.dirname(path))),
                              (_('Accessed'),
                               time.strftime('%Y-%m-%d, %H:%M:%S',
                                             time.localtime(stats.st_atime))),
                              (_('Modified'),
                               time.strftime('%Y-%m-%d, %H:%M:%S',
                                             time.localtime(stats.st_mtime))),
                              (_('Permissions'),
                               oct(stat.S_IMODE(stats.st_mode))), (_('Owner'),
                                                                   uid))
            page.set_secondary_info(secondary_info)
        except Exception:
            pass
        notebook.append_page(page, gtk.Label(_('Image')))
        self.show_all()