def _file_close(action, window): debug(DEBUG_COMMANDS) active_tab = window.get_active_tab() if active_tab == None: return _file_close_tab(active_tab, window)
def load_file_list(window, uris, encoding, line_pos, create): loaded_files = 0 jump_to = True flash = True # Whether to flash a message in the statusbar debug(DEBUG_COMMANDS) if uris == None: return 0 win_docs = window.get_documents() files_to_load = [] for uri in uris: if not is_duplicated_uri(files_to_load, uri): tab = get_tab_from_uri(win_docs, uri) if tab != None: if uri == uris[0]: window.set_active_tab(tab) jump_to = False if line_pos > 0: doc = tab.get_document(); view = tab.get_view(); # document counts lines starting from 0 document.goto_line(line_pos - 1) view.scroll_to_cursor() ++loaded_files else: files_to_load.append(uris); # TODO: Or prepend? if files_to_load == None: return loaded_files # files_to_load = g_slist_reverse (files_to_load); tab = window.get_active_tab() if tab != None: doc = tab.get_document() if doc.is_untouched() and tab.get_state == TAB_STATE_NORMAL: uri = files_to_load.pop(0) # Removes the first element and returns it tab.load(uri, encoding, line_pos, create) jump_to = False; if len(files_to_load) == 0: # There is only a single file to load uri_for_display = utils.format_uri_for_display(uri) statusbar.flash_message(window.get_statusbar(), window._generic_message_cid, "Loading file '%s'\342\200\246" % uri_for_display) flash = False ++loaded_files for uri_to_load in files_to_load: if uri_to_load == None: return 0 tab = window.create_tab_from_uri(uri_to_load, encoding, line_pos, create, jump_to) if tab != None: jump_to = False ++loaded_files if flash: if loaded_files == 1: if tab == None: return loaded_files doc = tab.get_document() uri_for_display = doc.get_uri_for_display() # gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar), # window->priv->generic_message_cid, # _("Loading file '%s'\342\200\246"), # uri_for_display); else: pass # gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar), # window->priv->generic_message_cid, # ngettext("Loading %d file\342\200\246", # "Loading %d files\342\200\246", # loaded_files), # loaded_files); return loaded_files
def _file_save_as(action, window): # gedit_debug (DEBUG_COMMANDS); tab = window.get_active_tab() file_save_as(tab, window)
def _file_save(action, window): tab = window.get_active_tab() if tab == None: return file_save(tab, window)
def load_file_list(window, uris, encoding, line_pos, create): loaded_files = 0 jump_to = True flash = True # Whether to flash a message in the statusbar debug(DEBUG_COMMANDS) if uris == None: return 0 win_docs = window.get_documents() files_to_load = [] for uri in uris: if not is_duplicated_uri(files_to_load, uri): tab = get_tab_from_uri(win_docs, uri) if tab != None: if uri == uris[0]: window.set_active_tab(tab) jump_to = False if line_pos > 0: doc = tab.get_document() view = tab.get_view() # document counts lines starting from 0 document.goto_line(line_pos - 1) view.scroll_to_cursor() ++loaded_files else: files_to_load.append(uris) # TODO: Or prepend? if files_to_load == None: return loaded_files # files_to_load = g_slist_reverse (files_to_load); tab = window.get_active_tab() if tab != None: doc = tab.get_document() if doc.is_untouched() and tab.get_state == TAB_STATE_NORMAL: uri = files_to_load.pop( 0) # Removes the first element and returns it tab.load(uri, encoding, line_pos, create) jump_to = False if len(files_to_load) == 0: # There is only a single file to load uri_for_display = utils.format_uri_for_display(uri) statusbar.flash_message( window.get_statusbar(), window._generic_message_cid, "Loading file '%s'\342\200\246" % uri_for_display) flash = False ++loaded_files for uri_to_load in files_to_load: if uri_to_load == None: return 0 tab = window.create_tab_from_uri(uri_to_load, encoding, line_pos, create, jump_to) if tab != None: jump_to = False ++loaded_files if flash: if loaded_files == 1: if tab == None: return loaded_files doc = tab.get_document() uri_for_display = doc.get_uri_for_display() # gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar), # window->priv->generic_message_cid, # _("Loading file '%s'\342\200\246"), # uri_for_display); else: pass # gedit_statusbar_flash_message (GEDIT_STATUSBAR (window->priv->statusbar), # window->priv->generic_message_cid, # ngettext("Loading %d file\342\200\246", # "Loading %d files\342\200\246", # loaded_files), # loaded_files); return loaded_files