def manual_connect(self, *_args): ''' This function is called when the user selects the manual connection option from the menu. It requests a host/ip to connect to. ''' dialog = dialogs.TextEntryDialog( _("Enter IP address and port for share"), _("Enter IP address and port.")) resp = dialog.run() if resp == Gtk.ResponseType.OK: loc = dialog.get_value().strip() host = loc # the port will be anything after the last : p = host.rfind(":") # ipv6 literals should have a closing brace before the port b = host.rfind("]") if p > b: try: port = int(host[p + 1:]) host = host[:p] except ValueError: logger.error('non-numeric port specified') return else: port = 3689 # if no port specified, use default DAAP port # if it's an ipv6 host with brackets, strip them if host and host[0] == '[' and host[-1] == ']': host = host[1:-1] self.connect_share(None, (loc, host, port, None))
def rename_playlist(self, playlist): """ Renames the playlist """ if playlist is None: return # Ask for new name dialog = dialogs.TextEntryDialog( _("Enter the new name you want for your playlist"), _("Rename Playlist"), playlist.name) result = dialog.run() name = dialog.get_value() dialog.destroy() if result != Gtk.ResponseType.OK or name == '': return if name in self.playlist_manager.playlists: # name is already in use dialogs.error( self.parent, _("The " "playlist name you entered is already in use.")) return selection = self.tree.get_selection() (model, iter) = selection.get_selected() model.set_value(iter, 1, name) # Update the manager aswell self.playlist_manager.rename_playlist(playlist, name)
def on_menu_add_category(self, widget, name, parent, context): # TODO: instead of dialog, just add a new thing, make it editable? input = dialogs.TextEntryDialog( _('New Category?'), _('Enter new group category name')) if input.run() == gtk.RESPONSE_OK: category = input.get_value() if category != "": model, paths = context['selected-rows'] if model.add_category( category ): self.emit( 'category-changed', category_change.added, category )
def on_search(self): """ Called when the user wants to search for a specific stream """ dialog = dialogs.TextEntryDialog(_("Enter the search keywords"), _("Icecast Search")) result = dialog.run() if result == Gtk.ResponseType.OK: keyword = dialog.get_value() self.do_search(keyword)
def on_add_podcast(self, *e): dialog = dialogs.TextEntryDialog(_('Enter the URL of the ' 'podcast to add'), _('Open Podcast')) dialog.set_transient_for(self.parent) dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) result = dialog.run() dialog.hide() if result == gtk.RESPONSE_OK: url = dialog.get_value() self._parse_podcast(url, True)
def on_add_podcast(self, *e): dialog = dialogs.TextEntryDialog(_('Enter the URL of the ' 'podcast to add'), _('Open Podcast')) dialog.set_transient_for(self.parent) dialog.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) result = dialog.run() dialog.hide() if result == Gtk.ResponseType.OK: url = dialog.get_value() self._parse_podcast(url, True)
def on_menu_add_group( self, widget, name, parent, context): # TODO: instead of dialog, just add a new thing, make it editable? input = dialogs.TextEntryDialog( _('New tag value?'), _('Enter new tag value')) if input.run() == gtk.RESPONSE_OK: group = input.get_value() if group != "": model, paths = context['selected-rows'] categories = context['categories'] if len(categories): category = categories[0] else: category = uncategorized if model.add_group( group, category, True ): self.emit( 'group-changed', group_change.added, group ) else: self.emit( 'group-changed', group_change.edited, None )
def _add_new_station(self, locs): """ Add a new station """ # If the user dragged files prompt for a new playlist name # else if they dragged a playlist add the playlist # We don't want the tracks in the playlists to be added to the # master tracks list so we pass in False (tracks, playlists) = self.tree.get_drag_data(locs, False) # First see if they dragged any playlist files for new_playlist in playlists: self.model.append( self.custom, [self.playlist_image, new_playlist.name, new_playlist]) # We are adding a completely new playlist with tracks so we save it self.playlist_manager.save_playlist(new_playlist, overwrite=True) # After processing playlist proceed to ask the user for the # name of the new playlist to add and add the tracks to it if len(tracks) > 0: dialog = dialogs.TextEntryDialog( _("Enter the name you want for your new playlist"), _("New Playlist")) result = dialog.run() if result == Gtk.ResponseType.OK: name = dialog.get_value() if not name == "": # Create the playlist from all of the tracks new_playlist = xl.playlist.Playlist(name) new_playlist.extend(tracks) self.playlist_nodes[new_playlist] = self.model.append( self.custom, [self.playlist_image, new_playlist.name, new_playlist], ) self.tree.expand_row(self.model.get_path(self.custom), False) # We are adding a completely new playlist with tracks so we save it self.playlist_manager.save_playlist(new_playlist) self._load_playlist_nodes(new_playlist)
def open_url(self, *e): """ Displays a dialog to open a url """ dialog = dialogs.TextEntryDialog(_('Enter the URL to open'), _('Open URL')) dialog.set_transient_for(self.main.window) dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) clipboard = gtk.clipboard_get() text = clipboard.wait_for_text() if text is not None: location = gio.File(uri=text) if location.get_uri_scheme() is not None: dialog.set_value(text) result = dialog.run() dialog.hide() if result == gtk.RESPONSE_OK: url = dialog.get_value() self.open_uri(url, play=False)