def one_line_dialog(dialog_title, parent=None, entry_text=None, message_text1=None, message_text2=None): dialog = Gtk.MessageDialog( parent, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, None) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.set_title(dialog_title) if message_text1: dialog.set_markup(message_text1) if message_text2: dialog.format_secondary_markup(message_text2) entry = Gtk.Entry() '''set last widget in action area as default widget (button OK)''' dialog.set_default_response(Gtk.ResponseType.OK) '''activate default widget after Enter pressed in entry''' entry.set_activates_default(True) if entry_text: entry.set_text(entry_text) dialog.vbox.pack_start(entry, True, True, 0) dialog.show_all() dialog.run() text = entry.get_text() dialog.destroy() return text if text else None
def _update_info(self, bean): if not bean: return if not self.sound_menu: # if dbus initialization can't be finished return image = "file:///" + get_foobnix_resourse_path_by_name(ICON_FOOBNIX) if bean.image: if bean.image.startswith("/"): image = "file:///" + bean.image else: image = bean.image artists = None if bean.artist: artists = [bean.artist] properties = { "CanPause": bean.type != FTYPE_RADIO, "CanSeek": bean.type != FTYPE_RADIO } self.sound_menu.song_changed( artists=artists, title=bean.title or bean.text, album=bean.album, cover=image, duration_microsec=self.sound_menu.duration_microseconds, properties=properties)
def __init__(self): Gtk.AboutDialog.__init__(self) self.set_program_name("Foobnix") self.set_version(FOOBNIX_VERSION) self.set_copyright("(c) Ivan Ivanenko <*****@*****.**>") self.set_comments(_("Simple and Powerful player")) self.set_website("http://www.foobnix.com") self.set_authors(["Dmitry Kozhura (zavlab1) <*****@*****.**>", "Pietro Campagnano <fain182@gmailcom>", "Viktor Suprun <*****@*****.**>"]) self.set_translator_credits("""Bernardo Miguel Savone Sérgio Marques XsLiDian KamilSPL north Alex Serada Ivan Ivanenko Dmitry-Kogura Fitoschido zeugma Schaffino Oleg «Eleidan» Kulik Sergey Zigachev Martino Barbon Florian Heissenberger Aldo Mann""") self.set_logo(Gdk.pixbuf_new_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX))) #@UndefinedVariable
def show_login_password_error_dialog(title, description, login, password): dialog = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, title) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.set_markup(str(title)) dialog.format_secondary_markup(description) login_entry = Gtk.Entry() login_entry.set_text(login) login_entry.show() password_entry = Gtk.Entry() password_entry.set_text(password) password_entry.set_visibility(False) password_entry.set_invisible_char("*") password_entry.show() vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0) vbox.pack_start(login_entry, False, False, 0) vbox.pack_start(password_entry, False, False, 0) dialog.vbox.pack_start(vbox, True, True, 0) dialog.show_all() dialog.run() login_text = login_entry.get_text() password_text = password_entry.get_text() dialog.destroy() return [login_text, password_text]
def message_on_save(absolute=True): dialog = Gtk.Dialog(buttons=("Yes", Gtk.ResponseType.OK, "No", Gtk.ResponseType.REJECT)) dialog.set_title(_("Choose window")) dialog.set_border_width(5) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) label = Gtk.Label() label.set_markup(_("""<big><b>\t\t\t\t\t\t\t\tAttention!\n</b></big>\t\ The relative location of the \ playlist and music files allows you to save a relative paths to the files in your playlist. This will allow to carry along the playlist with the files (only together) at any place of the computer or even at another computer. Also, it will make library compatible with OS Windows. However, in this case you can't change the relative location of the playlist file and music files. \tAbsolute file paths make it impossible to transfer a playlist on other computer or use it in OS Windows, but it will put the library anywhere in the file system sepa- rate from the music files (the library will be working).\n \tDo you want to save the playlist with relative paths?\n""")) label.show() dialog.vbox.pack_start(label, False, False) dialog.vbox.show() dialog.show_all() response = dialog.run() if response == Gtk.ResponseType.OK: dialog.destroy() return False else: dialog.destroy() return True
def check_active_dynamic_icon(self, icon_object): icon_name = icon_object.entry.get_text() try: path = get_foobnix_resourse_path_by_name(icon_name) self.controls.trayicon.set_image_from_path(path) except TypeError: pass
def __init__(self, title, func, args=None, current_folder=None, current_name=None): Gtk.FileChooserDialog.__init__(self, title, action=Gtk.FileChooserAction.SAVE, buttons=(Gtk.STOCK_SAVE, Gtk.ResponseType.OK)) self.set_default_response(Gtk.ResponseType.OK) self.set_select_multiple(False) self.set_do_overwrite_confirmation(True) self.set_icon_from_file( get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) if current_folder: self.set_current_folder(current_folder) if current_name: self.set_current_name(current_name) response = self.run() if response == Gtk.ResponseType.OK: filename = self.get_filename() folder = self.get_current_folder() if func: try: if args: func(filename, folder, args) else: func(filename, folder) except IOError, e: logging.error(e)
def __init__(self, title, file_list, width=None, hight=None): Gtk.Dialog.__init__(self, title) if width and hight: self.set_default_size(width, hight) self.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) self.set_resizable(True) self.set_border_width(5) self.total_size = get_full_size(file_list) self.label_from = Gtk.Label.new(None) self.label_to = Gtk.Label.new(None) self.pr_label = Gtk.Label.new(_("Total progress")) self.pr_bar = Gtk.ProgressBar() self.total_pr_bar = Gtk.ProgressBar() self.add_button(_("Stop"), Gtk.ResponseType.REJECT) self.vbox.pack_start(self.label_from, False, False, 0) self.vbox.pack_start(self.label_to, False, False, 0) self.vbox.pack_start(self.pr_bar, False, False, 0) self.vbox.pack_start(self.pr_label, False, False, 0) self.vbox.pack_start(self.total_pr_bar, False, False, 0) self.exit = False self.show_all()
def copy_move_files_dialog(files, dest_folder, copy=None): if copy == Gdk.DragAction.COPY: action = _("Copy") #@UndefinedVariable else: action = _("Replace") dialog = Gtk.Dialog(_('%s file(s) / folder(s)') % action) ok_button = dialog.add_button(action, Gtk.ResponseType.OK) cancel_button = dialog.add_button( "dialog-cancel", Gtk.ResponseType.CANCEL) #@UnusedVariable ok_button.grab_default() label = Gtk.Label.new('\n' + _("Are you really want to %s this item(s) to %s ?") % (action, dest_folder)) area = ScrolledText() area.text.set_editable(False) area.text.set_cursor_visible(False) area.buffer.set_text("\n".join([os.path.basename(path) for path in files])) dialog.vbox.pack_start(area.scroll, False, False, 0) dialog.set_border_width(5) dialog.vbox.pack_start(label, False, False, 0) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.set_default_size(400, 150) dialog.show_all() if dialog.run() == Gtk.ResponseType.OK: dialog.destroy() return True dialog.destroy() return False
def __init__(self, title, file_list, width=None, hight=None): Gtk.Dialog.__init__(self, title) if width and hight: self.set_default_size(width, hight) self.set_icon_from_file( get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) self.set_resizable(True) self.set_border_width(5) self.total_size = get_full_size(file_list) self.label_from = Gtk.Label() self.label_to = Gtk.Label() self.pr_label = Gtk.Label(_("Total progress")) self.pr_bar = Gtk.ProgressBar() self.total_pr_bar = Gtk.ProgressBar() self.add_button(_("Stop"), Gtk.ResponseType.REJECT) self.vbox.pack_start(self.label_from, False) self.vbox.pack_start(self.label_to, False) self.vbox.pack_start(self.pr_bar, False) self.vbox.pack_start(self.pr_label, False) self.vbox.pack_start(self.total_pr_bar, False) self.exit = False self.show_all()
def copy_move_files_dialog(files, dest_folder, copy=None): if copy == Gdk.DragAction.COPY: action = _("Copy") #@UndefinedVariable else: action = _("Replace") dialog = Gtk.Dialog(_('%s file(s) / folder(s)') % action) ok_button = dialog.add_button(action, Gtk.ResponseType.OK) cancel_button = dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL) #@UnusedVariable ok_button.grab_default() label = Gtk.Label('\n' + _("Are you really want to %s this item(s) to %s ?") % (action, dest_folder)) area = ScrolledText() area.text.set_editable(False) area.text.set_cursor_visible(False) area.buffer.set_text("\n".join([os.path.basename(path) for path in files])) dialog.vbox.pack_start(area.scroll) dialog.set_border_width(5) dialog.vbox.pack_start(label) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.set_default_size(400, 150) dialog.show_all() if dialog.run() == Gtk.ResponseType.OK: dialog.destroy() return True dialog.destroy() return False
def __init__(self): Gtk.AboutDialog.__init__(self) self.set_program_name("Foobnix") self.set_version(FOOBNIX_VERSION) self.set_copyright("(c) Ivan Ivanenko <*****@*****.**>") self.set_comments(_("Simple and Powerful player")) self.set_website("http://www.foobnix.com") self.set_authors([ "Dmitry Kozhura (zavlab1) <*****@*****.**>", "Pietro Campagnano <fain182@gmailcom>", "Viktor Suprun <*****@*****.**>" ]) self.set_translator_credits("""Bernardo Miguel Savone Sérgio Marques XsLiDian KamilSPL north Alex Serada Ivan Ivanenko Dmitry-Kogura Fitoschido zeugma Schaffino Oleg «Eleidan» Kulik Sergey Zigachev Martino Barbon Florian Heissenberger Aldo Mann""") self.set_logo( Gdk.pixbuf_new_from_file( get_foobnix_resourse_path_by_name( ICON_FOOBNIX))) #@UndefinedVariable
def info_dialog(title, message, parent=None): dialog = Gtk.MessageDialog( parent, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, None) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.set_title(title) dialog.set_markup(title) dialog.format_secondary_markup(message) dialog.show_all() dialog.run() dialog.destroy()
def file_saving_dialog(title, current_folder=None): chooser = Gtk.FileChooserDialog(title, action=Gtk.FileChooserAction.SAVE, buttons=("document-save", Gtk.ResponseType.OK)) chooser.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) chooser.set_default_response(Gtk.ResponseType.OK) chooser.set_select_multiple(False) if current_folder: chooser.set_current_folder(current_folder) response = chooser.run() if response == Gtk.ResponseType.OK: paths = chooser.get_filenames() elif response == Gtk.ResponseType.CANCEL: logging.info('Closed, no files selected') chooser.destroy()
def info_dialog_with_link(title, version, link): dialog = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, None) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.set_title(title) dialog.set_markup(title) dialog.format_secondary_markup("<b>" + version + "</b>") link = Gtk.LinkButton(link, link) link.show() dialog.vbox.pack_end(link, True, True, 0) dialog.show_all() dialog.run() dialog.destroy()
def file_chooser_dialog(title, current_folder=None): chooser = Gtk.FileChooserDialog(title, action=Gtk.FileChooserAction.OPEN, buttons=(_("Open"), Gtk.ResponseType.OK)) chooser.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) chooser.set_default_response(Gtk.ResponseType.OK) chooser.set_select_multiple(True) paths = None if current_folder: chooser.set_current_folder(current_folder) response = chooser.run() if response == Gtk.ResponseType.OK: paths = chooser.get_filenames() elif response == Gtk.ResponseType.CANCEL: logging.info('Closed, no files selected') chooser.destroy() return paths
def _update_info(self, bean): if not bean: return if not self.sound_menu: # if dbus initialization can't be finished return image = "file:///" + get_foobnix_resourse_path_by_name(ICON_FOOBNIX) if bean.image: if bean.image.startswith("/"): image = "file:///" + bean.image else: image = bean.image artists = None if bean.artist: artists = [bean.artist] self.sound_menu.song_changed(artists=artists, title=bean.title or bean.text, album=bean.album, cover=image)
def __init__(self, controls): FControl.__init__(self, controls) Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL) self.set_title("Foobnix " + FOOBNIX_VERSION) self.set_position(Gtk.WindowPosition.CENTER) self.set_resizable(True) self.connect("window-state-event", self.on_change_state) self.connect("delete-event", self.hide_window) self.connect("key-press-event", self.on_key_press) try: self.set_icon_from_file(get_foobnix_resourse_path_by_name(const.ICON_FOOBNIX)) except TypeError as e: logging.error(str(e)) self.set_opacity(FC().window_opacity) self.iconified = False
def info_dialog_with_link(title, version, link): dialog = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, None) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.set_title(title) dialog.set_markup(title) dialog.format_secondary_markup("<b>" + version + "</b>") link = Gtk.LinkButton.new_with_label(link, link) link.show() dialog.vbox.pack_end(link, True, True, 0) dialog.show_all() dialog.run() dialog.destroy()
def show_entry_dialog(title, description): dialog = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK, None) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.set_markup(title) entry = Gtk.Entry() entry.connect("activate", responseToDialog, dialog, Gtk.ResponseType.OK) hbox = Gtk.HBox() hbox.pack_start(Gtk.Label("Value:"), False, 5, 5) hbox.pack_end(entry) dialog.format_secondary_markup(description) dialog.vbox.pack_end(hbox, True, True, 0) dialog.show_all() dialog.run() text = entry.get_text() dialog.destroy() return text
def __init__(self, controls): FControl.__init__(self, controls) Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL) self.set_title("Foobnix " + FOOBNIX_VERSION) self.set_position(Gtk.WindowPosition.CENTER) self.set_resizable(True) self.connect("window-state-event", self.on_change_state) self.connect("delete-event", self.hide_window) self.connect("key-press-event", self.on_key_press) try: self.set_icon_from_file( get_foobnix_resourse_path_by_name(const.ICON_FOOBNIX)) except TypeError as e: logging.error(str(e)) self.set_opacity(FC().window_opacity) self.iconified = False
def two_line_dialog(dialog_title, parent=None, message_text1=None, message_text2=None, entry_text1="", entry_text2=""): dialog = Gtk.MessageDialog( parent, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK, None) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.set_title(dialog_title) if message_text1: dialog.set_markup(message_text1) if message_text2: dialog.format_secondary_markup(message_text2) login_entry = Gtk.Entry() if entry_text1: login_entry.set_text(entry_text1) login_entry.show() password_entry = Gtk.Entry() if entry_text2: password_entry.set_text(entry_text2) password_entry.show() hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) hbox.pack_start(login_entry, False, False, 0) hbox.pack_start(password_entry, False, False, 0) dialog.vbox.pack_start(hbox, True, True, 0) dialog.show_all() '''set last widget in action area as default widget (button OK)''' dialog.set_default_response(Gtk.ResponseType.OK) '''activate default widget after Enter pressed in entry''' login_entry.set_activates_default(True) password_entry.set_activates_default(True) dialog.run() login_text = login_entry.get_text() password_text = password_entry.get_text() dialog.destroy() return [login_text, password_text] if (login_text and password_text) else [None,None]
def info_dialog_with_link_and_donate(version): dialog = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, None) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.set_title(_("New foobnix release avaliable")) dialog.set_markup(_("New foobnix release avaliable")) dialog.format_secondary_markup("<b>" + version + "</b>") card = Gtk.LinkButton( "http://www.foobnix.com/support?lang=%s" % SITE_LOCALE, _("Download and Donate")) #terminal = Gtk.LinkButton("http://www.foobnix.com/donate/eng#terminal", _("Download and Donate by Webmoney or Payment Terminal")) link = Gtk.LinkButton( "http://www.foobnix.com/support?lang=%s" % SITE_LOCALE, _("Download")) frame = Gtk.Frame(label="Please donate and download") vbox = Gtk.VBox(True, 0) vbox.pack_start(card, True, True) #vbox.pack_start(terminal, True, True) vbox.pack_start(link, True, True) frame.add(vbox) image = ImageBase("images/foobnix-slogan.jpg") dialog.vbox.pack_start(image, True, True) dialog.vbox.pack_start(frame, True, True) dialog.vbox.pack_start( Gtk.Label( _("We hope you like the player. We will make it even better.")), True, True) version_check = Gtk.CheckButton( _("Check for new foobnix release on start")) version_check.set_active(FC().check_new_version) dialog.vbox.pack_start(version_check, True, True) dialog.show_all() dialog.run() FC().check_new_version = version_check.get_active() FC().save() dialog.destroy()
def info_dialog_with_link_and_donate(version): dialog = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, None) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.set_title(_("New foobnix release avaliable")) dialog.set_markup(_("New foobnix release avaliable")) dialog.format_secondary_markup("<b>" + version + "</b>") card = Gtk.LinkButton("http://foobnix.com/%s/download.html"%SITE_LOCALE, _("Download and Donate")) #terminal = Gtk.LinkButton("http://www.foobnix.com/donate/eng#terminal", _("Download and Donate by Webmoney or Payment Terminal")) # link = Gtk.LinkButton("http://www.foobnix.com/support?lang=%s"%SITE_LOCALE, _("Download")) frame = Gtk.Frame(label="Please donate and download") vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0) vbox.set_homogeneous(True) vbox.pack_start(card, True, True) #vbox.pack_start(terminal, True, True) vbox.pack_start(link, True, True) frame.add(vbox) image = ImageBase("images/foobnix-slogan.jpg") dialog.vbox.pack_start(image, True, True) dialog.vbox.pack_start(frame, True, True) dialog.vbox.pack_start(Gtk.Label(_("We hope you like the player. We will make it even better.")), True, True) version_check = Gtk.CheckButton(_("Check for new foobnix release on start")) version_check.set_active(FC().check_new_version) dialog.vbox.pack_start(version_check, True, True) dialog.show_all() dialog.run() FC().check_new_version = version_check.get_active() FC().save() dialog.destroy()
def rename_file_on_disk(row, index_path, index_text): path = row[index_path] name = os.path.basename(path) entry = Gtk.Entry() entry.set_width_chars(64) hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) if os.path.isdir(path): entry.set_text(name) hbox.pack_start(entry, False, False, 0) title = _('Rename folder') else: name_tuple = os.path.splitext(name) entry.set_text(name_tuple[0]) entry_ext = Gtk.Entry() entry_ext.set_width_chars(7) entry_ext.set_text(name_tuple[1][1:]) hbox.pack_start(entry, False, False, 0) hbox.pack_start(entry_ext, False, False, 0) title = _('Rename file') dialog = Gtk.Dialog(title, buttons=("Rename", Gtk.ResponseType.ACCEPT, "Cancel", Gtk.ResponseType.REJECT)) dialog.vbox.pack_start(hbox, False, False, 0) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.show_all() if dialog.run() == Gtk.ResponseType.ACCEPT: if os.path.isdir(path) or not entry_ext.get_text(): new_path = os.path.join(os.path.dirname(path), entry.get_text()) else: new_path = os.path.join( os.path.dirname(path), entry.get_text() + '.' + entry_ext.get_text()) try: os.rename(path, new_path) row[index_path] = new_path row[index_text] = os.path.basename(new_path) except IOError as e: logging.error(e) dialog.destroy() return True dialog.destroy()
def show_entry_dialog(title, description): dialog = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK, None) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.set_markup(title) entry = Gtk.Entry() entry.connect("activate", responseToDialog, dialog, Gtk.ResponseType.OK) hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 0) hbox.pack_start(Gtk.Label.new("Value:"), False, 5, 5) hbox.pack_end(entry) dialog.format_secondary_markup(description) dialog.vbox.pack_end(hbox, True, True, 0) dialog.show_all() dialog.run() text = entry.get_text() dialog.destroy() return text
def __init__(self, title, func, args = None, current_folder=None, current_name=None): Gtk.FileChooserDialog.__init__(self, title, action=Gtk.FileChooserAction.SAVE, buttons=("document-save", Gtk.ResponseType.OK)) self.set_default_response(Gtk.ResponseType.OK) self.set_select_multiple(False) self.set_do_overwrite_confirmation(True) self.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) if current_folder: self.set_current_folder(current_folder) if current_name: self.set_current_name(current_name) response = self.run() if response == Gtk.ResponseType.OK: filename = self.get_filename() folder = self.get_current_folder() if func: try: if args: func(filename, folder, args) else: func(filename, folder) except IOError, e: logging.error(e)
def delete_files_from_disk(row_refs, paths, get_iter_from_row_reference): title = _('Delete file(s) / folder(s)') label = Gtk.Label.new(_('Do you really want to delete item(s) from disk?')) dialog = Gtk.Dialog(title, buttons=("Delete", Gtk.ResponseType.ACCEPT, "Cancel", Gtk.ResponseType.REJECT)) dialog.set_default_size(500, 200) dialog.set_border_width(5) dialog.vbox.pack_start(label, False, False, 0) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) buffer = Gtk.TextBuffer() text = Gtk.TextView(buffer=buffer) text.set_editable(False) text.set_cursor_visible(False) scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolled_window.add(text) dialog.vbox.pack_start(scrolled_window, False, False, 0) for path in paths: name = os.path.basename(path) buffer.insert_at_cursor('\t' + name + '\n') dialog.show_all() if dialog.run() == Gtk.ResponseType.ACCEPT: model = row_refs[0].get_model() for row_ref, path in zip(row_refs, paths): try: if os.path.isfile(path): os.remove(path) else: del_dir(path) model.remove(get_iter_from_row_reference(row_ref)) except Exception as e: logging.error(str(e)) continue dialog.destroy() return True dialog.destroy()
def rename_file_on_disk(row, index_path, index_text): path = row[index_path] name = os.path.basename(path) entry = Gtk.Entry() entry.set_width_chars(64) hbox = Gtk.HBox() if os.path.isdir(path): entry.set_text(name) hbox.pack_start(entry) title = _('Rename folder') else: name_tuple = os.path.splitext(name) entry.set_text(name_tuple[0]) entry_ext = Gtk.Entry() entry_ext.set_width_chars(7) entry_ext.set_text(name_tuple[1][1:]) hbox.pack_start(entry) hbox.pack_start(entry_ext) title = _('Rename file') dialog = Gtk.Dialog(title, buttons=("Rename", Gtk.ResponseType.ACCEPT, "Cancel", Gtk.ResponseType.REJECT)) dialog.vbox.pack_start(hbox) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) dialog.show_all() if dialog.run() == Gtk.ResponseType.ACCEPT: if os.path.isdir(path) or not entry_ext.get_text(): new_path = os.path.join(os.path.dirname(path), entry.get_text()) else: new_path = os.path.join(os.path.dirname(path), entry.get_text() + '.' + entry_ext.get_text()) try: os.rename(path, new_path) row[index_path] = new_path row[index_text] = os.path.basename(new_path) except IOError, e: logging.error(e) dialog.destroy() return True
def delete_files_from_disk(row_refs, paths, get_iter_from_row_reference): title = _('Delete file(s) / folder(s)') label = Gtk.Label(_('Do you really want to delete item(s) from disk?')) dialog = Gtk.Dialog(title, buttons=("Delete", Gtk.ResponseType.ACCEPT, "Cancel", Gtk.ResponseType.REJECT)) dialog.set_default_size(500, 200) dialog.set_border_width(5) dialog.vbox.pack_start(label) dialog.set_icon_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) buffer = Gtk.TextBuffer() text = Gtk.TextView(buffer=buffer) text.set_editable(False) text.set_cursor_visible(False) scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolled_window.add(text) dialog.vbox.pack_start(scrolled_window) for path in paths: name = os.path.basename(path) buffer.insert_at_cursor('\t' + name + '\n') dialog.show_all() if dialog.run() == Gtk.ResponseType.ACCEPT: model = row_refs[0].get_model() for row_ref, path in zip(row_refs, paths): try: if os.path.isfile(path): os.remove(path) else: del_dir(path) model.remove(get_iter_from_row_reference(row_ref)) except Exception, e: logging.error(str(e)) continue dialog.destroy() return True
def _update_info(self, bean): if not bean: return if not self.sound_menu: # if dbus initialization can't be finished return image = "file:///" + get_foobnix_resourse_path_by_name(ICON_FOOBNIX) if bean.image: if bean.image.startswith("/"): image = "file:///" + bean.image else: image = bean.image artists = None if bean.artist: artists = [bean.artist] properties = { "CanPause": bean.type != FTYPE_RADIO, "CanSeek": bean.type != FTYPE_RADIO } self.sound_menu.song_changed(artists=artists, title=bean.title or bean.text, album=bean.album, cover=image, duration_microsec=self.sound_menu.duration_microseconds, properties=properties)
from gi.repository import Gtk from gi.repository import GLib from subprocess import Popen, PIPE from foobnix.fc.fc_helper import CONFIG_DIR from foobnix.util.const import ICON_FOOBNIX from foobnix.util.file_utils import open_in_filemanager from foobnix.util.localization import foobnix_localization from foobnix.helpers.textarea import ScrolledText from foobnix.helpers.window import ChildTopWindow from foobnix.gui.service.path_service import get_foobnix_resourse_path_by_name foobnix_localization() LOGO = get_foobnix_resourse_path_by_name(ICON_FOOBNIX) FFMPEG_NAME = "ffmpeg_foobnix" #fix win if os.name == 'posix': if os.uname()[4] == 'x86_64': FFMPEG_NAME += "_x64" class Converter(ChildTopWindow): def __init__(self): ChildTopWindow.__init__(self, title="Audio Converter", width=500, height=400) self.area = ScrolledText()
from gi.repository import Gtk from gi.repository import GLib from subprocess import Popen, PIPE from foobnix.fc.fc_helper import CONFIG_DIR from foobnix.util.const import ICON_FOOBNIX from foobnix.util.file_utils import open_in_filemanager from foobnix.util.localization import foobnix_localization from foobnix.helpers.textarea import ScrolledText from foobnix.helpers.window import ChildTopWindow from foobnix.gui.service.path_service import get_foobnix_resourse_path_by_name foobnix_localization() LOGO = get_foobnix_resourse_path_by_name(ICON_FOOBNIX) FFMPEG_NAME = "ffmpeg_foobnix" #fix win if os.name == 'posix': if os.uname()[4] == 'x86_64': FFMPEG_NAME += "_x64" class Converter(ChildTopWindow): def __init__(self): ChildTopWindow.__init__(self, title="Audio Converter", width=500, height=400) self.area = ScrolledText() vbox = Gtk.VBox(False, 10) vbox.pack_start(self.area.scroll) vbox.show() format_label = Gtk.Label(_('Format'))
def on_load(self): if FC().show_tray_icon: self.set_from_file(get_foobnix_resourse_path_by_name(ICON_FOOBNIX)) self.show()
def create_pixbuf_from_resource(name, size=None): path = get_foobnix_resourse_path_by_name(name) return create_pixbuf_from_path(path, size)
def get_fobnix_logo(self): return get_foobnix_resourse_path_by_name(ICON_FOOBNIX)