def set_filename(self, filename): """Set the filename to be displayed to <filename>. Call this before set_main_info(). """ label = labels.BoldLabel(i18n.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?)
def set_filename(self, filename): '''Set the filename to be displayed to <filename>. Call this before set_main_info(). ''' label = labels.BoldLabel(i18n.to_unicode(filename)) label.set_alignment(0, 0.5) label.set_selectable(True) self._mainbox.pack_start(label, False, False, 0) self._mainbox.pack_start(Gtk.VBox(homogeneous=True, spacing=0), True, True, 0) # Just to add space (better way?)
def __init__(self, header, right_column_width): """Contruct a new section with the header set to the text in <header>, and the width request of the (possible) right columns set to that of <right_column_width>. """ super(_PreferenceSection, self).__init__(False, 0) self._right_column_width = right_column_width self.contentbox = gtk.VBox(False, 6) label = labels.BoldLabel(header) label.set_alignment(0, 0.5) hbox = gtk.HBox(False, 0) hbox.pack_start(gtk.HBox(), False, False, 6) hbox.pack_start(self.contentbox) self.pack_start(label, False, False) self.pack_start(hbox, False, False, 6)
def __init__(self, header, right_column_width): '''Contruct a new section with the header set to the text in <header>, and the width request of the (possible) right columns set to that of <right_column_width>. ''' super(_PreferenceSection, self).__init__(homogeneous=False, spacing=0) self._right_column_width = right_column_width self.contentbox = Gtk.VBox(homogeneous=False, spacing=6) label = labels.BoldLabel(header) label.set_alignment(0, 0.5) hbox = Gtk.HBox(homogeneous=False, spacing=0) hbox.pack_start(Gtk.HBox(homogeneous=True, spacing=0), False, False, 6) hbox.pack_start(self.contentbox, True, True, 0) self.pack_start(label, False, False, 0) self.pack_start(hbox, False, False, 6)
def set_secondary_info(self, info): """Set the information below the main info box to the values in the sequence <info>. Each entry in info should be a tuple (desc, value). """ left_box = gtk.VBox(True, 8) right_box = gtk.VBox(True, 8) self._extrabox.pack_start(left_box, False, False) self._extrabox.pack_start(right_box, False, False) for desc, value in info: desc_label = labels.BoldLabel('%s:' % desc) desc_label.set_alignment(1.0, 1.0) left_box.pack_start(desc_label, True, True) value_label = gtk.Label(value) value_label.set_alignment(0, 1.0) value_label.set_selectable(True) right_box.pack_start(value_label, True, True)
def __init__(self, library, window, paths, collection): """Adds the books at <paths> to the library, and also to the <collection>, unless it is None. """ super(_AddLibraryProgressDialog, self).__init__(_('Adding books'), library, Gtk.DialogFlags.MODAL, (Gtk.STOCK_STOP, Gtk.ResponseType.CLOSE)) self._window = window self._destroy = False self.set_size_request(400, -1) self.set_resizable(False) self.set_border_width(4) self.connect('response', self._response) self.set_default_response(Gtk.ResponseType.CLOSE) main_box = Gtk.VBox(homogeneous=False, spacing=5) main_box.set_border_width(6) self.vbox.pack_start(main_box, False, False, 0) hbox = Gtk.HBox(homogeneous=False, spacing=10) main_box.pack_start(hbox, False, False, 5) left_box = Gtk.VBox(homogeneous=True, spacing=5) right_box = Gtk.VBox(homogeneous=True, spacing=5) hbox.pack_start(left_box, False, False, 0) hbox.pack_start(right_box, False, False, 0) label = labels.BoldLabel(_('Added books:')) label.set_alignment(1.0, 1.0) left_box.pack_start(label, True, True, 0) number_label = Gtk.Label(label='0') number_label.set_alignment(0, 1.0) right_box.pack_start(number_label, True, True, 0) bar = Gtk.ProgressBar() main_box.pack_start(bar, False, False, 0) added_label = labels.ItalicLabel() added_label.set_alignment(0, 0.5) added_label.set_width_chars(64) added_label.set_max_width_chars(64) added_label.set_ellipsize(Pango.EllipsizeMode.MIDDLE) main_box.pack_start(added_label, False, False, 0) self.show_all() total_paths_int = len(paths) total_paths_float = float(len(paths)) total_added = 0 for path in paths: if library.backend.add_book(path, collection): total_added += 1 number_label.set_text('%d / %d' % (total_added, total_paths_int)) added_label.set_text(_("Adding '%s'...") % path) bar.set_fraction(total_added / total_paths_float) while Gtk.events_pending(): Gtk.main_iteration_do(False) if self._destroy: return self._response()
def __init__(self, library): super(_ControlArea, self).__init__(homogeneous=False, spacing=12) self._library = library self.set_border_width(10) borderbox = Gtk.Frame() borderbox.set_shadow_type(Gtk.ShadowType.ETCHED_IN) borderbox.set_size_request(350, -1) insidebox = Gtk.EventBox() insidebox.set_border_width(1) insidebox.set_state(Gtk.StateType.ACTIVE) infobox = Gtk.VBox(homogeneous=False, spacing=5) infobox.set_border_width(10) self.pack_start(borderbox, True, True, 0) borderbox.add(insidebox) insidebox.add(infobox) self._namelabel = labels.BoldLabel() self._namelabel.set_alignment(0, 0.5) self._namelabel.set_selectable(True) self._namelabel.set_ellipsize(Pango.EllipsizeMode.MIDDLE) infobox.pack_start(self._namelabel, False, False, 0) self._filelabel = Gtk.Label() self._filelabel.set_ellipsize(Pango.EllipsizeMode.MIDDLE) self._filelabel.set_alignment(0, 0.5) infobox.pack_start(self._filelabel, False, False, 0) self._dirlabel = Gtk.Label() self._dirlabel.set_ellipsize(Pango.EllipsizeMode.MIDDLE) self._dirlabel.set_alignment(0, 0.5) self._dirlabel.set_selectable(True) infobox.pack_start(self._dirlabel, False, False, 0) vbox = Gtk.VBox(homogeneous=False, spacing=10) vbox.set_size_request(350, -1) self.pack_start(vbox, False, False, 0) # First line of controls, containing the search box hbox = Gtk.HBox(homogeneous=False) vbox.pack_start(hbox, True, True, 0) label = Gtk.Label(label=_('_Search:')) label.set_use_underline(True) hbox.pack_start(label, False, False, 0) search_entry = Gtk.Entry() search_entry.connect('activate', self._filter_books) search_entry.set_tooltip_text( _('Display only those books that have the specified text string ' 'in their full path. The search is not case sensitive.')) hbox.pack_start(search_entry, True, True, 6) label.set_mnemonic_widget(search_entry) # Last line of controls, containing buttons like 'Open' hbox = Gtk.HBox(homogeneous=False, spacing=10) vbox.pack_end(hbox, True, True, 0) watchlist_button = Gtk.Button(label=_('_Watch list'), use_underline=True) watchlist_button.set_always_show_image(True) watchlist_button.set_image( Gtk.Image.new_from_stock(Gtk.STOCK_FIND, Gtk.IconSize.BUTTON)) watchlist_button.set_image_position(Gtk.PositionType.LEFT) watchlist_button.connect('clicked', lambda *args: WatchListDialog(self._library)) watchlist_button.set_tooltip_text( _('Open the watchlist management dialog.')) hbox.pack_start(watchlist_button, True, True, 0) self._open_button = Gtk.Button(label=_('_Open list'), use_underline=True) self._open_button.set_always_show_image(True) self._open_button.set_image( Gtk.Image.new_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.BUTTON)) self._open_button.set_image_position(Gtk.PositionType.LEFT) self._open_button.connect('clicked', self._library.book_area.open_selected_book) self._open_button.set_tooltip_text(_('Open the selected book.')) self._open_button.set_sensitive(False) hbox.pack_end(self._open_button, True, True, 0)
def __init__(self, library): gtk.HBox.__init__(self, False, 12) self._library = library self.set_border_width(10) borderbox = gtk.EventBox() borderbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#333')) borderbox.set_size_request(350, -1) insidebox = gtk.EventBox() insidebox.set_border_width(1) insidebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ddb')) infobox = gtk.VBox(False, 5) infobox.set_border_width(10) self.pack_start(borderbox, False, False) borderbox.add(insidebox) insidebox.add(infobox) self._namelabel = labels.BoldLabel() self._namelabel.set_alignment(0, 0.5) self._namelabel.set_selectable(True) self._namelabel.set_ellipsize(pango.ELLIPSIZE_MIDDLE) infobox.pack_start(self._namelabel, False, False) self._filelabel = gtk.Label() self._filelabel.set_ellipsize(pango.ELLIPSIZE_MIDDLE) self._filelabel.set_alignment(0, 0.5) infobox.pack_start(self._filelabel, False, False) self._dirlabel = gtk.Label() self._dirlabel.set_ellipsize(pango.ELLIPSIZE_MIDDLE) self._dirlabel.set_alignment(0, 0.5) self._dirlabel.set_selectable(True) infobox.pack_start(self._dirlabel, False, False) vbox = gtk.VBox(False, 10) self.pack_start(vbox, True, True) # First line of controls, containing the search box hbox = gtk.HBox(False) vbox.pack_start(hbox, False, False) label = gtk.Label(_('_Search:')) label.set_use_underline(True) hbox.pack_start(label, False, False) search_entry = gtk.Entry() search_entry.connect('activate', self._filter_books) search_entry.set_tooltip_text( _('Display only those books that have the specified text string ' 'in their full path. The search is not case sensitive.')) hbox.pack_start(search_entry, True, True, 6) label.set_mnemonic_widget(search_entry) # Last line of controls, containing buttons like 'Open' hbox = gtk.HBox(False, 10) vbox.pack_end(hbox, False, False) watchlist_button = gtk.Button(_("_Watch list")) watchlist_button.set_image( gtk.image_new_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_BUTTON)) watchlist_button.connect('clicked', lambda *args: WatchListDialog(self._library)) watchlist_button.set_tooltip_text( _('Open the watchlist management dialog.')) hbox.pack_start(watchlist_button, expand=False) self._open_button = gtk.Button(None, gtk.STOCK_OPEN) self._open_button.connect('clicked', self._library.book_area.open_selected_book) self._open_button.set_tooltip_text(_('Open the selected book.')) self._open_button.set_sensitive(False) hbox.pack_end(self._open_button, False, False)
def __init__(self, library, window, 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._window = window 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(_('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_int = len(paths) total_paths_float = float(len(paths)) total_added = 0 for path in paths: if library.backend.add_book(path, collection): total_added += 1 number_label.set_text('%d / %d' % (total_added, total_paths_int)) added_label.set_text(_("Adding '%s'...") % path) bar.set_fraction(total_added / total_paths_float) while gtk.events_pending(): gtk.main_iteration(False) if self._destroy: return self._response()