Implemented initial functional GUI for customizing Places in Preferences window.

This commit is contained in:
clhodapp 2009-08-08 04:17:44 -04:00
parent 62e210c2a3
commit 49074de2c5
4 changed files with 536 additions and 12 deletions

View File

@ -824,10 +824,308 @@
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<widget class="GtkFrame" id="frame3">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="top_padding">2</property>
<property name="bottom_padding">10</property>
<property name="left_padding">14</property>
<child>
<widget class="GtkVBox" id="vbox4">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<widget class="GtkCheckButton" id="computercheckbutton">
<property name="label" translatable="yes">Computer</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="homecheckbutton">
<property name="label" translatable="yes">Home Folder</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="networkcheckbutton">
<property name="label" translatable="yes">Network</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="desktopcheckbutton">
<property name="label" translatable="yes">Desktop</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="trashcheckbutton">
<property name="label" translatable="yes">Trash</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="position">4</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="label" translatable="yes">Toggle Default Places:</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="top_padding">9</property>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child>
<widget class="GtkTreeView" id="customplacestree">
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
</child>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<widget class="GtkVButtonBox" id="vbuttonbox1">
<property name="visible">True</property>
<property name="spacing">5</property>
<child>
<widget class="GtkButton" id="newButton">
<property name="label" translatable="yes">gtk-new</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="editButton">
<property name="label" translatable="yes">gtk-edit</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">6</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkVButtonBox" id="vbuttonbox2">
<property name="visible">True</property>
<child>
<widget class="GtkButton" id="upButton">
<property name="label" translatable="yes">gtk-go-up</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="downButton">
<property name="label" translatable="yes">gtk-go-down</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">5</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkVButtonBox" id="vbuttonbox3">
<property name="visible">True</property>
<child>
<widget class="GtkButton" id="removeButton">
<property name="label" translatable="yes">gtk-remove</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">5</property>
<property name="position">2</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">6</property>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="label" translatable="yes">Custom Places:</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xpad">1</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">5</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="placesLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Places</property>
</widget>
<packing>
<property name="position">5</property>
<property name="tab_fill">False</property>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="padding">2</property>
<property name="position">0</property>
</packing>
</child>
@ -860,4 +1158,106 @@
</widget>
</child>
</widget>
<widget class="GtkDialog" id="editPlaceDialog">
<property name="border_width">5</property>
<property name="type_hint">normal</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox2">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkEntry" id="nameEntryBox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="pathEntryBox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Path:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">Name:</property>
</widget>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area2">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<widget class="GtkButton" id="okButton">
<property name="label" translatable="yes">gtk-ok</property>
<property name="response_id">1</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="cancelButton">
<property name="label" translatable="yes">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -36,6 +36,7 @@ class mintMenuConfig( object ):
# Load glade file and extract widgets
gladefile = os.path.join( self.path, "mintMenuConfig.glade" )
wTree = gtk.glade.XML( gladefile, "mainWindow" )
editTree = gtk.glade.XML( gladefile, "editPlaceDialog" )
#i18n
@ -103,11 +104,21 @@ class mintMenuConfig( object ):
self.buttonIcon = wTree.get_widget( "buttonIcon" )
self.buttonIconImage = wTree.get_widget( "image_button_icon" )
self.searchCommand = wTree.get_widget( "search_command" )
self.computertoggle = wTree.get_widget( "computercheckbutton" )
self.homefoldertoggle = wTree.get_widget( "homecheckbutton" )
self.networktoggle = wTree.get_widget( "networkcheckbutton" )
self.desktoptoggle = wTree.get_widget( "desktopcheckbutton" )
self.trashtoggle = wTree.get_widget( "trashcheckbutton" )
self.customplacestree = wTree.get_widget( "customplacestree" )
self.editPlaceDialog = editTree.get_widget( "editPlaceDialog" )
self.editPlaceName = editTree.get_widget( "nameEntryBox" )
self.editPlacePath = editTree.get_widget( "pathEntryBox" )
wTree.get_widget( "closeButton" ).connect("clicked", gtk.main_quit )
self.gconf = EasyGConf( "/apps/mintMenu/" )
self.gconfApplications = EasyGConf( "/apps/mintMenu/plugins/applications/" )
self.gconfPlaces = EasyGConf( "/apps/mintMenu/plugins/places/" )
self.useCustomColors.connect( "toggled", self.toggleUseCustomColors )
@ -137,6 +148,31 @@ class mintMenuConfig( object ):
self.showRecentPlugin.connect("toggled", self.toggleRecent )
self.showRecentPlugin.set_active( self.getRecentToggle() )
self.bindGconfValueToWidget( self.gconfPlaces, "bool", "show_computer", self.computertoggle, "toggled", self.computertoggle.set_active, self.computertoggle.get_active )
self.bindGconfValueToWidget( self.gconfPlaces, "bool", "show_home_folder", self.homefoldertoggle, "toggled", self.homefoldertoggle.set_active, self.homefoldertoggle.get_active )
self.bindGconfValueToWidget( self.gconfPlaces, "bool", "show_network", self.networktoggle, "toggled", self.networktoggle.set_active, self.networktoggle.get_active )
self.bindGconfValueToWidget( self.gconfPlaces, "bool", "show_desktop", self.desktoptoggle, "toggled", self.desktoptoggle.set_active, self.desktoptoggle.get_active )
self.bindGconfValueToWidget( self.gconfPlaces, "bool", "show_trash", self.trashtoggle, "toggled", self.trashtoggle.set_active, self.trashtoggle.get_active )
self.customplacenames = self.gconfPlaces.get( "list-string", "custom_names", [ ] )
self.customplacepaths = self.gconfPlaces.get( "list-string", "custom_paths", [ ] )
self.customplacestreemodel = gtk.ListStore( str, str)
self.cell = gtk.CellRendererText()
for count in range( len(self.customplacepaths) ):
self.customplacestreemodel.append( [ self.customplacenames[count], self.customplacepaths[count] ] )
self.customplacestree.set_model( self.customplacestreemodel )
self.namescolumn = gtk.TreeViewColumn( 'Name', self.cell, text = 0 )
self.placescolumn = gtk.TreeViewColumn( 'Path', self.cell, text = 1 )
self.customplacestree.append_column( self.namescolumn )
self.customplacestree.append_column( self.placescolumn )
wTree.get_widget("newButton").connect("clicked", self.newPlace)
wTree.get_widget("editButton").connect("clicked", self.editPlace)
wTree.get_widget("upButton").connect("clicked", self.moveUp)
wTree.get_widget("downButton").connect("clicked", self.moveDown)
wTree.get_widget("removeButton").connect("clicked", self.removePlace)
wTree.get_widget( "mainWindow" ).present()
self.getBackgroundColor()
@ -205,6 +241,94 @@ class mintMenuConfig( object ):
def gdkColorToString( self, gdkColor ):
return "#%.2X%.2X%.2X" % ( gdkColor.red / 256, gdkColor.green / 256, gdkColor.blue / 256 )
def moveUp( self, upButton ):
treeselection = self.customplacestree.get_selection()
currentiter = (treeselection.get_selected())[1]
if ( treeselection != None ):
lagiter = self.customplacestreemodel.get_iter_first()
nextiter = self.customplacestreemodel.get_iter_first()
while ( (self.customplacestreemodel.get_path(nextiter) != self.customplacestreemodel.get_path(currentiter)) & (nextiter != None)):
lagiter = nextiter
nextiter = self.customplacestreemodel.iter_next(nextiter)
if (nextiter != None):
self.customplacestreemodel.swap(currentiter, lagiter)
self.updatePlacesGconf()
return
def newPlace(self, newButton):
self.editPlaceName.set_text("")
self.editPlacePath.set_text("")
response = self.editPlaceDialog.run()
self.editPlaceDialog.hide()
if (response == 1 ):
name = self.editPlaceName.get_text()
path = self.editPlacePath.get_text()
self.customplacestreemodel.append( (name, path) )
self.updatePlacesGconf()
def editPlace(self, editButton):
treeselection = self.customplacestree.get_selection()
currentiter = (treeselection.get_selected())[1]
if (currentiter != None):
initName = self.customplacestreemodel.get_value(currentiter, 0)
initPath = self.customplacestreemodel.get_value(currentiter, 1)
self.editPlaceName.set_text(initName)
self.editPlacePath.set_text(initPath)
response = self.editPlaceDialog.run()
self.editPlaceDialog.hide()
if (response == 1 ):
name = self.editPlaceName.get_text()
path = self.editPlacePath.get_text()
self.customplacestreemodel.set_value(currentiter, 0, name)
self.customplacestreemodel.set_value(currentiter, 1, path)
self.updatePlacesGconf()
def moveDown(self, downButton):
treeselection = self.customplacestree.get_selection()
currentiter = (treeselection.get_selected())[1]
nextiter = self.customplacestreemodel.iter_next(currentiter)
if (nextiter != None):
self.customplacestreemodel.swap(currentiter, nextiter)
self.updatePlacesGconf()
return
def removePlace(self, removeButton):
treeselection = self.customplacestree.get_selection()
currentiter = (treeselection.get_selected())[1]
if (currentiter != None):
self.customplacestreemodel.remove(currentiter)
self.updatePlacesGconf()
return
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
window = mintMenuConfig()
gtk.main()

BIN
usr/lib/linuxmint/mintMenu/plugins/easygconf.pyc Normal file → Executable file

Binary file not shown.

View File

@ -58,6 +58,7 @@ class pluginclass( object ):
self.content_holder.set_size_request( self.width, self.height )
def wake (self) :
if ( self.showtrash == True ):
self.refreshTrash()
def destroy( self ):
@ -98,7 +99,7 @@ class pluginclass( object ):
# Get names for custom items
self.customnames = self.gconf.get( "list-string", "custom-names", [ ] )
self.customnames = self.gconf.get( "list-string", "custom_names", [ ] )
# Hide vertical dotted separator
self.hideseparator = self.gconf.get( "bool", "hide_separator", False )
@ -163,8 +164,7 @@ class pluginclass( object ):
self.trashButton.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop trash:" )
self.trashButton.show()
self.trashButton.connect( "button-release-event", self.trashPopup )
#self.refreshTrash()
self.refreshTrash()
self.placesBtnHolder.pack_start( self.trashButton, False, False )
self.mintMenuWin.setTooltip( self.trashButton, _("Browse deleted files") )