def __setup_treeview_files(self): treeview = self.builder.get_object('treeview_files') store = gtk.TreeStore(str, float, float, bool) # filename, size, date, locked treeview.set_model(store) # constants for model and columns self.__FILENAME = 0 self.__SIZE = 1 self.__DATE = 2 self.__ISDIR = 3 # create the TreeViewColumns to display the data column_names = ['Dateiname', 'Größe', 'Geändert' ] tvcolumns = [None] * len(column_names) # pixbuf and filename cell_renderer_pixbuf = gtk.CellRendererPixbuf() tvcolumns[self.__FILENAME] = gtk.TreeViewColumn(column_names[self.__FILENAME], cell_renderer_pixbuf) cell_renderer_text_name = gtk.CellRendererText() tvcolumns[self.__FILENAME].pack_start(cell_renderer_text_name, False) tvcolumns[self.__FILENAME].set_cell_data_func(cell_renderer_pixbuf, self.__tv_files_pixbuf) tvcolumns[self.__FILENAME].set_cell_data_func(cell_renderer_text_name, self.__tv_files_name) # size cell_renderer_text_size = gtk.CellRendererText() cell_renderer_text_size.set_property('xalign', 1.0) tvcolumns[self.__SIZE] = gtk.TreeViewColumn(column_names[self.__SIZE], cell_renderer_text_size) tvcolumns[self.__SIZE].set_cell_data_func(cell_renderer_text_size, self.__tv_files_size) # date cell_renderer_text_date = gtk.CellRendererText() tvcolumns[self.__DATE] = gtk.TreeViewColumn(column_names[self.__DATE], cell_renderer_text_date) tvcolumns[self.__DATE].set_cell_data_func(cell_renderer_text_date, self.__tv_files_date) # append the columns for col in tvcolumns: col.set_resizable(True) treeview.append_column(col) # allow multiple selection treeselection = treeview.get_selection() treeselection.set_mode(gtk.SELECTION_MULTIPLE) # sorting treeview.get_model().set_sort_func(0, self.__tv_files_sort) tvcolumns[self.__FILENAME].set_sort_column_id(0) tvcolumns[self.__SIZE].set_sort_column_id(1) tvcolumns[self.__DATE].set_sort_column_id(2) # load pixbufs for treeview self.__pix_avi = gtk.gdk.pixbuf_new_from_file(path.get_image_path('avi.png')) self.__pix_otrkey = gtk.gdk.pixbuf_new_from_file(path.get_image_path('decode.png')) self.__pix_folder = gtk.gdk.pixbuf_new_from_file(path.get_image_path('folder.png'))
def _on_menuHelpAbout_activate(self, widget, data=None): version = open(path.getdatapath("VERSION"), 'r').read().strip() # TODO: script_root_dir won't work when program is installed? script_root_dir = os.path.abspath( os.path.realpath(sys.argv[0]) + '/../..') with open(os.path.join(script_root_dir, 'AUTHORS'), 'r') as f: authors = f.readlines() authors = [x.strip() for x in authors] with open(os.path.join(script_root_dir, 'LICENSE'), 'r') as f: license = f.read() about_dialog = Gtk.AboutDialog( parent=self.gui.main_window, program_name=self.app.app_name, version=version, copyright='\xa9 2010 - ' + str(datetime.datetime.now().year) + ' B. Elbers and others', license=license, website='https://github.com/EinApfelBaum/otr-verwaltung3p/wiki', comments='Zum Verwalten von Dateien von onlinetvrecorder.com', authors=authors, logo=GdkPixbuf.Pixbuf.new_from_file( path.get_image_path('icon.png'))) # ~ title='About {}'.format(self.app.app_name)) about_dialog.set_destroy_with_parent(True) about_dialog.set_size_request(500, 300) about_dialog.run() about_dialog.destroy()
def _on_menuHelpAbout_activate(self, widget, data=None): def open_website(dialog, url, data=None): webbrowser.open(url) # Gtk.about_dialog_set_url_hook(open_website) about_dialog = Gtk.AboutDialog() about_dialog.set_transient_for(self.gui.main_window) about_dialog.set_destroy_with_parent(True) about_dialog.set_name(self.app.app_name) about_dialog.set_logo( GdkPixbuf.Pixbuf.new_from_file(path.get_image_path('icon.png'))) version = open(path.getdatapath("VERSION"), 'r').read().strip() about_dialog.set_version(version) about_dialog.set_website("http://elbersb.de/otrverwaltung") about_dialog.set_comments( "Zum Verwalten von Dateien von onlinetvrecorder.com.") about_dialog.set_copyright( "Copyright \xc2\xa9 2010 Benjamin Elbers and others") about_dialog.set_authors([ "Benjamin Elbers", "JanS", "monarc99", "EinApfelbaum", "Timo08", "gCurse" ]) about_dialog.run() about_dialog.destroy()
def __init__(self): gtk.TreeView.__init__(self) self.pixbuf_warning = gtk.gdk.pixbuf_new_from_file(path.get_image_path('error.png')) self.errors = { "100000" : "Fehlender Beginn", "010000" : "Fehlendes Ende", "001000" : "Kein Video", "000100" : "Kein Audio", "000010" : "Anderer Fehler", "000001" : "Falscher Inhalt/EPG-Error" } # setup combobox_archive self.liststore = gtk.ListStore(object) self.set_model(self.liststore) # create the TreeViewColumns to display the data column_names = [ ("Autor", 'author'), ("Autorw.", 'ratingbyauthor'), ("Benutzerw.", self._treeview_rating), ("Loads", "downloadcount"), ("Kommentar", 'usercomment'), ("Fehler", self._treeview_errors), ("Dauer (s)", "duration"), ("Schnitte", "countcuts"), ("Eigentlicher Inhalt", self._treeview_actualcontent), ("Dateiname", "filename"), ] # add a pixbuf renderer in case of errors in cutlists cell_renderer_pixbuf = gtk.CellRendererPixbuf() col = gtk.TreeViewColumn('', cell_renderer_pixbuf) col.set_cell_data_func(cell_renderer_pixbuf, self._treeview_warning) self.append_column(col) # append the columns for count, (text, data_func) in enumerate(column_names): renderer_left = gtk.CellRendererText() renderer_left.set_property('xalign', 0.0) col = gtk.TreeViewColumn(text, renderer_left) if type(data_func) == str: col.set_cell_data_func(renderer_left, self._treeview_standard, data_func) else: col.set_cell_data_func(renderer_left, data_func) #col.set_resizable(False) #col.set_fixed_width(0) col.set_resizable(True) col.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) self.append_column(col)
def _on_button_config_clicked(self, widget, data=None): store, iter = self.builder.get_object('treeview_plugins').get_selection().get_selected() name = store.get_value(iter, 3) dialog = gtk.Dialog(store.get_value(iter, 1) + " - Einstellungen", parent=self, flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) dialog.set_border_width(2) dialog.set_icon(gtk.gdk.pixbuf_new_from_file(path.get_image_path('icon3.png'))) dialog = self.gui.app.plugin_system.plugins[name].configurate(dialog) dialog.show_all() dialog.run() dialog.hide()
def __setup_widgets(self): self.builder.get_object('menu_bottom').set_active(self.app.config.get('general', 'show_bottom')) self.builder.get_object('image_status').clear() ## sidebar ## self.sidebar = Sidebar() planned = self.sidebar.add_element(Section.PLANNING, 'Geplante Sendungen', False) self.sidebar.add_element(Section.DOWNLOAD, 'Downloads', False) self.sidebar.add_section('OTRKEYS') self.sidebar.add_element(Section.OTRKEY, 'Nicht dekodiert') self.sidebar.add_section('VIDEOS') self.sidebar.add_element(Section.VIDEO_UNCUT, 'Ungeschnitten') self.sidebar.add_element(Section.VIDEO_CUT, 'Geschnitten') self.sidebar.add_element(Section.ARCHIVE, 'Archiv') self.sidebar.add_element(Section.TRASH, 'Mülleimer', False) self.builder.get_object('hbox_main').pack_start(self.sidebar, expand=False) self.builder.get_object('hbox_main').reorder_child(self.sidebar, 0) self.sidebar.connect('element-clicked', self._on_sidebar_toggled) self.sidebar.set_active(Section.DOWNLOAD) # add planning badge self.eventbox_planning = gtk.EventBox() self.label_planning_current = gtk.Label() self.eventbox_planning.add(self.label_planning_current) self.eventbox_planning.set_size_request(30, 15) style = self.eventbox_planning.get_style().copy() pixmap, mask = gtk.gdk.pixbuf_new_from_file(path.get_image_path('badge.png')).render_pixmap_and_mask() style.bg_pixmap[gtk.STATE_NORMAL] = pixmap self.eventbox_planning.shape_combine_mask(mask, 0, 0) self.eventbox_planning.set_style(style) planned.add_widget(self.eventbox_planning) self.sidebar.show_all() ## sidebar end ## # change background of conclusin bar eventbox = self.builder.get_object('box_conclusion') cmap = eventbox.get_colormap() colour = cmap.alloc_color("#E8E7B6") style = eventbox.get_style().copy() style.bg[gtk.STATE_NORMAL] = colour eventbox.set_style(style)
def __init__(self): Gtk.TreeView.__init__(self) self.pixbuf_warning = GdkPixbuf.Pixbuf.new_from_file( path.get_image_path('error.png')) self.errors = { "100000": "Fehlender Beginn", "010000": "Fehlendes Ende", "001000": "Kein Video", "000100": "Kein Audio", "000010": "Anderer Fehler", "000001": "Falscher Inhalt/EPG-Error" } # setup combobox_archive self.liststore = Gtk.ListStore(object) self.set_model(self.liststore) # create the TreeViewColumns to display the data column_names = [("Autor", 'author'), ("Autorwertung", 'ratingbyauthor'), ("Benutzerwertung", self._treeview_rating), ("Kommentar", 'usercomment'), ("Fehler", self._treeview_errors), ("Eigentlicher Inhalt", self._treeview_actualcontent), ("Anzahl d. Schnitte", "countcuts"), ("Dateiname", "filename"), ("Dauer in s", "duration"), ("Anzahl Heruntergeladen", "downloadcount")] # add a pixbuf renderer in case of errors in cutlists cell_renderer_pixbuf = Gtk.CellRendererPixbuf() col = Gtk.TreeViewColumn('', cell_renderer_pixbuf) col.set_cell_data_func(cell_renderer_pixbuf, self._treeview_warning) self.append_column(col) # append the columns for count, (text, data_func) in enumerate(column_names): renderer_left = Gtk.CellRendererText() renderer_left.set_property('xalign', 0.0) col = Gtk.TreeViewColumn(text, renderer_left) if type(data_func) == str: col.set_cell_data_func(renderer_left, self._treeview_standard, data_func) else: col.set_cell_data_func(renderer_left, data_func) col.set_resizable(True) self.append_column(col)
def do_parser_finished(self, builder): self.builder = builder self.builder.connect_signals(self) self.cutlists_treeview = CutlistsTreeView() self.cutlists_treeview.show() self.cutlists_treeview.get_selection().connect("changed", self.treeview_cutlists_selection_changed) self.builder.get_object("scrolledwindow_cutlists").add(self.cutlists_treeview) animation = gtk.gdk.PixbufAnimation(path.get_image_path("spinner.gif")) self.builder.get_object("image_spinner").set_from_animation(animation) self.builder.get_object("image_spinner_download").set_from_animation(animation) selection = self.builder.get_object("treeview_programs").get_selection() selection.connect("changed", self.treeview_programs_selection_changed)
def _on_button_config_clicked(self, widget, data=None): store, iter = self.builder.get_object( 'treeview_plugins').get_selection().get_selected() name = store.get_value(iter, 3) dialog = Gtk.Dialog(store.get_value(iter, 1) + " - Einstellungen", parent=self, flags=Gtk.DialogFlags.MODAL, buttons=(Gtk.STOCK_CLOSE, Gtk.ResponseType.CLOSE)) dialog.set_border_width(2) dialog.set_icon( GdkPixbuf.Pixbuf.new_from_file(path.get_image_path('icon.png'))) dialog = self.gui.app.plugin_system.plugins[name].configurate(dialog) dialog.show_all() dialog.run() dialog.hide()
def do_parser_finished(self, builder): self.builder = builder self.builder.connect_signals(self) self.cutlists_treeview = CutlistsTreeView() self.cutlists_treeview.show() self.cutlists_treeview.get_selection().connect( 'changed', self.treeview_cutlists_selection_changed) self.builder.get_object('scrolledwindow_cutlists').add( self.cutlists_treeview) animation = gtk.gdk.PixbufAnimation(path.get_image_path("spinner.gif")) self.builder.get_object('image_spinner').set_from_animation(animation) self.builder.get_object('image_spinner_download').set_from_animation( animation) selection = self.builder.get_object( 'treeview_programs').get_selection() selection.connect('changed', self.treeview_programs_selection_changed)
def __init__(self, app): self.app = app def set_transient_modal(self, instance): instance.set_transient_for(self.main_window) instance.set_modal(True) # TODO: einheitliches benennungsschema für widgets: MainWindow oder main_window self.main_window = MainWindow.NewMainWindow(app, self) self.main_window.post_init() self.preferences_window = PreferencesWindow.NewPreferencesWindow( app, self) self.preferences_window.bind_config(app.config) set_transient_modal(self, self.preferences_window) self.dialog_archive = ArchiveDialog.NewArchiveDialog() set_transient_modal(self, self.dialog_archive) self.dialog_conclusion = ConclusionDialog.NewConclusionDialog( app, self) set_transient_modal(self, self.dialog_conclusion) self.dialog_cut = CutDialog.NewCutDialog(app, self) set_transient_modal(self, self.dialog_cut) self.dialog_email_password = EmailPasswordDialog.NewEmailPasswordDialog( ) set_transient_modal(self, self.dialog_email_password) self.dialog_rename = RenameDialog.NewRenameDialog() set_transient_modal(self, self.dialog_rename) self.dialog_planning = PlanningDialog.NewPlanningDialog(self) set_transient_modal(self, self.dialog_planning) self.dialog_plugins = PluginsDialog.NewPluginsDialog(self) set_transient_modal(self, self.dialog_plugins) for window in [self.main_window]: window.set_icon( GdkPixbuf.Pixbuf.new_from_file( path.get_image_path('icon.png')))
def __init__(self, app): self.app = app # TODO: einheitliches benennungsschema für widgets: MainWindow oder main_window self.main_window = MainWindow.NewMainWindow(app, self) self.main_window.post_init() self.preferences_window = PreferencesWindow.NewPreferencesWindow(app, self) self.preferences_window.bind_config(app.config) self.dialog_archive = ArchiveDialog.NewArchiveDialog() self.dialog_conclusion = ConclusionDialog.NewConclusionDialog(app, self) self.dialog_cut = CutDialog.NewCutDialog(app, self) self.dialog_email_password = EmailPasswordDialog.NewEmailPasswordDialog() self.dialog_rename = RenameDialog.NewRenameDialog() self.dialog_planning = PlanningDialog.NewPlanningDialog(self) self.dialog_plugins = PluginsDialog.NewPluginsDialog(self) for window in [self.main_window]: window.set_icon(gtk.gdk.pixbuf_new_from_file(path.get_image_path('icon3.png')))
def change_status(self, message_type, message, permanent=False): """ Zeigt ein Bild und einen Text in der Statusleiste an. message_type 0 = Information-Icon, -1 = kein Icon message Anzuzeigender Text permanent: wenn \e False, verschwindet die Nachricht nach 10s wieder.""" self.builder.get_object('label_statusbar').set_text(message) if message_type == 0: self.builder.get_object('image_status').set_from_file(path.get_image_path("information.png")) if not permanent: def wait(): yield 0 # fake generator time.sleep(10) def completed(): self.builder.get_object('label_statusbar').set_text("") self.builder.get_object('image_status').clear() GeneratorTask(wait, None, completed).start()
def _on_menuHelpAbout_activate(self, widget, data=None): def open_website(dialog, url, data=None): webbrowser.open(url) gtk.about_dialog_set_url_hook(open_website) about_dialog = gtk.AboutDialog() about_dialog.set_transient_for(self.gui.main_window) about_dialog.set_destroy_with_parent(True) about_dialog.set_name("OTR-Verwaltung") about_dialog.set_logo(gtk.gdk.pixbuf_new_from_file(path.get_image_path('icon3.png'))) version = open(path.getdatapath("VERSION"), 'r').read().strip() about_dialog.set_version(version) about_dialog.set_website("http://elbersb.de/otrverwaltung") about_dialog.set_comments("Zum Verwalten von Dateien von onlinetvrecorder.com.") about_dialog.set_copyright("Copyright \xc2\xa9 2010 Benjamin Elbers") about_dialog.set_authors(["Benjamin Elbers <*****@*****.**>"]) about_dialog.run() about_dialog.destroy()
def __init__(self, app): self.app = app # TODO: einheitliches benennungsschema für widgets: MainWindow oder main_window self.main_window = MainWindow.NewMainWindow(app, self) self.main_window.post_init() self.preferences_window = PreferencesWindow.NewPreferencesWindow( app, self) self.preferences_window.bind_config(app.config) self.dialog_archive = ArchiveDialog.NewArchiveDialog() self.dialog_conclusion = ConclusionDialog.NewConclusionDialog( app, self) self.dialog_cut = CutDialog.NewCutDialog(app, self) self.dialog_email_password = EmailPasswordDialog.NewEmailPasswordDialog( ) self.dialog_rename = RenameDialog.NewRenameDialog() self.dialog_planning = PlanningDialog.NewPlanningDialog(self) self.dialog_plugins = PluginsDialog.NewPluginsDialog(self) for window in [self.main_window]: window.set_icon( gtk.gdk.pixbuf_new_from_file(path.get_image_path('icon3.png')))
def __setup_toolbar(self): toolbar_buttons = [ ('decodeandcut', 'decodeandcut.png', "Dekodieren und Schneiden", Action.DECODEANDCUT), ('decode', 'decode.png', 'Dekodieren', Action.DECODE), ('delete', 'bin.png', "In den Müll verschieben", Action.DELETE), ('archive', 'archive.png', "Archivieren", Action.ARCHIVE), ('cut', 'cut.png', "Schneiden", Action.CUT), ('restore', 'restore.png', "Wiederherstellen", Action.RESTORE), ('rename', 'rename.png', "Umbenennen", Action.RENAME), ('new_folder', 'new_folder.png', "Neuer Ordner", Action.NEW_FOLDER), ('real_delete', 'delete.png', "Löschen", Action.REAL_DELETE), ('plan_add', 'film_add.png', "Hinzufügen", Action.PLAN_ADD), ('plan_remove', 'film_delete.png', "Löschen", Action.PLAN_REMOVE), ('plan_edit', 'film_edit.png', "Bearbeiten", Action.PLAN_EDIT), ('plan_search', 'film_search.png', "Auf Mirror suchen", Action.PLAN_SEARCH), ('download_add', 'add_download.png', "Download hinzufügen", Action.DOWNLOAD_ADD), ('download_add_link', 'add_download.png', "Link hinzufügen", Action.DOWNLOAD_ADD_LINK), ('download_start', 'download_start.png', "Start", Action.DOWNLOAD_START), ('download_stop', 'download_stop.png', "Stop", Action.DOWNLOAD_STOP), ('download_remove', 'delete.png', "Löschen", Action.DOWNLOAD_REMOVE), ] self.__toolbar_buttons = {} for key, image_name, text, action in toolbar_buttons: image = Gtk.Image.new_from_file(path.get_image_path(image_name)) image.show() if key == "cut" or key == "decodeandcut": self.__toolbar_buttons[key] = Gtk.MenuToolButton.new( image, text) self.__toolbar_buttons[key].set_menu( self.__get_cut_menu(action)) else: self.__toolbar_buttons[key] = Gtk.ToolButton.new(image, text) self.__toolbar_buttons[key].connect("clicked", self._on_toolbutton_clicked, action) self.__toolbar_buttons[key].show() self.__sets_of_toolbars = { Section.PLANNING: ['plan_add', 'plan_edit', 'plan_remove', 'plan_search'], Section.DOWNLOAD: [ 'download_add_link', 'download_start', 'download_stop', 'download_remove' ], Section.OTRKEY: ['decodeandcut', 'decode', 'delete', 'real_delete'], Section.VIDEO_UNCUT: ['cut', 'delete', 'real_delete', 'archive'], Section.VIDEO_CUT: ['archive', 'delete', 'real_delete', 'cut', 'rename'], Section.ARCHIVE: ['delete', 'real_delete', 'rename', 'new_folder'], Section.TRASH: ['real_delete', 'restore'] } # create sets of toolbuttons for section, button_names in self.__sets_of_toolbars.items(): toolbar_buttons = [] for button_name in button_names: toolbar_buttons.append(self.__toolbar_buttons[button_name]) self.__sets_of_toolbars[section] = toolbar_buttons # toolbar_search self.search_tool_item = EntrySearchToolItem("Durchsuchen") self.builder.get_object('toolbar_search').insert( self.search_tool_item, -1) self.search_tool_item.connect('search', lambda w, search: self.do_search(search)) self.search_tool_item.connect('clear', self.on_search_clear)
def __setup_treeview_files(self): treeview = self.builder.get_object('treeview_files') treeview.connect('button_press_event', self._on_treeview_files_button_pressed) store = Gtk.TreeStore(str, float, float, bool) # filename, size, date, locked treeview.set_model(store) # constants for model and columns self.__FILENAME = 0 self.__SIZE = 1 self.__DATE = 2 self.__ISDIR = 3 # create the TreeViewColumns to display the data column_names = ['Dateiname', 'Größe', 'Geändert'] tvcolumns = [None] * len(column_names) # pixbuf and filename cell_renderer_pixbuf = Gtk.CellRendererPixbuf() tvcolumns[self.__FILENAME] = Gtk.TreeViewColumn( column_names[self.__FILENAME], cell_renderer_pixbuf) cell_renderer_text_name = Gtk.CellRendererText() tvcolumns[self.__FILENAME].pack_start(cell_renderer_text_name, False) tvcolumns[self.__FILENAME].set_cell_data_func(cell_renderer_pixbuf, self.__tv_files_pixbuf) tvcolumns[self.__FILENAME].set_cell_data_func(cell_renderer_text_name, self.__tv_files_name) # size cell_renderer_text_size = Gtk.CellRendererText() cell_renderer_text_size.set_property('xalign', 1.0) tvcolumns[self.__SIZE] = Gtk.TreeViewColumn(column_names[self.__SIZE], cell_renderer_text_size) tvcolumns[self.__SIZE].set_cell_data_func(cell_renderer_text_size, self.__tv_files_size) # date cell_renderer_text_date = Gtk.CellRendererText() tvcolumns[self.__DATE] = Gtk.TreeViewColumn(column_names[self.__DATE], cell_renderer_text_date) tvcolumns[self.__DATE].set_cell_data_func(cell_renderer_text_date, self.__tv_files_date) # append the columns for col in tvcolumns: col.set_resizable(True) treeview.append_column(col) # allow multiple selection treeselection = treeview.get_selection() treeselection.set_mode(Gtk.SelectionMode.MULTIPLE) # sorting treeview.get_model().set_sort_func(0, self.__tv_files_sort) tvcolumns[self.__FILENAME].set_sort_column_id(0) tvcolumns[self.__SIZE].set_sort_column_id(1) tvcolumns[self.__DATE].set_sort_column_id(2) # load pixbufs for treeview if self.app.config.get('general', 'use_internal_icons'): self.__pix_avi = GdkPixbuf.Pixbuf.new_from_file( path.get_image_path('avi.png')) self.__pix_otrkey = GdkPixbuf.Pixbuf.new_from_file( path.get_image_path('decode.png')) self.__pix_folder = GdkPixbuf.Pixbuf.new_from_file( path.get_image_path('folder.png')) else: try: self.__pix_avi = Gtk.IconTheme.get_default().load_icon( 'video-x-generic', self.app.config.get('general', 'icon_size'), 0) self.__pix_otrkey = Gtk.IconTheme.get_default().load_icon( 'dialog-password', self.app.config.get('general', 'icon_size'), 0) self.__pix_folder = Gtk.IconTheme.get_default().load_icon( 'folder', self.app.config.get('general', 'icon_size'), 0) except: pass
def __setup_toolbar(self): toolbar_buttons = [ ('decodeandcut', 'decodeandcut.png', "Dekodieren und Schneiden", Action.DECODEANDCUT), ('decode', 'decode.png', 'Dekodieren', Action.DECODE), ('delete', 'delete.png', "In den Müll verschieben", Action.DELETE), ('archive', 'archive.png', "Archivieren", Action.ARCHIVE), ('cut', 'cut.png', "Schneiden", Action.CUT), ('restore', 'restore.png', "Wiederherstellen", Action.RESTORE), ('rename', 'rename.png', "Umbenennen", Action.RENAME), ('new_folder', 'new_folder.png', "Neuer Ordner", Action.NEW_FOLDER), ('real_delete', 'delete.png', "Löschen", Action.REAL_DELETE), ('plan_add', 'film_add.png', "Hinzufügen", Action.PLAN_ADD), ('plan_remove', 'film_delete.png', "Löschen", Action.PLAN_REMOVE), ('plan_edit', 'film_edit.png', "Bearbeiten", Action.PLAN_EDIT), ('plan_search', 'film_search.png', "Auf Mirror suchen", Action.PLAN_SEARCH), ('download_add', 'add_download.png', "Download hinzufügen", Action.DOWNLOAD_ADD), ('download_add_link', 'add_download.png', "Link hinzufügen", Action.DOWNLOAD_ADD_LINK), ('download_start', 'download_start.png', "Start", Action.DOWNLOAD_START), ('download_stop', 'download_stop.png', "Stop", Action.DOWNLOAD_STOP), ('download_remove', 'delete.png', "Löschen", Action.DOWNLOAD_REMOVE), ] self.__toolbar_buttons = {} for key, image_name, text, action in toolbar_buttons: image = gtk.image_new_from_file(path.get_image_path(image_name)) image.show() if key == "cut" or key == "decodeandcut": self.__toolbar_buttons[key] = gtk.MenuToolButton(image, text) self.__toolbar_buttons[key].set_menu(self.__get_cut_menu(action)) else: self.__toolbar_buttons[key] = gtk.ToolButton(image, text) self.__toolbar_buttons[key].connect("clicked", self._on_toolbutton_clicked, action) self.__toolbar_buttons[key].show() self.__sets_of_toolbars = { Section.PLANNING : [ 'plan_add', 'plan_edit', 'plan_remove', 'plan_search'], Section.DOWNLOAD: [ 'download_add_link', 'download_start', 'download_stop', 'download_remove' ], Section.OTRKEY : [ 'decodeandcut', 'decode', 'delete' ], Section.VIDEO_UNCUT: [ 'cut', 'delete', 'archive', ], Section.VIDEO_CUT: [ 'archive', 'delete', 'cut', 'rename' ], Section.ARCHIVE: [ 'delete', 'rename', 'new_folder' ], Section.TRASH: [ 'real_delete', 'restore' ] } # create sets of toolbuttons for section, button_names in self.__sets_of_toolbars.iteritems(): toolbar_buttons = [] for button_name in button_names: toolbar_buttons.append(self.__toolbar_buttons[button_name]) self.__sets_of_toolbars[section] = toolbar_buttons # toolbar_search self.search_tool_item = EntrySearchToolItem("Durchsuchen") self.builder.get_object('toolbar_search').insert(self.search_tool_item, -1) self.search_tool_item.connect('search', lambda w, search: self.do_search(search)) self.search_tool_item.connect('clear', self.on_search_clear)
def __setup_toolbar(self): if self.app.config.get('general', 'use_internal_icons'): toolbar_buttons = [ ('decodeandcut', 'decodeandcut.png', "Dekodieren und Schneiden", Action.DECODEANDCUT), ('decode', 'decode.png', 'Dekodieren', Action.DECODE), ('delete', 'bin.png', "In den Müll verschieben", Action.DELETE), ('archive', 'archive.png', "Archivieren", Action.ARCHIVE), ('cut', 'cut.png', "Schneiden", Action.CUT), ('restore', 'restore.png', "Wiederherstellen", Action.RESTORE), ('rename', 'rename.png', "Umbenennen", Action.RENAME), ('new_folder', 'new_folder.png', "Neuer Ordner", Action.NEW_FOLDER), ('real_delete', 'delete.png', "Löschen", Action.REAL_DELETE) ] else: toolbar_buttons = [ ('decodeandcut', ['dialog-password', 'edit-cut-symbolic'], "Dekodieren und Schneiden", Action.DECODEANDCUT), ('decode', 'dialog-password', 'Dekodieren', Action.DECODE), ('delete', 'user-trash', "In den Müll verschieben", Action.DELETE), ('archive', 'system-file-manager', "Archivieren", Action.ARCHIVE), ('cut', 'edit-cut', "Schneiden", Action.CUT), ('restore', 'view-refresh', "Wiederherstellen", Action.RESTORE), ('rename', 'edit-rename', "Umbenennen", Action.RENAME), ('new_folder', 'folder-new', "Neuer Ordner", Action.NEW_FOLDER), ('real_delete', 'edit-delete', "Löschen", Action.REAL_DELETE), ] self.__toolbar_buttons = {} for key, image_name, text, action in toolbar_buttons: if self.app.config.get('general', 'use_internal_icons'): image = Gtk.Image.new_from_file( path.get_image_path(image_name)) else: # Gtk.IconSize.LARGE_TOOLBAR if type(image_name) == type( []): # It's a list so we create an emblemed icon try: image = Gtk.Image.new_from_gicon( Gio.EmblemedIcon.new( Gio.ThemedIcon.new(image_name[0]), Gio.Emblem.new( Gio.ThemedIcon.new(image_name[1]))), self.app.config.get('general', 'icon_size')) except: pass else: try: image = Gtk.Image.new_from_pixbuf( Gtk.IconTheme.get_default().load_icon( image_name, self.app.config.get('general', 'icon_size'), 0)) except: pass image.show() if key == "cut" or key == "decodeandcut": self.__toolbar_buttons[key] = Gtk.MenuToolButton.new( image, text) self.__toolbar_buttons[key].set_menu( self.__get_cut_menu(action)) else: self.__toolbar_buttons[key] = Gtk.ToolButton.new(image, text) self.__toolbar_buttons[key].connect("clicked", self._on_toolbutton_clicked, action) self.__toolbar_buttons[key].show() self.__sets_of_toolbars = { # ~ Section.PLANNING: ['plan_add', 'plan_edit', 'plan_remove', 'plan_search'], # ~ Section.DOWNLOAD: ['download_add_link', 'download_start', 'download_stop','download_remove'], Section.OTRKEY: ['decodeandcut', 'decode', 'delete', 'real_delete'], Section.VIDEO_UNCUT: ['cut', 'delete', 'real_delete', 'archive'], Section.VIDEO_CUT: ['archive', 'delete', 'real_delete', 'cut', 'rename'], Section.ARCHIVE: ['delete', 'real_delete', 'rename', 'new_folder'], Section.TRASH: ['real_delete', 'restore'], Section.TRASH_AVI: ['real_delete', 'restore'], Section.TRASH_OTRKEY: ['real_delete', 'restore'] } if self.app.config.get('general', 'hide_archive_buttons'): for section, buttons in self.__sets_of_toolbars.items(): if 'archive' in buttons: buttons.remove('archive') self.__sets_of_toolbars[section] = buttons # create sets of toolbuttons for section, button_names in self.__sets_of_toolbars.items(): toolbar_buttons = [] for button_name in button_names: toolbar_buttons.append(self.__toolbar_buttons[button_name]) self.__sets_of_toolbars[section] = toolbar_buttons # toolbar_search self.search_tool_item = EntrySearchToolItem("Durchsuchen") self.builder.get_object('toolbar_search').insert( self.search_tool_item, -1) self.search_tool_item.connect('search', lambda w, search: self.do_search(search)) self.search_tool_item.connect('clear', self.on_search_clear)