Started migrating places plugin..

This commit is contained in:
Clement Lefebvre 2013-03-04 16:50:14 +00:00
parent 3dbd270225
commit c940e3a735
5 changed files with 267 additions and 153 deletions

View File

@ -3,7 +3,7 @@
import gi import gi
gi.require_version("Gtk", "2.0") gi.require_version("Gtk", "2.0")
from gi.repository import Gtk, Gdk from gi.repository import Gtk, GdkPixbuf, Gdk
from gi.repository import MatePanelApplet from gi.repository import MatePanelApplet
from gi.repository import Gio from gi.repository import Gio
@ -21,14 +21,14 @@ except Exception, e:
print e print e
sys.exit( 1 ) sys.exit( 1 )
#global mbindkey global mbindkey
# Load the key binding lib (developped by deskbar-applet, copied into mintMenu so we don't end up with an unnecessary dependency) # Load the key binding lib (developped by deskbar-applet, copied into mintMenu so we don't end up with an unnecessary dependency)
#try: try:
# from deskbar.core.keybinder import tomboy_keybinder_bind as bind_key from deskbar.core.keybinder import tomboy_keybinder_bind as bind_key
#except Exception, cause: except Exception, cause:
# print "*********** Keybind Driver Load Failure **************" print "*********** Keybind Driver Load Failure **************"
# print "Error Report : ", str(cause) print "Error Report : ", str(cause)
# pass pass
# Rename the process # Rename the process
architecture = commands.getoutput("uname -a") architecture = commands.getoutput("uname -a")
@ -58,8 +58,8 @@ if not windowManager:
windowManager = "MATE" windowManager = "MATE"
xdg.Config.setWindowManager( windowManager.upper() ) xdg.Config.setWindowManager( windowManager.upper() )
#from easybuttons import iconManager from easybuttons import iconManager
#from execute import * #from execute import * COMMENTED DURING MIGRATION
class MainWindow( object ): class MainWindow( object ):
"""This is the main class for the application""" """This is the main class for the application"""
@ -76,12 +76,14 @@ class MainWindow( object ):
self.icon = "/usr/lib/linuxmint/mintMenu/visualisation-logo.png" self.icon = "/usr/lib/linuxmint/mintMenu/visualisation-logo.png"
self.toggle = toggleButton self.toggle = toggleButton
# Load glade file and extract widgets # Load UI file and extract widgets
gladefile = os.path.join( self.path, "mintMenu.glade" ) builder = Gtk.Builder()
wTree = Gtk.glade.XML( gladefile, "mainWindow" ) builder.add_from_file(os.path.join( self.path, "mintMenu.ui" ))
self.window = wTree.get_widget( "mainWindow" ) self.window = builder.get_object( "mainWindow" )
self.paneholder = wTree.get_widget( "paneholder" ) self.paneholder = builder.get_object( "paneholder" )
self.border = wTree.get_widget( "border" ) self.border = builder.get_object( "border" )
builder.connect_signals(self)
self.panesToColor = [ ] self.panesToColor = [ ]
self.headingsToColor = [ ] self.headingsToColor = [ ]
@ -98,9 +100,6 @@ class MainWindow( object ):
plugindir = os.path.join( os.path.expanduser( "~" ), ".linuxmint/mintMenu/plugins" ) plugindir = os.path.join( os.path.expanduser( "~" ), ".linuxmint/mintMenu/plugins" )
sys.path.append( plugindir ) sys.path.append( plugindir )
dic = {"on_window1_destroy" : self.quit_cb}
wTree.signal_autoconnect( dic )
self.getSetGconfEntries() self.getSetGconfEntries()
self.SetupMintMenuBorder() self.SetupMintMenuBorder()
self.SetupMintMenuOpacity() self.SetupMintMenuOpacity()
@ -126,7 +125,7 @@ class MainWindow( object ):
self.settings.connect( "changed::border_width", self.toggleBorderWidth ) self.settings.connect( "changed::border_width", self.toggleBorderWidth )
self.settings.connect( "changed::opacity", self.toggleOpacity ) self.settings.connect( "changed::opacity", self.toggleOpacity )
def quit_cb (self): def on_window1_destroy (self, widget, data=None):
Gtk.main_quit() Gtk.main_quit()
sys.exit(0) sys.exit(0)
@ -196,10 +195,11 @@ class MainWindow( object ):
self.globalEnableTooltips = mate_settings.get_boolean( "tooltips-enabled" ) self.globalEnableTooltips = mate_settings.get_boolean( "tooltips-enabled" )
def SetupMintMenuBorder( self ): def SetupMintMenuBorder( self ):
if self.usecustomcolor: # COMMENTED DURING MIGRATION
self.window.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.custombordercolor ) ) #if self.usecustomcolor:
else: # self.window.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.custombordercolor ) )
self.window.modify_bg( Gtk.StateType.NORMAL, self.window.rc_get_style().bg[ Gtk.StateType.SELECTED ] ) #else:
# self.window.modify_bg( Gtk.StateType.NORMAL, self.window.rc_get_style().bg[ Gtk.StateType.SELECTED ] )
self.border.set_padding( self.borderwidth, self.borderwidth, self.borderwidth, self.borderwidth ) self.border.set_padding( self.borderwidth, self.borderwidth, self.borderwidth, self.borderwidth )
def SetupMintMenuOpacity( self ): def SetupMintMenuOpacity( self ):
@ -240,8 +240,6 @@ class MainWindow( object ):
self.plugins = {} self.plugins = {}
for plugin in self.pluginlist: for plugin in self.pluginlist:
#Bypass
break
if plugin in self.plugins: if plugin in self.plugins:
print u"Duplicate plugin in list: ", plugin print u"Duplicate plugin in list: ", plugin
continue continue
@ -384,13 +382,13 @@ class MainWindow( object ):
for item in items: for item in items:
if item not in self.panesToColor: if item not in self.panesToColor:
self.panesToColor.append( item ) self.panesToColor.append( item )
#COMMENTED DURING MIGRATION
if self.usecustomcolor: #if self.usecustomcolor:
for item in items: # for item in items:
item.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.customcolor ) ) # item.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.customcolor ) )
else: #else:
for item in items: # for item in items:
item.modify_bg( Gtk.StateType.NORMAL, self.paneholder.rc_get_style().bg[ Gtk.StateType.NORMAL ] ) # item.modify_bg( Gtk.StateType.NORMAL, self.paneholder.rc_get_style().bg[ Gtk.StateType.NORMAL ] )
def SetHeadingStyle( self, items ): def SetHeadingStyle( self, items ):
@ -466,7 +464,8 @@ class MainWindow( object ):
Gdk.keyboard_ungrab() Gdk.keyboard_ungrab()
def onMap( self, widget, event ): def onMap( self, widget, event ):
self.grab() #self.grab() COMMENTED DURING MIGRATION
pass
def onShow( self, widget ): def onShow( self, widget ):
for plugin in self.plugins.values(): for plugin in self.plugins.values():
@ -474,7 +473,7 @@ class MainWindow( object ):
plugin.onShowMenu() plugin.onShowMenu()
def onUnmap( self, widget, event ): def onUnmap( self, widget, event ):
self.ungrab() #self.ungrab() COMMENTED DURING MIGRATION
for plugin in self.plugins.values(): for plugin in self.plugins.values():
if hasattr( plugin, "onHideMenu" ): if hasattr( plugin, "onHideMenu" ):
@ -520,7 +519,7 @@ class MainWindow( object ):
class MenuWin( object ): class MenuWin( object ):
def __init__( self, applet, iid ): def __init__( self, applet, iid ):
self.applet = applet self.applet = applet
self.settings = Gio.Settings.new_with_path("com.linuxmint.mintmenu", self.applet.get_preferences_path()) self.settings = Gio.Settings.new("com.linuxmint.mintmenu")
self.settings.connect( "changed::applet_text", self.reloadSettings ) self.settings.connect( "changed::applet_text", self.reloadSettings )
self.settings.connect( "changed::theme_name", self.changeTheme ) self.settings.connect( "changed::theme_name", self.changeTheme )
@ -550,7 +549,7 @@ class MenuWin( object ):
icon = iconManager.getIcon( self.mainwin.icon, 1 ) icon = iconManager.getIcon( self.mainwin.icon, 1 )
if icon: if icon:
Gtk.window_set_default_icon( icon ) Gtk.Window.set_default_icon( icon )
self.propxml = """ self.propxml = """
<popup name="button3"> <popup name="button3">
@ -722,6 +721,7 @@ class MenuWin( object ):
self.button_icon.hide() self.button_icon.hide()
else: else:
self.button_icon.show() self.button_icon.show()
# COMMENTED DURING MIGRATION
# This code calculates width and height for the button_box # This code calculates width and height for the button_box
# and takes the orientation in account # and takes the orientation in account
#if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN: #if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN:
@ -801,7 +801,7 @@ class MenuWin( object ):
ourHeight = self.mainwin.window.get_size()[1] + self.mainwin.offset ourHeight = self.mainwin.window.get_size()[1] + self.mainwin.offset
# Get the dimensions/position of the widgetToAlignWith # Get the dimensions/position of the widgetToAlignWith
entryX, entryY = self.applet.window.get_origin() entryX, entryY = self.applet.get_allocation().x, self.applet.get_allocation().y
entryWidth, entryHeight = self.applet.get_allocation().width, self.applet.get_allocation().height entryWidth, entryHeight = self.applet.get_allocation().width, self.applet.get_allocation().height
entryHeight = entryHeight + self.mainwin.offset entryHeight = entryHeight + self.mainwin.offset

View File

@ -0,0 +1,29 @@
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 2.10 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkWindow" id="mainWindow">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK</property>
<property name="type">popup</property>
<property name="resizable">False</property>
<property name="type_hint">menu</property>
<property name="skip_taskbar_hint">True</property>
<property name="skip_pager_hint">True</property>
<property name="decorated">False</property>
<property name="deletable">False</property>
<signal handler="gtk_widget_hide" name="key_press_event"/>
<child>
<object class="GtkAlignment" id="border">
<property name="visible">True</property>
<child>
<object class="GtkHBox" id="paneholder">
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View File

@ -1,40 +1,40 @@
#!/usr/bin/env python #!/usr/bin/env python
import gtk from gi.repository import Gtk, GdkPixbuf, Gdk
import pango from gi.repository import Pango
import matedesktop #import matedesktop
import gobject from gi.repository import GObject
import os.path import os.path
import shutil import shutil
import re import re
from execute import * #from execute import *
import xdg.DesktopEntry import xdg.DesktopEntry
import xdg.Menu import xdg.Menu
from filemonitor import monitor as filemonitor from filemonitor import monitor as filemonitor
import glib import glib
class IconManager(gobject.GObject): class IconManager(GObject.GObject):
__gsignals__ = { __gsignals__ = {
"changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, () ) "changed" : (GObject.SignalFlags.RUN_LAST, None, () )
} }
def __init__( self ): def __init__( self ):
gobject.GObject.__init__( self ) GObject.GObject.__init__( self )
self.icons = { } self.icons = { }
self.count = 0 self.count = 0
# Some apps don't put a default icon in the default theme folder, so we will search all themes # Some apps don't put a default icon in the default theme folder, so we will search all themes
def createTheme( d ): def createTheme( d ):
theme = gtk.IconTheme() theme = Gtk.IconTheme()
theme.set_custom_theme( d ) theme.set_custom_theme( d )
return theme return theme
# This takes to much time and there are only a very few applications that use icons from different themes # This takes to much time and there are only a very few applications that use icons from different themes
#self.themes = map( createTheme, [ d for d in os.listdir( "/usr/share/icons" ) if os.path.isdir( os.path.join( "/usr/share/icons", d ) ) ] ) #self.themes = map( createTheme, [ d for d in os.listdir( "/usr/share/icons" ) if os.path.isdir( os.path.join( "/usr/share/icons", d ) ) ] )
defaultTheme = gtk.icon_theme_get_default() defaultTheme = Gtk.IconTheme()
defaultKdeTheme = createTheme( "kde.default" ) defaultKdeTheme = createTheme( "kde.default" )
# Themes with the same content as the default them aren't needed # Themes with the same content as the default them aren't needed
@ -80,7 +80,7 @@ class IconManager(gobject.GObject):
iconFileName = "" iconFileName = ""
if iconFileName and os.path.exists( iconFileName ): if iconFileName and os.path.exists( iconFileName ):
icon = gtk.gdk.pixbuf_new_from_file_at_size( iconFileName, iconSize, iconSize ) icon = GdkPixbuf.Pixbuf.new_from_file_at_size( iconFileName, iconSize, iconSize )
else: else:
icon = None icon = None
@ -88,9 +88,9 @@ class IconManager(gobject.GObject):
# if the actual icon size is to far from the desired size resize it # if the actual icon size is to far from the desired size resize it
if icon and (( icon.get_width() - iconSize ) > 5 or ( icon.get_height() - iconSize ) > 5): if icon and (( icon.get_width() - iconSize ) > 5 or ( icon.get_height() - iconSize ) > 5):
if icon.get_width() > icon.get_height(): if icon.get_width() > icon.get_height():
newIcon = icon.scale_simple( iconSize, icon.get_height() * iconSize / icon.get_width(), gtk.gdk.INTERP_BILINEAR ) newIcon = icon.scale_simple( iconSize, icon.get_height() * iconSize / icon.get_width(), GdkPixbuf.InterpType.BILINEAR )
else: else:
newIcon = icon.scale_simple( icon.get_width() * iconSize / icon.get_height(), iconSize, gtk.gdk.INTERP_BILINEAR ) newIcon = icon.scale_simple( icon.get_width() * iconSize / icon.get_height(), iconSize, GdkPixbuf.InterpType.BILINEAR )
del icon del icon
icon = newIcon icon = newIcon
@ -108,26 +108,26 @@ class IconManager(gobject.GObject):
self.cache = { } self.cache = { }
self.emit( "changed" ) self.emit( "changed" )
gobject.type_register(IconManager) GObject.type_register(IconManager)
class easyButton( gtk.Button ): class easyButton( Gtk.Button ):
def __init__( self, iconName, iconSize, labels = None, buttonWidth = -1, buttonHeight = -1 ): def __init__( self, iconName, iconSize, labels = None, buttonWidth = -1, buttonHeight = -1 ):
gtk.Button.__init__( self ) GObject.GObject.__init__( self )
self.connections = [ ] self.connections = [ ]
self.iconName = iconName self.iconName = iconName
self.iconSize = iconSize self.iconSize = iconSize
self.showIcon = True self.showIcon = True
self.set_relief( gtk.RELIEF_NONE ) self.set_relief( Gtk.ReliefStyle.NONE )
self.set_size_request( buttonWidth, buttonHeight ) self.set_size_request( buttonWidth, buttonHeight )
Align1 = gtk.Alignment( 0, 0.5, 1.0, 0 ) Align1 = Gtk.Alignment.new( 0, 0.5, 1.0, 0 )
HBox1 = gtk.HBox() HBox1 = Gtk.HBox()
self.labelBox = gtk.VBox( False, 2 ) self.labelBox = Gtk.VBox( False, 2 )
self.buttonImage = gtk.Image() self.buttonImage = Gtk.Image()
icon = self.getIcon( self.iconSize ) icon = self.getIcon( self.iconSize )
if icon: if icon:
self.buttonImage.set_from_pixbuf( icon ) self.buttonImage.set_from_pixbuf( icon )
@ -146,7 +146,7 @@ class easyButton( gtk.Button ):
self.addLabel( label[0], label[1] ) self.addLabel( label[0], label[1] )
self.labelBox.show() self.labelBox.show()
HBox1.pack_start( self.labelBox ) HBox1.pack_start( self.labelBox , True, True, 0)
HBox1.show() HBox1.show()
Align1.add( HBox1 ) Align1.add( HBox1 )
Align1.show() Align1.show()
@ -161,7 +161,7 @@ class easyButton( gtk.Button ):
self.connections.append( self.connect( event, callback ) ) self.connections.append( self.connect( event, callback ) )
def onRelease( self, widget ): def onRelease( self, widget ):
widget.set_state(gtk.STATE_NORMAL) widget.set_state(Gtk.StateType.NORMAL)
def onDestroy( self, widget ): def onDestroy( self, widget ):
self.buttonImage.clear() self.buttonImage.clear()
@ -172,22 +172,22 @@ class easyButton( gtk.Button ):
def addLabel( self, text, styles = None ): def addLabel( self, text, styles = None ):
label = gtk.Label() label = Gtk.Label()
if "<b>" in text: if "<b>" in text:
label.set_markup(text) # don't remove our pango label.set_markup(text) # don't remove our pango
else: else:
label.set_markup(glib.markup_escape_text(text)) label.set_markup(glib.markup_escape_text(text))
if styles: if styles:
labelStyle = pango.AttrList() labelStyle = Pango.AttrList()
for attr in styles: for attr in styles:
labelStyle.insert( attr ) labelStyle.insert( attr )
label.set_attributes( labelStyle ) label.set_attributes( labelStyle )
label.set_ellipsize( pango.ELLIPSIZE_END ) label.set_ellipsize( Pango.EllipsizeMode.END )
label.set_alignment( 0.0, 1.0 ) label.set_alignment( 0.0, 1.0 )
label.show() label.show()
self.labelBox.pack_start( label ) self.labelBox.pack_start( label , True, True, 0)
def getIcon ( self, iconSize ): def getIcon ( self, iconSize ):
@ -263,9 +263,9 @@ class ApplicationLauncher( easyButton ):
# Drag and Drop # Drag and Drop
self.connectSelf( "drag_data_get", self.dragDataGet ) self.connectSelf( "drag_data_get", self.dragDataGet )
self.drag_source_set( gtk.gdk.BUTTON1_MASK , [ ( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ) ], gtk.gdk.ACTION_COPY ) self.drag_source_set( Gdk.ModifierType.BUTTON1_MASK , [ ( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ) ], Gdk.DragAction.COPY )
icon = self.getIcon( gtk.ICON_SIZE_DND ) icon = self.getIcon( Gtk.IconSize.DND )
if icon: if icon:
self.drag_source_set_icon_pixbuf( icon ) self.drag_source_set_icon_pixbuf( icon )
del icon del icon
@ -315,10 +315,10 @@ class ApplicationLauncher( easyButton ):
def onFocusIn( self, widget, event ): def onFocusIn( self, widget, event ):
self.set_relief( gtk.RELIEF_HALF ) self.set_relief( Gtk.ReliefStyle.HALF )
def onFocusOut( self, widget, event ): def onFocusOut( self, widget, event ):
self.set_relief( gtk.RELIEF_NONE ) self.set_relief( Gtk.ReliefStyle.NONE )
def onEnterNotify( self, widget, event ): def onEnterNotify( self, widget, event ):
self.grab_focus() self.grab_focus()
@ -379,7 +379,7 @@ class ApplicationLauncher( easyButton ):
def iconChanged( self ): def iconChanged( self ):
easyButton.iconChanged( self ) easyButton.iconChanged( self )
icon = self.getIcon( gtk.ICON_SIZE_DND ) icon = self.getIcon( Gtk.IconSize.DND )
if icon: if icon:
self.drag_source_set_icon_pixbuf( icon ) self.drag_source_set_icon_pixbuf( icon )
del icon del icon
@ -471,7 +471,7 @@ class MenuApplicationLauncher( ApplicationLauncher ):
appComment = self.appComment appComment = self.appComment
if self.highlight: if self.highlight:
try: try:
#color = self.labelBox.rc_get_style().fg[ gtk.STATE_SELECTED ].to_string() #color = self.labelBox.rc_get_style().fg[ Gtk.StateType.SELECTED ].to_string()
#if len(color) > 0 and color[0] == "#": #if len(color) > 0 and color[0] == "#":
#appName = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appName); #appName = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appName);
#appComment = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appComment); #appComment = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appComment);
@ -488,11 +488,11 @@ class MenuApplicationLauncher( ApplicationLauncher ):
if self.showComment and self.appComment != "": if self.showComment and self.appComment != "":
if self.iconSize <= 2: if self.iconSize <= 2:
self.addLabel( appName, [ pango.AttrScale( pango.SCALE_SMALL, 0, -1 ) ] ) self.addLabel( appName, [ Pango.AttrScale( Pango.SCALE_SMALL, 0, -1 ) ] )
self.addLabel( appComment, [ pango.AttrScale( pango.SCALE_X_SMALL, 0, -1 ) ] ) self.addLabel( appComment, [ Pango.AttrScale( Pango.SCALE_X_SMALL, 0, -1 ) ] )
else: else:
self.addLabel( appName ) self.addLabel( appName )
self.addLabel( appComment, [ pango.AttrScale( pango.SCALE_SMALL, 0, -1 ) ] ) self.addLabel( appComment, [ Pango.AttrScale( Pango.SCALE_SMALL, 0, -1 ) ] )
else: else:
self.addLabel( appName ) self.addLabel( appName )
@ -520,13 +520,13 @@ class FavApplicationLauncher( ApplicationLauncher ):
def setupLabels( self ): def setupLabels( self ):
if self.appGenericName: if self.appGenericName:
if self.swapGeneric: if self.swapGeneric:
self.addLabel( self.appName, [ pango.AttrWeight( pango.WEIGHT_BOLD, 0, -1 ) ] ) self.addLabel( self.appName, [ Pango.AttrWeight( Pango.Weight.BOLD, 0, -1 ) ] )
self.addLabel( self.appGenericName ) self.addLabel( self.appGenericName )
else: else:
self.addLabel( self.appGenericName, [ pango.AttrWeight( pango.WEIGHT_BOLD, 0, -1 ) ] ) self.addLabel( self.appGenericName, [ Pango.AttrWeight( Pango.Weight.BOLD, 0, -1 ) ] )
self.addLabel( self.appName ) self.addLabel( self.appName )
else: else:
self.addLabel( self.appName, [ pango.AttrWeight( pango.WEIGHT_BOLD, 0, -1 ) ] ) self.addLabel( self.appName, [ Pango.AttrWeight( Pango.Weight.BOLD, 0, -1 ) ] )
if self.appComment != "": if self.appComment != "":
self.addLabel( self.appComment ) self.addLabel( self.appComment )
else: else:

View File

@ -1,7 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
import gtk from gi.repository import Gtk
import gtk.glade
import os import os
import string import string
import gettext import gettext
@ -10,7 +9,6 @@ import time
from easybuttons import * from easybuttons import *
from execute import Execute from execute import Execute
from easygconf import EasyGConf
from user import home from user import home
from urllib import unquote from urllib import unquote
@ -25,44 +23,44 @@ class pluginclass( object ):
self.toggleButton = toggleButton self.toggleButton = toggleButton
self.de = de self.de = de
# Read GLADE file # Read UI file
gladefile = os.path.join( os.path.dirname( __file__ ), "places.glade" ) builder = Gtk.Builder()
wTree = gtk.glade.XML( gladefile, "mainWindow" ) builder.add_from_file(os.path.join( os.path.dirname( __file__ ), "places.ui" ))
self.placesBtnHolder = wTree.get_widget( "places_button_holder" )
self.editableBtnHolder = wTree.get_widget( "editable_button_holder" ) self.placesBtnHolder = builder.get_object( "places_button_holder" )
self.scrolledWindow=wTree.get_widget("scrolledwindow2") self.editableBtnHolder = builder.get_object( "editable_button_holder" )
self.scrolledWindow=builder.get_object("scrolledwindow2")
# These properties are NECESSARY to maintain consistency # These properties are NECESSARY to maintain consistency
# Set 'window' property for the plugin (Must be the root widget) # Set 'window' property for the plugin (Must be the root widget)
self.window = wTree.get_widget( "mainWindow" ) self.window = builder.get_object( "mainWindow" )
# Set 'heading' property for plugin # Set 'heading' property for plugin
self.heading = _("Places") self.heading = _("Places")
# 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 = wTree.get_widget( "Places" ) self.content_holder = builder.get_object( "Places" )
# Items to get custom colors # Items to get custom colors
self.itemstocolor = [ wTree.get_widget( "viewport2" ) ] self.itemstocolor = [ builder.get_object( "viewport2" ) ]
# Gconf stuff # Settings
self.gconf = EasyGConf( "/apps/mintMenu/plugins/places/" ) self.settings = Gio.Settings.new("com.linuxmint.mintmenu")
self.gconf.notifyAdd( "icon_size", self.RegenPlugin ) self.settings.connect( "changed::places-icon-size", self.RegenPlugin )
self.gconf.notifyAdd( "show_computer", self.RegenPlugin ) self.settings.connect( "changed::places-show-computer", self.RegenPlugin )
self.gconf.notifyAdd( "show_desktop", self.RegenPlugin ) self.settings.connect( "changed::places-show-desktop", self.RegenPlugin )
self.gconf.notifyAdd( "show_home_folder", self.RegenPlugin ) self.settings.connect( "changed::places-show-home_folder", self.RegenPlugin )
self.gconf.notifyAdd( "show_network", self.RegenPlugin ) self.settings.connect( "changed::places-show-network", self.RegenPlugin )
self.gconf.notifyAdd( "show_trash", self.RegenPlugin ) self.settings.connect( "changed::places-show-trash", self.RegenPlugin )
self.gconf.notifyAdd( "custom_names", self.RegenPlugin ) self.settings.connect( "changed::places-custom-names", self.RegenPlugin )
self.gconf.notifyAdd( "custom_paths", self.RegenPlugin ) self.settings.connect( "changed::places-custom-paths", self.RegenPlugin )
self.gconf.notifyAdd( "allowScrollbar", self.RegenPlugin ) self.settings.connect( "changed::places-allow-scrollbar", self.RegenPlugin )
self.gconf.notifyAdd( "show_gtk_bookmarks", self.RegenPlugin ) self.settings.connect( "changed::places-show-gtk-bookmarks", self.RegenPlugin )
self.gconf.notifyAdd( "height", self.changePluginSize ) self.settings.connect( "changed::places-height", self.changePluginSize )
self.gconf.notifyAdd( "width", self.changePluginSize ) self.settings.connect( "changed::places-width", self.changePluginSize )
self.gconf.bindGconfEntryToVar( "bool", "sticky", self, "sticky" )
self.GetGconfEntries() self.loadSettings()
self.content_holder.set_size_request( self.width, self.height ) self.content_holder.set_size_request( self.width, self.height )
@ -71,69 +69,60 @@ class pluginclass( object ):
self.refreshTrash() self.refreshTrash()
def destroy( self ): def destroy( self ):
self.gconf.notifyRemoveAll() self.settings.disconnect_all()
def changePluginSize( self, client, connection_id, entry, args ): def changePluginSize( self, client, connection_id, entry, args ):
self.allowScrollbar = self.gconf.get( "bool", "allowScrollbar", False) self.allowScrollbar = self.settings.get_boolean( "places-allow-scrollbar" )
if entry.get_key() == self.gconf.gconfDir+"width": self.width = self.settings.get_int( "places-width" )
self.width = entry.get_value().get_int() if (self.allowScrollbar == False):
elif entry.get_key() == self.gconf.gconfDir+"height": self.height = -1
if (self.allowScrollbar == False): self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER )
self.height = -1 else:
self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER ) self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC )
else: self.height = self.settings.get_int( "places-height" )
self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC )
self.height = entry.get_value().get_int()
self.content_holder.set_size_request( self.width, self.height ) self.content_holder.set_size_request( self.width, self.height )
def RegenPlugin( self, *args, **kargs ): def RegenPlugin( self, *args, **kargs ):
self.GetGconfEntries() self.loadSettings()
self.ClearAll() self.ClearAll()
self.do_standard_places() self.do_standard_places()
self.do_custom_places() self.do_custom_places()
self.do_gtk_bookmarks() self.do_gtk_bookmarks()
def GetGconfEntries( self ): def loadSettings( self ):
self.width = self.settings.get_int( "places-width" )
self.width = self.gconf.get( "int", "width", 200 ) self.allowScrollbar = self.settings.get_boolean( "places-allow-scrollbar" )
self.allowScrollbar = self.gconf.get( "bool", "allowScrollbar", False) self.showGTKBookmarks = self.settings.get_boolean( "places-show-gtk-bookmarks" )
self.showGTKBookmarks = self.gconf.get( "bool", "show_gtk_bookmarks", False) self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC )
self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC ) self.height = self.settings.get_int( "places-height" )
self.height = self.gconf.get( "int", "height", 180 )
self.content_holder.set_size_request( self.width, self.height ) self.content_holder.set_size_request( self.width, self.height )
if (self.allowScrollbar == False): if (self.allowScrollbar == False):
self.height = -1 self.height = -1
self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER ) self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER )
self.content_holder.set_size_request( self.width, self.height ) self.content_holder.set_size_request( self.width, self.height )
self.execapp = self.gconf.get( "string", "execute_app", "nautilus" ) self.iconsize = self.settings.get_int( "places-icon-size" )
self.iconsize = self.gconf.get( "int","icon_size", 16 )
# Check default items # Check default items
self.showcomputer = self.gconf.get( "bool", "show_computer", True ) self.showcomputer = self.settings.get_boolean( "places-show_computer" )
self.showhomefolder = self.gconf.get( "bool", "show_home_folder", True ) self.showhomefolder = self.settings.get_boolean( "places-show-home-folder" )
self.shownetwork = self.gconf.get( "bool", "show_network", True ) self.shownetwork = self.settings.get_boolean( "places-show-network" )
self.showdesktop = self.gconf.get( "bool", "show_desktop", True ) self.showdesktop = self.settings.get_boolean( "places-show-desktop" )
self.showtrash = self.gconf.get( "bool", "show_trash", True ) self.showtrash = self.settings.get_boolean( "places-show-trash" )
# Get paths for custom items # Get paths for custom items
self.custompaths = self.settings.get_strv( "places-custom-paths" )
self.custompaths = self.gconf.get( "list-string", "custom_paths", [ ] )
# Get names for custom items # Get names for custom items
self.customnames = self.settings.get_strv( "places-custom-names" )
self.customnames = self.gconf.get( "list-string", "custom_names", [ ] )
# Hide vertical dotted separator # Hide vertical dotted separator
self.hideseparator = self.gconf.get( "bool", "hide_separator", False ) self.hideseparator = self.settings.get_boolean( "places-hide-separator" )
# Plugin icon # Plugin icon
self.icon = self.gconf.get( "string", 'icon', "mate-fs-directory.png" ) self.icon = self.settings_get_string( "places-icon" )
# 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.settings.get_boolean( "places-sticky", False )
self.minimized = self.gconf.get( "bool", "minimized", False ) self.minimized = self.settings.get_boolean( "places-minimized", False )
def ClearAll(self): def ClearAll(self):
for child in self.placesBtnHolder.get_children(): for child in self.placesBtnHolder.get_children():
@ -165,8 +154,8 @@ class pluginclass( object ):
self.mintMenuWin.setTooltip( Button2, _("Open your personal folder") ) self.mintMenuWin.setTooltip( Button2, _("Open your personal folder") )
if ( self.shownetwork == True and self.de == "mate"): if ( self.shownetwork == True and self.de == "mate"):
gconftheme = EasyGConf( "/desktop/mate/interface/" ) mate_settings = Gio.Settings.new("org.mate.interface")
icon_theme = gconftheme.get("string", "icon_theme", "Mint-X") icon_theme = mate_settings.get_string( "icon-theme" )
if "Mint-X" in icon_theme: if "Mint-X" in icon_theme:
Button3 = easyButton( "notification-network-ethernet-connected", self.iconsize, [_("Network")], -1, -1) Button3 = easyButton( "notification-network-ethernet-connected", self.iconsize, [_("Network")], -1, -1)
else: else:
@ -260,8 +249,8 @@ class pluginclass( object ):
def trashPopup( self, widget, event ): def trashPopup( self, widget, event ):
if event.button == 3: if event.button == 3:
trashMenu = gtk.Menu() trashMenu = Gtk.Menu()
emptyTrashMenuItem = gtk.MenuItem(_("Empty trash")) emptyTrashMenuItem = Gtk.MenuItem(_("Empty trash"))
trashMenu.append(emptyTrashMenuItem) trashMenu.append(emptyTrashMenuItem)
trashMenu.show_all() trashMenu.show_all()
emptyTrashMenuItem.connect ( "activate", self.emptyTrash, widget ) emptyTrashMenuItem.connect ( "activate", self.emptyTrash, widget )

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<schemalist> <schemalist>
<schema id="com.linuxmint.mintmenu"> <schema id="com.linuxmint.mintmenu" path="/com/linuxmint/mintmenu/">
<key type="b" name="hide-applet-icon"> <key type="b" name="hide-applet-icon">
<default>false</default> <default>false</default>
@ -98,5 +98,101 @@
<description></description> <description></description>
</key> </key>
<key type="b" name="places-sticky">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="places-minimized">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="places-allow-scrollbar">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="places-show-gtk-bookmarks">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="places-hide-separator">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="i" name="places-height">
<default>180</default>
<summary></summary>
<description></description>
</key>
<key type="i" name="places-width">
<default>200</default>
<summary></summary>
<description></description>
</key>
<key type="i" name="places-icon-size">
<default>16</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="places-show-computer">
<default>true</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="places-show-home-folder">
<default>true</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="places-show-network">
<default>true</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="places-show-desktop">
<default>true</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="places-show-trash">
<default>true</default>
<summary></summary>
<description></description>
</key>
<key type="as" name="places-custom-paths">
<default>[]</default>
<summary></summary>
<description></description>
</key>
<key type="as" name="places-custom-names">
<default>[]</default>
<summary></summary>
<description></description>
</key>
<key type="s" name="places-icon">
<default>"mate-fs-directory.png"</default>
<summary></summary>
<description></description>
</key>
</schema> </schema>
</schemalist> </schemalist>