Fixed indentation
This commit is contained in:
parent
1f9cfb7e6d
commit
69e08564fe
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -1,3 +1,9 @@
|
|||||||
|
mintmenu (5.1.8) katya; urgency=low
|
||||||
|
|
||||||
|
* Fixed indentation issue in recent documents plugin
|
||||||
|
|
||||||
|
-- Clement Lefebvre <root@linuxmint.com> Wed, 30 Mar 2011 19:01:00 +0000
|
||||||
|
|
||||||
mintmenu (5.1.7) katya; urgency=low
|
mintmenu (5.1.7) katya; urgency=low
|
||||||
|
|
||||||
* Added support for Xfce
|
* Added support for Xfce
|
||||||
|
@ -15,208 +15,206 @@ from easybuttons import *
|
|||||||
|
|
||||||
|
|
||||||
class pluginclass:
|
class pluginclass:
|
||||||
"""This is the main class for the plugin"""
|
"""This is the main class for the plugin"""
|
||||||
"""It MUST be named pluginclass"""
|
"""It MUST be named pluginclass"""
|
||||||
|
|
||||||
def __init__( self, mintMenuWin, toggleButton, de ):
|
def __init__( self, mintMenuWin, toggleButton, de ):
|
||||||
|
|
||||||
self.Win = mintMenuWin
|
self.Win = mintMenuWin
|
||||||
self.toggleButton = toggleButton
|
self.toggleButton = toggleButton
|
||||||
self.de = de
|
self.de = de
|
||||||
|
|
||||||
#The Glade file for the plugin
|
#The Glade file for the plugin
|
||||||
self.gladefile = os.path.join( os.path.dirname( __file__ ), "recent.glade" )
|
self.gladefile = os.path.join( os.path.dirname( __file__ ), "recent.glade" )
|
||||||
|
|
||||||
#Read GLADE file
|
#Read GLADE file
|
||||||
self.wTree = gtk.glade.XML( self.gladefile, "window1" )
|
self.wTree = gtk.glade.XML( self.gladefile, "window1" )
|
||||||
|
|
||||||
#Set 'window' property for the plugin (Must be the root widget)
|
#Set 'window' property for the plugin (Must be the root widget)
|
||||||
self.window = self.wTree.get_widget( "window1" )
|
self.window = self.wTree.get_widget( "window1" )
|
||||||
|
|
||||||
#Set 'heading' property for plugin
|
#Set 'heading' property for plugin
|
||||||
self.heading = _("Recent documents")
|
self.heading = _("Recent documents")
|
||||||
|
|
||||||
#This should be the first item added to the window in glade
|
#This should be the first item added to the window in glade
|
||||||
self.content_holder = self.wTree.get_widget( "eventbox1" )
|
self.content_holder = self.wTree.get_widget( "eventbox1" )
|
||||||
|
|
||||||
#Specify plugin width
|
#Specify plugin width
|
||||||
self.width = 250
|
self.width = 250
|
||||||
|
|
||||||
#Plugin icon
|
#Plugin icon
|
||||||
self.icon = 'gnome-folder.png'
|
self.icon = 'gnome-folder.png'
|
||||||
|
|
||||||
self.gconf_dir = '/apps/mintMenu/plugins/recent'
|
self.gconf_dir = '/apps/mintMenu/plugins/recent'
|
||||||
self.client = gconf.client_get_default()
|
self.client = gconf.client_get_default()
|
||||||
self.client.add_dir( '/apps/mintMenu/plugins/recent', gconf.CLIENT_PRELOAD_NONE )
|
self.client.add_dir( '/apps/mintMenu/plugins/recent', gconf.CLIENT_PRELOAD_NONE )
|
||||||
self.client.notify_add( '/apps/mintMenu/plugins/recent/height', self.RegenPlugin )
|
self.client.notify_add( '/apps/mintMenu/plugins/recent/height', self.RegenPlugin )
|
||||||
self.client.notify_add( '/apps/mintMenu/plugins/recent/width', self.RegenPlugin )
|
self.client.notify_add( '/apps/mintMenu/plugins/recent/width', self.RegenPlugin )
|
||||||
self.client.notify_add( '/apps/mintMenu/plugins/recent/num_recent_docs_to_show', self.RegenPlugin )
|
self.client.notify_add( '/apps/mintMenu/plugins/recent/num_recent_docs_to_show', self.RegenPlugin )
|
||||||
self.client.notify_add( '/apps/mintMenu/plugins/recent/recent_font_size', self.RegenPlugin )
|
self.client.notify_add( '/apps/mintMenu/plugins/recent/recent_font_size', self.RegenPlugin )
|
||||||
|
|
||||||
self.FileList=[]
|
self.FileList=[]
|
||||||
self.RecManagerInstance = gtk.recent_manager_get_default()
|
self.RecManagerInstance = gtk.recent_manager_get_default()
|
||||||
self.RecManagerInstance.connect("changed",self.DoRecent)
|
self.RecManagerInstance.connect("changed",self.DoRecent)
|
||||||
|
|
||||||
|
|
||||||
self.RegenPlugin()
|
self.RegenPlugin()
|
||||||
self.wTree.get_widget( "RecentTabs" ).set_current_page(1)
|
self.wTree.get_widget( "RecentTabs" ).set_current_page(1)
|
||||||
|
|
||||||
#Connect event handlers
|
#Connect event handlers
|
||||||
dic = { "on_ClrBtn_clicked" : self.clrmenu}
|
dic = { "on_ClrBtn_clicked" : self.clrmenu}
|
||||||
self.wTree.signal_autoconnect( dic )
|
self.wTree.signal_autoconnect( dic )
|
||||||
|
|
||||||
def wake (self) :
|
def wake (self) :
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def RegenPlugin( self, *args, **kargs ):
|
def RegenPlugin( self, *args, **kargs ):
|
||||||
self.GetGconfEntries()
|
self.GetGconfEntries()
|
||||||
|
|
||||||
def GetGconfEntries( self ):
|
def GetGconfEntries( self ):
|
||||||
self.gconf = EasyGConf( "/apps/mintMenu/plugins/recent/" )
|
self.gconf = EasyGConf( "/apps/mintMenu/plugins/recent/" )
|
||||||
self.recenth = self.gconf.get( 'int', 'height', 385 )
|
self.recenth = self.gconf.get( 'int', 'height', 385 )
|
||||||
self.recentw = self.gconf.get( 'int', 'width', 250 )
|
self.recentw = self.gconf.get( 'int', 'width', 250 )
|
||||||
self.numentries = self.gconf.get( 'int', 'num_recent_docs_to_show', 10 )
|
self.numentries = self.gconf.get( 'int', 'num_recent_docs_to_show', 10 )
|
||||||
self.recentfontsize = self.gconf.get( 'int', 'recent_font_size', 9 )
|
self.recentfontsize = self.gconf.get( 'int', 'recent_font_size', 9 )
|
||||||
|
|
||||||
# Hide vertical dotted separator
|
# Hide vertical dotted separator
|
||||||
self.hideseparator = self.gconf.get( "bool", "hide_separator", False )
|
self.hideseparator = self.gconf.get( "bool", "hide_separator", False )
|
||||||
# Plugin icon
|
# Plugin icon
|
||||||
self.icon = self.gconf.get( "string", 'icon', "gnome-fs-directory" )
|
self.icon = self.gconf.get( "string", 'icon', "gnome-fs-directory" )
|
||||||
# Allow plugin to be minimized to the left plugin pane
|
# Allow plugin to be minimized to the left plugin pane
|
||||||
self.sticky = self.gconf.get( "bool", "sticky", False )
|
self.sticky = self.gconf.get( "bool", "sticky", False )
|
||||||
self.minimized = self.gconf.get( "bool", "minimized", False )
|
self.minimized = self.gconf.get( "bool", "minimized", False )
|
||||||
self.RebuildPlugin()
|
self.RebuildPlugin()
|
||||||
|
|
||||||
def SetHidden( self, state ):
|
def SetHidden( self, state ):
|
||||||
if state == True:
|
if state == True:
|
||||||
self.gconf.set( "bool", "minimized", True )
|
self.gconf.set( "bool", "minimized", True )
|
||||||
else:
|
else:
|
||||||
self.gconf.set( "bool", "minimized", False )
|
self.gconf.set( "bool", "minimized", False )
|
||||||
|
|
||||||
|
|
||||||
def RebuildPlugin(self):
|
def RebuildPlugin(self):
|
||||||
self.content_holder.set_size_request(self.recentw, self.recenth )
|
self.content_holder.set_size_request(self.recentw, self.recenth )
|
||||||
self.DoRecent()
|
self.DoRecent()
|
||||||
|
|
||||||
|
|
||||||
def DoRecent( self, *args, **kargs ):
|
def DoRecent( self, *args, **kargs ):
|
||||||
for i in self.wTree.get_widget( "RecentBox" ).get_children():
|
for i in self.wTree.get_widget( "RecentBox" ).get_children():
|
||||||
i.destroy()
|
i.destroy()
|
||||||
|
|
||||||
self.wTree.get_widget( "vbox1" ).set_size_request( self.recentw, self.recenth )
|
self.wTree.get_widget( "vbox1" ).set_size_request( self.recentw, self.recenth )
|
||||||
if len( self.wTree.get_widget( "RecentBox" ).get_children() ) < self.numentries:
|
if len( self.wTree.get_widget( "RecentBox" ).get_children() ) < self.numentries:
|
||||||
n=len( self.wTree.get_widget( "RecentBox" ).get_children() )-1
|
n=len( self.wTree.get_widget( "RecentBox" ).get_children() )-1
|
||||||
else:
|
else:
|
||||||
n=self.numentries-1
|
n=self.numentries-1
|
||||||
while n >= 0:
|
while n >= 0:
|
||||||
self.wTree.get_widget( "RecentBox" ).remove( self.wTree.get_widget( "RecentBox" ).get_children()[n] )
|
self.wTree.get_widget( "RecentBox" ).remove( self.wTree.get_widget( "RecentBox" ).get_children()[n] )
|
||||||
n-=1
|
n-=1
|
||||||
|
|
||||||
self.FileList, self.IconList = self.GetRecent()
|
self.FileList, self.IconList = self.GetRecent()
|
||||||
loc = 0
|
loc = 0
|
||||||
for Name in self.FileList:
|
for Name in self.FileList:
|
||||||
if Name != None:
|
if Name != None:
|
||||||
self.AddRecentBtn( Name, self.IconList[loc] )
|
self.AddRecentBtn( Name, self.IconList[loc] )
|
||||||
loc = loc + 1
|
loc = loc + 1
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def clrmenu(self, *args, **kargs):
|
def clrmenu(self, *args, **kargs):
|
||||||
self.RecManagerInstance.purge_items()
|
self.RecManagerInstance.purge_items()
|
||||||
self.DoRecent()
|
self.DoRecent()
|
||||||
return
|
return
|
||||||
|
|
||||||
def AddRecentBtn( self, Name, RecentImage ):
|
def AddRecentBtn( self, Name, RecentImage ):
|
||||||
DispName=os.path.basename( Name )
|
DispName=os.path.basename( Name )
|
||||||
|
|
||||||
AButton = gtk.Button( "", "ok", True )
|
AButton = gtk.Button( "", "ok", True )
|
||||||
AButton.remove( AButton.get_children()[0] )
|
AButton.remove( AButton.get_children()[0] )
|
||||||
AButton.set_size_request( 200, -1 )
|
AButton.set_size_request( 200, -1 )
|
||||||
AButton.set_relief( gtk.RELIEF_NONE )
|
AButton.set_relief( gtk.RELIEF_NONE )
|
||||||
AButton.connect( "clicked", self.callback, Name )
|
AButton.connect( "clicked", self.callback, Name )
|
||||||
|
|
||||||
Align1 = gtk.Alignment( 0, 0.5, 0, 0 )
|
Align1 = gtk.Alignment( 0, 0.5, 0, 0 )
|
||||||
Align1.set_padding( 0, 0, 0, 0 )
|
Align1.set_padding( 0, 0, 0, 0 )
|
||||||
HBox1 = gtk.HBox( False, 5 )
|
HBox1 = gtk.HBox( False, 5 )
|
||||||
VBox1 = gtk.VBox( False, 2 )
|
VBox1 = gtk.VBox( False, 2 )
|
||||||
|
|
||||||
VBox1.show()
|
VBox1.show()
|
||||||
|
|
||||||
|
|
||||||
Label1 = gtk.Label( DispName )
|
Label1 = gtk.Label( DispName )
|
||||||
Label1.set_size_request( AButton.size_request()[0]-20, -1 )
|
Label1.set_size_request( AButton.size_request()[0]-20, -1 )
|
||||||
Label1.set_ellipsize( pango.ELLIPSIZE_END )
|
Label1.set_ellipsize( pango.ELLIPSIZE_END )
|
||||||
Label1.show()
|
Label1.show()
|
||||||
VBox1.add( Label1 )
|
VBox1.add( Label1 )
|
||||||
|
|
||||||
ButtonIcon = gtk.Image()
|
ButtonIcon = gtk.Image()
|
||||||
ButtonIcon.set_from_pixbuf(RecentImage)
|
ButtonIcon.set_from_pixbuf(RecentImage)
|
||||||
HBox1.add( ButtonIcon )
|
HBox1.add( ButtonIcon )
|
||||||
|
|
||||||
ButtonIcon.show()
|
ButtonIcon.show()
|
||||||
HBox1.add( VBox1 )
|
HBox1.add( VBox1 )
|
||||||
HBox1.show()
|
HBox1.show()
|
||||||
Align1.add( HBox1 )
|
Align1.add( HBox1 )
|
||||||
Align1.show()
|
Align1.show()
|
||||||
AButton.add( Align1 )
|
AButton.add( Align1 )
|
||||||
AButton.show()
|
AButton.show()
|
||||||
|
|
||||||
self.wTree.get_widget( "RecentBox" ).pack_start( AButton, False, True, 0 )
|
self.wTree.get_widget( "RecentBox" ).pack_start( AButton, False, True, 0 )
|
||||||
|
|
||||||
def callback(self, widget, filename=None):
|
def callback(self, widget, filename=None):
|
||||||
self.Win.hide()
|
self.Win.hide()
|
||||||
|
|
||||||
x = os.system("gnome-open \""+filename+"\"")
|
x = os.system("gnome-open \""+filename+"\"")
|
||||||
if x == 256:
|
if x == 256:
|
||||||
dia = gtk.Dialog('File not found!',
|
dia = gtk.Dialog('File not found!',
|
||||||
None, #the toplevel wgt of your app
|
None, #the toplevel wgt of your app
|
||||||
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, #binary flags or'ed together
|
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, #binary flags or'ed together
|
||||||
("Ok", 77))
|
("Ok", 77))
|
||||||
dia.vbox.pack_start(gtk.Label('The location or file could not be found!'))
|
dia.vbox.pack_start(gtk.Label('The location or file could not be found!'))
|
||||||
dia.vbox.show_all()
|
dia.vbox.show_all()
|
||||||
dia.show()
|
dia.show()
|
||||||
result = dia.run()
|
result = dia.run()
|
||||||
if result == 77:
|
if result == 77:
|
||||||
dia.destroy()
|
dia.destroy()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def GetRecent(self, *args, **kargs):
|
def GetRecent(self, *args, **kargs):
|
||||||
FileString=[]
|
FileString=[]
|
||||||
IconString=[]
|
IconString=[]
|
||||||
RecentInfo=self.RecManagerInstance.get_items()
|
RecentInfo=self.RecManagerInstance.get_items()
|
||||||
# print RecentInfo[0].get_icon(gtk.ICON_SIZE_MENU)
|
# print RecentInfo[0].get_icon(gtk.ICON_SIZE_MENU)
|
||||||
count=0
|
count=0
|
||||||
MaxEntries=self.numentries
|
MaxEntries=self.numentries
|
||||||
if self.numentries == -1:
|
if self.numentries == -1:
|
||||||
MaxEntries=len(RecentInfo)
|
MaxEntries=len(RecentInfo)
|
||||||
for items in RecentInfo:
|
for items in RecentInfo:
|
||||||
FileString.append(items.get_uri_display())
|
FileString.append(items.get_uri_display())
|
||||||
IconString.append(items.get_icon(gtk.ICON_SIZE_MENU))
|
IconString.append(items.get_icon(gtk.ICON_SIZE_MENU))
|
||||||
count+=1
|
count+=1
|
||||||
if count >= MaxEntries:
|
if count >= MaxEntries:
|
||||||
break
|
break
|
||||||
return FileString, IconString
|
return FileString, IconString
|
||||||
|
|
||||||
|
|
||||||
def ButtonClicked( self, widget, event, Exec ):
|
def ButtonClicked( self, widget, event, Exec ):
|
||||||
self.press_x = event.x
|
self.press_x = event.x
|
||||||
self.press_y = event.y
|
self.press_y = event.y
|
||||||
self.Exec = Exec
|
self.Exec = Exec
|
||||||
|
|
||||||
def ButtonReleased( self, w, ev, ev2 ):
|
|
||||||
if ev.button == 1:
|
|
||||||
if not hasattr( self, "press_x" ) or \
|
|
||||||
not w.drag_check_threshold( int( self.press_x ),
|
|
||||||
int( self.press_y ),
|
|
||||||
int( ev.x ),
|
|
||||||
int( ev.y ) ):
|
|
||||||
if self.Win.pinmenu == False:
|
|
||||||
self.Win.wTree.get_widget( "window1" ).hide()
|
|
||||||
if "applications" in self.Win.plugins:
|
|
||||||
self.Win.plugins["applications"].wTree.get_widget( "entry1" ).grab_focus()
|
|
||||||
Execute( w, self.Exec )
|
|
||||||
|
|
||||||
def do_plugin(self):
|
|
||||||
self.DoRecent()
|
|
||||||
|
|
||||||
|
def ButtonReleased( self, w, ev, ev2 ):
|
||||||
|
if ev.button == 1:
|
||||||
|
if not hasattr( self, "press_x" ) or \
|
||||||
|
not w.drag_check_threshold( int( self.press_x ),
|
||||||
|
int( self.press_y ),
|
||||||
|
int( ev.x ),
|
||||||
|
int( ev.y ) ):
|
||||||
|
if self.Win.pinmenu == False:
|
||||||
|
self.Win.wTree.get_widget( "window1" ).hide()
|
||||||
|
if "applications" in self.Win.plugins:
|
||||||
|
self.Win.plugins["applications"].wTree.get_widget( "entry1" ).grab_focus()
|
||||||
|
Execute( w, self.Exec )
|
||||||
|
|
||||||
|
def do_plugin(self):
|
||||||
|
self.DoRecent()
|
||||||
|
Loading…
Reference in New Issue
Block a user