def __generatebutton_clicked__(self, widget): confirm = gtk.MessageDialog(self.window, gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO, "Are you sure you want to generate a new menu?\r\nWARNING! All modifications after last save will be lost!") reallygenerate = confirm.run() confirm.destroy() if reallygenerate == gtk.RESPONSE_YES: pleasewait = gtk.MessageDialog(self.window, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_NONE, "Please wait, the menu is being generated ("+externalGenerator+")") pleasewait.show() backupfine = 1 if saveBackupBeforeGenerating: backupfine = handleMenu.backup_menu(self.menuFile, '.bck', True) if backupfine == 1: generated = os.system(expanduser(externalGenerator)) else: warning = gtk.MessageDialog(dialog, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, "Saving backup failed so menu was not generated!\r\n") warning.run() warning.destroy() print "BACKUP FAILED!!!" generated = 1 pleasewait.destroy() if generated == 0: # Generation was succesfull self.treeview.get_model().clear() menu = handleMenu.read_menu(expanduser(generatedFile)) self.fill_treeview(menu) return
def __generatebutton_clicked__(self, widget): confirm = gtk.MessageDialog( self.window, gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO, "Are you sure you want to generate a new menu?\r\nWARNING! All modifications after last save will be lost!" ) reallygenerate = confirm.run() confirm.destroy() if reallygenerate == gtk.RESPONSE_YES: pleasewait = gtk.MessageDialog( self.window, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_NONE, "Please wait, the menu is being generated (" + externalGenerator + ")") pleasewait.show() backupfine = 1 if saveBackupBeforeGenerating: backupfine = handleMenu.backup_menu(self.menuFile, '.bck', True) if backupfine == 1: generated = os.system(expanduser(externalGenerator)) else: warning = gtk.MessageDialog( dialog, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, "Saving backup failed so menu was not generated!\r\n") warning.run() warning.destroy() print "BACKUP FAILED!!!" generated = 1 pleasewait.destroy() if generated == 0: # Generation was succesfull self.treeview.get_model().clear() menu = handleMenu.read_menu(expanduser(generatedFile)) self.fill_treeview(menu) return
def __save_clicked__(self, widget): # Save the menu, call handleMenu -> save if self.menuFile: menu = self.__serialize_menu__() # Save a backup if it is enabled if saveBackup: if handleMenu.backup_menu(self.menuFile, '.bck', True) != 1: warning = gtk.MessageDialog(dialog, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, "Could not save backup to " + self.menuFile + ".bck!") warning.run() warning.destroy() handleMenu.save_menu(menu, self.menuFile, True, useIcons) else: # Call save as -function to get the new filename print 'No menu-file' return
def __save_clicked__(self, widget): # Save the menu, call handleMenu -> save if self.menuFile: menu = self.__serialize_menu__() # Save a backup if it is enabled if saveBackup: if handleMenu.backup_menu(self.menuFile, '.bck', True) != 1: warning = gtk.MessageDialog( dialog, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, "Could not save backup to " + self.menuFile + ".bck!") warning.run() warning.destroy() handleMenu.save_menu(menu, self.menuFile, True, useIcons) else: # Call save as -function to get the new filename print 'No menu-file' return
def __init__(self): """The main fluxMenu window will show""" gladefile=programPath + "project1.glade" windowname="window1" self.wTree=gtk.glade.XML (gladefile,windowname) #self.set_geometry_hints(min_width = 300) self.window = self.wTree.get_widget("window1") self.typeBox = self.wTree.get_widget("typebox") self.typeLabel = self.wTree.get_widget("typelabel") self.treeview = self.wTree.get_widget("treeview1") self.nameEntry = self.wTree.get_widget("nameentry") self.commandEntry = self.wTree.get_widget("commandentry") self.commandButton = self.wTree.get_widget("commandbutton") self.nameLabel = self.wTree.get_widget("namelabel") self.iconButton = self.wTree.get_widget("iconbutton") self.clearIconButton = self.wTree.get_widget("clearicon") self.iconIcon = self.wTree.get_widget("icon") self.commandLabel = self.wTree.get_widget("commandlabel") self.errorLabel = self.wTree.get_widget("errorlabel") self.tooltips = gtk.Tooltips() self.__enable_fields__(0x00) # Disable (unusable) toolbar items self.__enable_toolbar__(False, False) #self.wTree.get_widget("preferencesbutton").set_sensitive(False) #self.wTree.get_widget("generatebutton").set_sensitive(False) self.wTree.get_widget("sortbutton").set_sensitive(False) handler = {"on_save1_activate":self.__save_clicked__, "on_save_as1_activate":self.__save_as_clicked__, "on_open1_activate":self.__open_menu__, "on_new1_activate":self.__new_menu__, "on_undo1_activate":self.__undo_clicked__, "on_deletebutton_clicked":self.__delete_item__, "on_submenubutton_clicked":self.__create_submenu__, "on_itembutton_clicked":self.__create_item__, "on_separatorbutton_clicked":self.__create_separator__, "on_generatebutton_clicked":self.__generatebutton_clicked__, "on_preferencesbutton_clicked":self.__preferences_dialog__, "on_preferences1_activate":self.__preferences_dialog__, "on_commandbutton_clicked":self.__commandbutton_clicked__, "on_icon_clicked":self.__icon_clicked__, "on_clearicon_clicked":self.__clearicon_clicked__, "on_typebox_changed":self.__typebox_changed__, "on_treeview1_cursor_changed":self.__treeview_changed__, "on_info_changed":self.__info_changed__, "on_about1_activate":self.__about1_activate__, "on_quit1_activate":(gtk.main_quit), "on_quit_clicked":(gtk.main_quit), "on_window1_destroy":(gtk.main_quit)} self.wTree.signal_autoconnect (handler) # Prepare the "type" -combobox for use self.__prepare_type_combobox__() # And the treeview self.__prepare_treeview__() # Read the menu file and fill the treeview # Try to find a default menu self.menuFile = '' for fileName in defaultMenus: menu = handleMenu.read_menu(expanduser(fileName)) if menu: self.menuFile = expanduser(fileName) self.__fill_treeview__(menu) break # If a menu was found and 'save original' is set # try to do a backup (overwrite as in 'overwrite original') if menu: if saveOriginal: if handleMenu.backup_menu(self.menuFile, '.original', overwriteOriginal) == 0: warning = gtk.MessageDialog(dialog, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, "Could not save original menu to menu.original!") warning.run() warning.destroy() # Set title for window according to filename... self.window.set_title(self.menuFile + ' - ' + windowTitle) self.oldType = 0 return
def __init__(self): """The main fluxMenu window will show""" gladefile = programPath + "project1.glade" windowname = "window1" self.wTree = gtk.glade.XML(gladefile, windowname) #self.set_geometry_hints(min_width = 300) self.window = self.wTree.get_widget("window1") self.typeBox = self.wTree.get_widget("typebox") self.typeLabel = self.wTree.get_widget("typelabel") self.treeview = self.wTree.get_widget("treeview1") self.nameEntry = self.wTree.get_widget("nameentry") self.commandEntry = self.wTree.get_widget("commandentry") self.commandButton = self.wTree.get_widget("commandbutton") self.nameLabel = self.wTree.get_widget("namelabel") self.iconButton = self.wTree.get_widget("iconbutton") self.clearIconButton = self.wTree.get_widget("clearicon") self.iconIcon = self.wTree.get_widget("icon") self.commandLabel = self.wTree.get_widget("commandlabel") self.errorLabel = self.wTree.get_widget("errorlabel") self.tooltips = gtk.Tooltips() self.__enable_fields__(0x00) # Disable (unusable) toolbar items self.__enable_toolbar__(False, False) #self.wTree.get_widget("preferencesbutton").set_sensitive(False) #self.wTree.get_widget("generatebutton").set_sensitive(False) self.wTree.get_widget("sortbutton").set_sensitive(False) handler = { "on_save1_activate": self.__save_clicked__, "on_save_as1_activate": self.__save_as_clicked__, "on_open1_activate": self.__open_menu__, "on_new1_activate": self.__new_menu__, "on_undo1_activate": self.__undo_clicked__, "on_deletebutton_clicked": self.__delete_item__, "on_submenubutton_clicked": self.__create_submenu__, "on_itembutton_clicked": self.__create_item__, "on_separatorbutton_clicked": self.__create_separator__, "on_generatebutton_clicked": self.__generatebutton_clicked__, "on_preferencesbutton_clicked": self.__preferences_dialog__, "on_preferences1_activate": self.__preferences_dialog__, "on_commandbutton_clicked": self.__commandbutton_clicked__, "on_icon_clicked": self.__icon_clicked__, "on_clearicon_clicked": self.__clearicon_clicked__, "on_typebox_changed": self.__typebox_changed__, "on_treeview1_cursor_changed": self.__treeview_changed__, "on_info_changed": self.__info_changed__, "on_about1_activate": self.__about1_activate__, "on_quit1_activate": (gtk.main_quit), "on_quit_clicked": (gtk.main_quit), "on_window1_destroy": (gtk.main_quit) } self.wTree.signal_autoconnect(handler) # Prepare the "type" -combobox for use self.__prepare_type_combobox__() # And the treeview self.__prepare_treeview__() # Read the menu file and fill the treeview # Try to find a default menu self.menuFile = '' for fileName in defaultMenus: menu = handleMenu.read_menu(expanduser(fileName)) if menu: self.menuFile = expanduser(fileName) self.__fill_treeview__(menu) break # If a menu was found and 'save original' is set # try to do a backup (overwrite as in 'overwrite original') if menu: if saveOriginal: if handleMenu.backup_menu(self.menuFile, '.original', overwriteOriginal) == 0: warning = gtk.MessageDialog( dialog, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, "Could not save original menu to menu.original!") warning.run() warning.destroy() # Set title for window according to filename... self.window.set_title(self.menuFile + ' - ' + windowTitle) self.oldType = 0 return