コード例 #1
0
ファイル: library.py プロジェクト: ZhanruiLiang/Comix
 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('')
コード例 #2
0
ファイル: library.py プロジェクト: foxes485/comix
 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('')
コード例 #3
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()
コード例 #4
0
ファイル: properties.py プロジェクト: BRRussell/Comix
    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()