Allowed drag-and-drop reordering of custom places.

This commit is contained in:
clhodapp 2009-10-10 04:55:56 -05:00
parent 79ff1b93c9
commit b43d5ffe9f
2 changed files with 17 additions and 16 deletions

View File

@ -1011,6 +1011,7 @@
<widget class="GtkTreeView" id="customplacestree"> <widget class="GtkTreeView" id="customplacestree">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="reorderable">True</property>
</widget> </widget>
</child> </child>
</widget> </widget>

View File

@ -178,6 +178,10 @@ class mintMenuConfig( object ):
for count in range( len(self.customplacepaths) ): for count in range( len(self.customplacepaths) ):
self.customplacestreemodel.append( [ self.customplacenames[count], self.customplacepaths[count] ] ) 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.customplacestree.set_model( self.customplacestreemodel )
self.namescolumn = gtk.TreeViewColumn( 'Name', self.cell, text = 0 ) self.namescolumn = gtk.TreeViewColumn( 'Name', self.cell, text = 0 )
self.placescolumn = gtk.TreeViewColumn( 'Path', self.cell, text = 1 ) self.placescolumn = gtk.TreeViewColumn( 'Path', self.cell, text = 1 )
@ -273,7 +277,6 @@ class mintMenuConfig( object ):
if (nextiter != None): if (nextiter != None):
self.customplacestreemodel.swap(currentiter, lagiter) self.customplacestreemodel.swap(currentiter, lagiter)
self.updatePlacesGconf()
return return
@ -307,7 +310,6 @@ class mintMenuConfig( object ):
path = newPlacePath.get_text() path = newPlacePath.get_text()
if (name != "" and path !=""): if (name != "" and path !=""):
self.customplacestreemodel.append( (name, path) ) self.customplacestreemodel.append( (name, path) )
self.updatePlacesGconf()
def editPlace(self, editButton): def editPlace(self, editButton):
gladefile = os.path.join( self.path, "mintMenuConfig.glade" ) gladefile = os.path.join( self.path, "mintMenuConfig.glade" )
@ -349,7 +351,6 @@ class mintMenuConfig( object ):
if (name != "" and path != ""): if (name != "" and path != ""):
self.customplacestreemodel.set_value(currentiter, 0, name) self.customplacestreemodel.set_value(currentiter, 0, name)
self.customplacestreemodel.set_value(currentiter, 1, path) self.customplacestreemodel.set_value(currentiter, 1, path)
self.updatePlacesGconf()
def moveDown(self, downButton): def moveDown(self, downButton):
@ -360,7 +361,6 @@ class mintMenuConfig( object ):
if (nextiter != None): if (nextiter != None):
self.customplacestreemodel.swap(currentiter, nextiter) self.customplacestreemodel.swap(currentiter, nextiter)
self.updatePlacesGconf()
return return
@ -372,7 +372,6 @@ class mintMenuConfig( object ):
if (currentiter != None): if (currentiter != None):
self.customplacestreemodel.remove(currentiter) self.customplacestreemodel.remove(currentiter)
self.updatePlacesGconf()
return return
@ -382,17 +381,18 @@ class mintMenuConfig( object ):
else: else:
self.placesHeightButton.set_sensitive(False) self.placesHeightButton.set_sensitive(False)
def updatePlacesGconf(self): def updatePlacesGconf(self, treemodel, path, iter = None, new_order = None):
treeiter = self.customplacestreemodel.get_iter_first() # Do only if not partway though an append operation; Append = insert+change+change and each creates a signal
customplacenames = [ ] if ((iter == None) or (self.customplacestreemodel.get_value(iter, 1) != None)):
customplacepaths = [ ] treeiter = self.customplacestreemodel.get_iter_first()
while( treeiter != None ): customplacenames = [ ]
customplacenames = customplacenames + [ self.customplacestreemodel.get_value(treeiter, 0 ) ] customplacepaths = [ ]
customplacepaths = customplacepaths + [ self.customplacestreemodel.get_value(treeiter, 1 ) ] while( treeiter != None ):
treeiter = self.customplacestreemodel.iter_next(treeiter) customplacenames = customplacenames + [ self.customplacestreemodel.get_value(treeiter, 0 ) ]
self.gconfPlaces.set( "list-string", "custom_names", customplacenames) customplacepaths = customplacepaths + [ self.customplacestreemodel.get_value(treeiter, 1 ) ]
self.gconfPlaces.set( "list-string", "custom_paths", customplacepaths) treeiter = self.customplacestreemodel.iter_next(treeiter)
return self.gconfPlaces.set( "list-string", "custom_names", customplacenames)
self.gconfPlaces.set( "list-string", "custom_paths", customplacepaths)
window = mintMenuConfig() window = mintMenuConfig()