def _file_close_tab(tab, window): debug(DEBUG_COMMANDS) if window != tab.get_toplevel(): return window.set_data(IS_CLOSING_ALL, False) window.set_data(IS_QUITTING, False) if tab._can_close(): window.close_tab(tab)
def _file_open(action, window): debug(DEBUG_COMMANDS) data = window.get_data(OPEN_DIALOG_KEY) if data != None: data.present() return open_dialog = FileChooserDialog("Open Files", window, gtk.FILE_CHOOSER_ACTION_OPEN, None, [[gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL], [gtk.STOCK_OPEN, gtk.RESPONSE_OK]]) window.set_data(OPEN_DIALOG_KEY, open_dialog) open_dialog.weak_ref(open_dialog_destroyed, window) # TODO: Set the curret folder uri open_dialog.connect("response", open_dialog_response_cb, window) open_dialog.show()
def file_close_all(window, is_quitting): debug(DEBUG_COMMANDS) if window.get_state() & (WINDOW_STATE_SAVING | WINDOW_STATE_PRINTING | WINDOW_STATE_SAVING_SESSION): return window.set_data(IS_CLOSING_ALL, True) window.set_data(IS_QUITTING, is_quitting) unsaved_docs = window.get_unsaved_documents() if len(unsaved_docs) == 0: # There is no document to save -> close all tabs window.close_all_tabs() if is_quitting: window.destroy() return if len(unsaved_docs) == 1: # There is only one unsaved document doc = unsaved_docs[0] tab = tab_get_from_document(doc) if tab == None: return window.set_active_tab(tab) dlg = close_confirmation_dialog_new_single(window, doc, False) else: dlg = close_confirmation_dialog_new(window, unsaved_docs, False) dlg.connect("response", close_confirmation_dialog_response_handler, window) dlg.show()
def open_dialog_destroyed(window): debug(DEBUG_COMMANDS) window.set_data(OPEN_DIALOG_KEY, None)