From b43d5ffe9f3f8ad8fae19d9fadc079c36c23e583 Mon Sep 17 00:00:00 2001 From: clhodapp Date: Sat, 10 Oct 2009 04:55:56 -0500 Subject: [PATCH] Allowed drag-and-drop reordering of custom places. --- .../linuxmint/mintMenu/mintMenuConfig.glade | 1 + usr/lib/linuxmint/mintMenu/mintMenuConfig.py | 32 +++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade b/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade index 5799729..4241cf9 100644 --- a/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade +++ b/usr/lib/linuxmint/mintMenu/mintMenuConfig.glade @@ -1011,6 +1011,7 @@ True True + True diff --git a/usr/lib/linuxmint/mintMenu/mintMenuConfig.py b/usr/lib/linuxmint/mintMenu/mintMenuConfig.py index 192b542..b50d4e9 100755 --- a/usr/lib/linuxmint/mintMenu/mintMenuConfig.py +++ b/usr/lib/linuxmint/mintMenu/mintMenuConfig.py @@ -178,6 +178,10 @@ class mintMenuConfig( object ): for count in range( len(self.customplacepaths) ): self.customplacestreemodel.append( [ self.customplacenames[count], self.customplacepaths[count] ] ) + + self.customplacestreemodel.connect("row-changed", self.updatePlacesGconf) + self.customplacestreemodel.connect("row-deleted", self.updatePlacesGconf) + self.customplacestreemodel.connect("rows-reordered", self.updatePlacesGconf) self.customplacestree.set_model( self.customplacestreemodel ) self.namescolumn = gtk.TreeViewColumn( 'Name', self.cell, text = 0 ) self.placescolumn = gtk.TreeViewColumn( 'Path', self.cell, text = 1 ) @@ -273,7 +277,6 @@ class mintMenuConfig( object ): if (nextiter != None): self.customplacestreemodel.swap(currentiter, lagiter) - self.updatePlacesGconf() return @@ -307,7 +310,6 @@ class mintMenuConfig( object ): path = newPlacePath.get_text() if (name != "" and path !=""): self.customplacestreemodel.append( (name, path) ) - self.updatePlacesGconf() def editPlace(self, editButton): gladefile = os.path.join( self.path, "mintMenuConfig.glade" ) @@ -349,7 +351,6 @@ class mintMenuConfig( object ): if (name != "" and path != ""): self.customplacestreemodel.set_value(currentiter, 0, name) self.customplacestreemodel.set_value(currentiter, 1, path) - self.updatePlacesGconf() def moveDown(self, downButton): @@ -360,7 +361,6 @@ class mintMenuConfig( object ): if (nextiter != None): self.customplacestreemodel.swap(currentiter, nextiter) - self.updatePlacesGconf() return @@ -372,7 +372,6 @@ class mintMenuConfig( object ): if (currentiter != None): self.customplacestreemodel.remove(currentiter) - self.updatePlacesGconf() return @@ -382,17 +381,18 @@ class mintMenuConfig( object ): else: self.placesHeightButton.set_sensitive(False) - def updatePlacesGconf(self): - treeiter = self.customplacestreemodel.get_iter_first() - customplacenames = [ ] - customplacepaths = [ ] - while( treeiter != None ): - customplacenames = customplacenames + [ self.customplacestreemodel.get_value(treeiter, 0 ) ] - customplacepaths = customplacepaths + [ self.customplacestreemodel.get_value(treeiter, 1 ) ] - treeiter = self.customplacestreemodel.iter_next(treeiter) - self.gconfPlaces.set( "list-string", "custom_names", customplacenames) - self.gconfPlaces.set( "list-string", "custom_paths", customplacepaths) - return + def updatePlacesGconf(self, treemodel, path, iter = None, new_order = None): +# Do only if not partway though an append operation; Append = insert+change+change and each creates a signal + if ((iter == None) or (self.customplacestreemodel.get_value(iter, 1) != None)): + treeiter = self.customplacestreemodel.get_iter_first() + customplacenames = [ ] + customplacepaths = [ ] + while( treeiter != None ): + customplacenames = customplacenames + [ self.customplacestreemodel.get_value(treeiter, 0 ) ] + customplacepaths = customplacepaths + [ self.customplacestreemodel.get_value(treeiter, 1 ) ] + treeiter = self.customplacestreemodel.iter_next(treeiter) + self.gconfPlaces.set( "list-string", "custom_names", customplacenames) + self.gconfPlaces.set( "list-string", "custom_paths", customplacepaths) window = mintMenuConfig()