def on_drag_received(self, widget, context, x, y, selection, target_type, timestamp): if target_type == TARGET_TYPE_URI_LIST: uris = selection.get_uris() for uri in uris: if uri.lower().endswith(".fen"): newGameDialog.loadFileAndRun(uri) else: perspective = perspective_manager.get_perspective("database") perspective.open_chessfile(uri)
def on_drag_received(self, widget, context, x, y, selection, target_type, timestamp): if target_type == TARGET_TYPE_URI_LIST: uris = selection.get_uris() for uri in uris: if uri.lower().endswith(".fen"): newGameDialog.loadFileAndRun(uri) else: perspective = perspective_manager.get_perspective( "database") perspective.open_chessfile(uri)
def on_load_game1_activate(self, widget): opendialog = get_open_dialog() d = NestedFileChooserDialog(opendialog) filenames = d.run() opendialog.destroy() if filenames is not None: for filename in filenames: if filename.lower().endswith(".fen"): newGameDialog.loadFileAndRun(filename) else: perspective = perspective_manager.get_perspective( "database") perspective.open_chessfile(filename)
def on_load_game1_activate(self, widget): dialog = get_open_dialog() response = dialog.run() if response == Gtk.ResponseType.OK: filenames = dialog.get_filenames() else: filenames = None dialog.destroy() if filenames is not None: for filename in filenames: if filename.lower().endswith(".fen"): newGameDialog.loadFileAndRun(filename) else: perspective = perspective_manager.get_perspective("database") perspective.open_chessfile(filename)
def on_load_game1_activate(self, widget): dialog = get_open_dialog() response = dialog.run() if response == Gtk.ResponseType.OK: filenames = dialog.get_filenames() else: filenames = None dialog.destroy() if filenames is not None: for filename in filenames: if filename.lower().endswith(".fen"): newGameDialog.loadFileAndRun(filename) else: perspective = perspective_manager.get_perspective("database") perspective.open_chessfile(filename)
def on_drag_received(self, widget, context, x, y, selection, target_type, timestamp): if target_type == TARGET_TYPE_URI_LIST: NOTPROC, PARTIAL, FULL = range(3) status = NOTPROC uris = selection.get_uris() for uri in uris: fn, fext = os.path.splitext(uri.lower()) b = False # Chess position if fext == '.fen': b = newGameDialog.loadFileAndRun(uri) # Shortcut elif fext in ['.url', '.desktop']: # Preconf if fext == '.url': sectname = 'InternetShortcut' typeok = True elif fext == '.desktop': sectname = 'Desktop Entry' typeok = False else: assert (False) # Read the shortcut filename = splitUri(uri)[1] with open(filename, 'r') as file: content = file.read() lines = content.replace("\r", '').split("\n") # Extract the link section = False link = '' for item in lines: # Header if item.startswith('['): if section: break section = item.startswith('[%s]' % sectname) if not section: continue # Item if item.startswith('URL='): link = item[4:] if item.startswith('Type=Link') and fext == '.desktop': typeok = True # Load the link if typeok and link != '': create_task(get_internet_game(link)) b = True # Database else: perspective = perspective_manager.get_perspective( "database") perspective.open_chessfile(uri) b = True # Update the global status if b: if status == NOTPROC: status = FULL else: if status != NOTPROC: status = PARTIAL # Feedback about the load msg = '' if status == NOTPROC: msg = _( 'All the links failed to fetch a relevant chess content.') msgtype = Gtk.MessageType.ERROR elif status == PARTIAL: msg = _('Some links were invalid.') msgtype = Gtk.MessageType.WARNING if msg != '': dlg = Gtk.MessageDialog(mainwindow(), type=msgtype, buttons=Gtk.ButtonsType.OK, message_format=msg) dlg.run() dlg.destroy()