Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    def __open_menu__(self, widget):
        dialog = gtk.FileChooserDialog("Open menu...",
                                        self.window ,gtk.FILE_CHOOSER_ACTION_OPEN,
                                        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                        gtk.STOCK_OPEN, gtk.RESPONSE_OK))
        dialog.set_default_response(gtk.RESPONSE_OK)

        filter = gtk.FileFilter()
        filter.set_name("Fluxbox menu")
        filter.add_pattern("menu")
        dialog.add_filter(filter)

        filter2 = gtk.FileFilter()
        filter2.set_name("All Files")
        filter2.add_pattern("*")
        dialog.add_filter(filter2)

        response = dialog.run()
        if response == gtk.RESPONSE_OK:
            self.treeview.get_model().clear()
            self.menuFile = dialog.get_filename()
            menu = handleMenu.read_menu(self.menuFile)
            self.__fill_treeview__(menu)
            self.window.set_title(self.menuFile + ' - ' + windowTitle)
            dialog.destroy()
        else:
            #print 'Closed, no files selected'
            dialog.destroy()

        return
Ejemplo n.º 3
0
    def __open_menu__(self, widget):
        dialog = gtk.FileChooserDialog("Open menu...", self.window,
                                       gtk.FILE_CHOOSER_ACTION_OPEN,
                                       (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                        gtk.STOCK_OPEN, gtk.RESPONSE_OK))
        dialog.set_default_response(gtk.RESPONSE_OK)

        filter = gtk.FileFilter()
        filter.set_name("Fluxbox menu")
        filter.add_pattern("menu")
        dialog.add_filter(filter)

        filter2 = gtk.FileFilter()
        filter2.set_name("All Files")
        filter2.add_pattern("*")
        dialog.add_filter(filter2)

        response = dialog.run()
        if response == gtk.RESPONSE_OK:
            self.treeview.get_model().clear()
            self.menuFile = dialog.get_filename()
            menu = handleMenu.read_menu(self.menuFile)
            self.__fill_treeview__(menu)
            self.window.set_title(self.menuFile + ' - ' + windowTitle)
            dialog.destroy()
        else:
            #print 'Closed, no files selected'
            dialog.destroy()

        return
Ejemplo n.º 4
0
 def __undo_clicked__(self, widget):
     """Loads the menu.bck, so reverts to last saved backup"""
     if saveBackup:
         if isfile(self.menuFile + '.bck'):
             self.treeview.get_model().clear()
             menu = handleMenu.read_menu(self.menuFile + '.bck')
             self.__fill_treeview__(menu)
         else:
             message = gtk.MessageDialog(self.window, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
                                          "Cannot revert to last backup: No backup-file (%s.bck)" %self.menuFile)
             message.run()
             message.destroy()
     else:
         message = gtk.MessageDialog(self.window, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
                                      "Cannot revert to last backup: Backups are not enabled")
         message.run()
         message.destroy()
  
     return
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
    def __undo_clicked__(self, widget):
        """Loads the menu.bck, so reverts to last saved backup"""
        if saveBackup:
            if isfile(self.menuFile + '.bck'):
                self.treeview.get_model().clear()
                menu = handleMenu.read_menu(self.menuFile + '.bck')
                self.__fill_treeview__(menu)
            else:
                message = gtk.MessageDialog(
                    self.window, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
                    "Cannot revert to last backup: No backup-file (%s.bck)" %
                    self.menuFile)
                message.run()
                message.destroy()
        else:
            message = gtk.MessageDialog(
                self.window, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
                "Cannot revert to last backup: Backups are not enabled")
            message.run()
            message.destroy()

        return
Ejemplo n.º 7
0
    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
Ejemplo n.º 8
0
    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