Transition (continued...)

This commit is contained in:
Clement Lefebvre 2013-03-04 15:01:20 +00:00
parent fd35fc832f
commit 3dbd270225
4 changed files with 222 additions and 80 deletions

41
debian/postinst vendored Normal file
View File

@ -0,0 +1,41 @@
#!/bin/sh
# postinst script
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
case "$1" in
configure)
glib-compile-schemas /usr/share/glib-2.0/schemas
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

1
test
View File

@ -2,5 +2,6 @@
sudo rm -rf /usr/lib/linuxmint/mintMenu
sudo cp -R usr /
sudo glib-compile-schemas /usr/share/glib-2.0/schemas
mintmenu

View File

@ -5,6 +5,7 @@ gi.require_version("Gtk", "2.0")
from gi.repository import Gtk, Gdk
from gi.repository import MatePanelApplet
from gi.repository import Gio
try:
import sys
@ -50,8 +51,6 @@ gettext.install("mintmenu", "/usr/share/linuxmint/locale")
NAME = _("Menu")
PATH = os.path.abspath( os.path.dirname( sys.argv[0] ) )
ICON = "/usr/lib/linuxmint/mintMenu/visualisation-logo.png"
sys.path.append( os.path.join( PATH , "plugins") )
windowManager = os.getenv("DESKTOP_SESSION")
@ -60,22 +59,21 @@ if not windowManager:
xdg.Config.setWindowManager( windowManager.upper() )
#from easybuttons import iconManager
#from easygconf import EasyGConf
#from execute import *
class MainWindow( object ):
"""This is the main class for the application"""
def __init__( self, toggleButton ):
def __init__( self, toggleButton, settings ):
self.settings = settings
self.path = PATH
sys.path.append( os.path.join( self.path, "plugins") )
self.detect_desktop_environment()
self.icon = ICON
self.icon = "/usr/lib/linuxmint/mintMenu/visualisation-logo.png"
self.toggle = toggleButton
# Load glade file and extract widgets
@ -103,8 +101,6 @@ class MainWindow( object ):
dic = {"on_window1_destroy" : self.quit_cb}
wTree.signal_autoconnect( dic )
self.gconf = EasyGConf( "/apps/mintMenu/" )
self.getSetGconfEntries()
self.SetupMintMenuBorder()
self.SetupMintMenuOpacity()
@ -117,18 +113,18 @@ class MainWindow( object ):
self.PopulatePlugins();
self.gconf.notifyAdd( "plugins_list", self.RegenPlugins )
self.settings.connect( "changed::plugins_list", self.RegenPlugins )
self.gconf.notifyAdd( "start_with_favorites", self.toggleStartWithFavorites )
self.gconf.notifyAdd( "/apps/panel/global/tooltips_enabled", self.toggleTooltipsEnabled )
self.gconf.notifyAdd( "tooltips_enabled", self.toggleTooltipsEnabled )
self.settings.connect( "changed::start_with_favorites", self.toggleStartWithFavorites )
self.settings.connect( "changed::/apps/panel/global/tooltips_enabled", self.toggleTooltipsEnabled )
self.settings.connect( "changed::tooltips_enabled", self.toggleTooltipsEnabled )
self.gconf.notifyAdd( "use_custom_color", self.toggleUseCustomColor )
self.gconf.notifyAdd( "custom_border_color", self.toggleCustomBorderColor )
self.gconf.notifyAdd( "custom_heading_color", self.toggleCustomHeadingColor )
self.gconf.notifyAdd( "custom_color", self.toggleCustomBackgroundColor )
self.gconf.notifyAdd( "border_width", self.toggleBorderWidth )
self.gconf.notifyAdd( "opacity", self.toggleOpacity )
self.settings.connect( "changed::use_custom_color", self.toggleUseCustomColor )
self.settings.connect( "changed::custom_border_color", self.toggleCustomBorderColor )
self.settings.connect( "changed::custom_heading_color", self.toggleCustomHeadingColor )
self.settings.connect( "changed::custom_color", self.toggleCustomBackgroundColor )
self.settings.connect( "changed::border_width", self.toggleBorderWidth )
self.settings.connect( "changed::opacity", self.toggleOpacity )
def quit_cb (self):
Gtk.main_quit()
@ -183,20 +179,21 @@ class MainWindow( object ):
def getSetGconfEntries( self ):
self.pluginlist = self.gconf.get( "list-string", "plugins_list",['places', 'system_management', 'newpane', 'applications'] )
self.dottedfile = os.path.join( self.path, "dotted.png")
self.usecustomcolor = self.gconf.get( "bool", "use_custom_color", False )
self.customcolor = self.gconf.get( "color", "custom_color", "#EEEEEE" )
self.customheadingcolor = self.gconf.get( "color", "custom_heading_color", "#001155" )
self.custombordercolor = self.gconf.get( "color", "custom_border_color", "#001155" )
self.pluginlist = self.settings.get_strv( "plugins-list" )
self.usecustomcolor = self.settings.get_boolean( "use-custom-color" )
self.customcolor = self.settings.get_string( "custom-color" )
self.customheadingcolor = self.settings.get_string( "custom-heading-color" )
self.custombordercolor = self.settings.get_string( "custom-border-color" )
self.borderwidth = self.settings.get_int( "border-width" )
self.opacity = self.settings.get_int( "opacity" )
self.offset = self.settings.get_int( "offset" )
self.enableTooltips = self.settings.get_boolean( "tooltips-enabled" )
self.startWithFavorites = self.settings.get_boolean( "start-with-favorites" )
self.borderwidth = self.gconf.get( "int", "border_width", 1 )
self.opacity = self.gconf.get( "int", "opacity", 98 )
self.offset = self.gconf.get( "int", "mintMenu_offset", 0 )
self.enableTooltips = self.gconf.get( "bool", "tooltips_enabled", True )
self.globalEnableTooltips = self.gconf.get( "bool", "/apps/panel/global/tooltips_enabled", True )
self.startWithFavorites = self.gconf.get( "bool", "start_with_favorites", False )
mate_settings = Gio.Settings.new("org.mate.panel")
self.globalEnableTooltips = mate_settings.get_boolean( "tooltips-enabled" )
def SetupMintMenuBorder( self ):
if self.usecustomcolor:
@ -523,28 +520,28 @@ class MainWindow( object ):
class MenuWin( object ):
def __init__( self, applet, iid ):
self.applet = applet
self.settings = Gio.Settings.new_with_path("com.linuxmint.mintmenu", self.applet.get_preferences_path())
self.gconf = EasyGConf( "/apps/mintMenu/" )
self.gconf.notifyAdd( "applet_text", self.gconfEntriesChanged )
self.gconf.notifyAdd( "theme_name", self.changeTheme )
self.gconf.notifyAdd( "hot_key", self.gconfEntriesChanged )
self.gconf.notifyAdd( "applet_icon", self.gconfEntriesChanged )
self.gconf.notifyAdd( "hide_applet_icon", self.gconfEntriesChanged )
self.gconf.notifyAdd( "applet_icon_size", self.gconfEntriesChanged )
self.getGconfEntries()
self.settings.connect( "changed::applet_text", self.reloadSettings )
self.settings.connect( "changed::theme_name", self.changeTheme )
self.settings.connect( "changed::hot_key", self.reloadSettings )
self.settings.connect( "changed::applet_icon", self.reloadSettings )
self.settings.connect( "changed::hide-applet-icon", self.reloadSettings )
self.settings.connect( "changed::applet_icon_size", self.reloadSettings )
self.loadSettings()
self.gconftheme = EasyGConf( "/desktop/mate/interface/" )
self.gconftheme.notifyAdd( "gtk_theme", self.changeTheme )
mate_settings = Gio.Settings.new("org.mate.interface")
mate_settings.connect( "changed::gtk-theme", self.changeTheme )
self.createPanelButton()
self.applet.set_applet_flags( mateapplet.EXPAND_MINOR )
self.applet.set_flags( MatePanelApplet.AppletFlags.EXPAND_MINOR )
self.applet.connect( "button-press-event", self.showMenu )
self.applet.connect( "change-orient", self.changeOrientation )
self.applet.connect( "change-background", self.changeBackground )
self.applet.connect("enter-notify-event", self.enter_notify)
self.applet.connect("leave-notify-event", self.leave_notify)
self.mainwin = MainWindow( self.button_box )
self.mainwin = MainWindow( self.button_box, self.settings )
self.mainwin.window.connect( "map-event", lambda *args: self.applet.set_state( Gtk.StateType.SELECTED ) )
self.mainwin.window.connect( "unmap-event", lambda *args: self.applet.set_state( Gtk.StateType.NORMAL ) )
self.mainwin.window.connect( "size-allocate", lambda *args: self.positionMenu() )
@ -591,7 +588,7 @@ class MenuWin( object ):
self.button_icon.set_from_pixbuf(pixbuf)
def createPanelButton( self ):
self.button_icon = Gtk.image_new_from_file( self.buttonIcon )
self.button_icon = Gtk.Image.new_from_file( self.buttonIcon )
self.systemlabel = Gtk.Label(label= self.buttonText )
if os.path.exists("/etc/linuxmint/info"):
import commands
@ -602,20 +599,20 @@ class MenuWin( object ):
self.systemlabel.set_tooltip_text(tooltip)
self.button_icon.set_tooltip_text(tooltip)
if self.applet.get_orient() == mateapplet.ORIENT_UP or self.applet.get_orient() == mateapplet.ORIENT_DOWN:
if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN:
self.button_box = Gtk.HBox()
self.button_box.pack_start( self.button_icon, False, False )
self.button_box.pack_start( self.systemlabel, False, False )
self.button_box.pack_start( self.button_icon, False, False, 0 )
self.button_box.pack_start( self.systemlabel, False, False, 0 )
self.button_icon.set_padding( 5, 0 )
# if we have a vertical panel
elif self.applet.get_orient() == mateapplet.ORIENT_LEFT:
elif self.applet.get_orient() == MatePanelApplet.AppletOrient.LEFT:
self.button_box = Gtk.VBox()
self.systemlabel.set_angle( 270 )
self.button_box.pack_start( self.systemlabel , True, True, 0)
self.button_box.pack_start( self.button_icon , True, True, 0)
self.button_icon.set_padding( 5, 0 )
elif self.applet.get_orient() == mateapplet.ORIENT_RIGHT:
elif self.applet.get_orient() == MatePanelApplet.AppletOrient.RIGHT:
self.button_box = Gtk.VBox()
self.systemlabel.set_angle( 90 )
self.button_box.pack_start( self.button_icon , True, True, 0)
@ -629,13 +626,13 @@ class MenuWin( object ):
self.applet.add( self.button_box )
def getGconfEntries( self, *args, **kargs ):
self.hideIcon = self.gconf.get( "bool", "hide_applet_icon", False )
self.buttonText = self.gconf.get( "string", "applet_text", "Menu" )
self.theme_name = self.gconf.get( "string", "theme_name", "default" )
self.hotkeyText = self.gconf.get( "string", "hot_key", "<Control>Super_L" )
self.buttonIcon = self.gconf.get( "string", "applet_icon", ICON )
self.iconSize = self.gconf.get( "int", "applet_icon_size", 22 )
def loadSettings( self, *args, **kargs ):
self.hideIcon = self.settings.get_boolean( "hide-applet-icon" )
self.buttonText = self.settings.get_string( "applet-text" )
self.theme_name = self.settings.get_string( "theme-name" )
self.hotkeyText = self.settings.get_string( "hot-key" )
self.buttonIcon = self.settings.get_string( "applet-icon" )
self.iconSize = self.settings.get_int( "applet-icon-size" )
def changeBackground( self, applet, type, color, pixmap ):
@ -646,21 +643,22 @@ class MenuWin( object ):
rc_style = Gtk.RcStyle()
self.applet.modify_style(rc_style)
if mateapplet.COLOR_BACKGROUND == type:
if MatePanelApplet.AppletBackgroundType.COLOR_BACKGROUND == type:
applet.modify_bg( Gtk.StateType.NORMAL, color )
elif mateapplet.PIXMAP_BACKGROUND == type:
elif MatePanelApplet.AppletBackgroundType.PIXMAP_BACKGROUND == type:
style = applet.style
style.bg_pixmap[ Gtk.StateType.NORMAL ] = pixmap
applet.set_style( style )
def changeTheme(self, *args):
self.gconfEntriesChanged()
self.reloadSettings()
self.applyTheme()
self.mainwin.RegenPlugins()
def applyTheme(self):
style_settings = Gtk.Settings.get_default()
desktop_theme = self.gconf.get( "string", '/desktop/mate/interface/gtk_theme', "")
mate_settings = Gio.Settings.new("org.mate.interface")
desktop_theme = mate_settings.get_string('gtk-theme')
if self.theme_name == "default":
style_settings.set_property("gtk-theme-name", desktop_theme)
else:
@ -671,17 +669,17 @@ class MenuWin( object ):
def changeOrientation( self, *args, **kargs ):
if self.applet.get_orient() == mateapplet.ORIENT_UP or self.applet.get_orient() == mateapplet.ORIENT_DOWN:
if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN:
tmpbox = Gtk.HBox()
self.systemlabel.set_angle( 0 )
self.button_box.reorder_child( self.button_icon, 0 )
self.button_icon.set_padding( 5, 0 )
elif self.applet.get_orient() == mateapplet.ORIENT_LEFT:
elif self.applet.get_orient() == MatePanelApplet.AppletOrient.LEFT:
tmpbox = Gtk.VBox()
self.systemlabel.set_angle( 270 )
self.button_box.reorder_child( self.button_icon, 1 )
self.button_icon.set_padding( 0, 5 )
elif self.applet.get_orient() == mateapplet.ORIENT_RIGHT:
elif self.applet.get_orient() == MatePanelApplet.AppletOrient.RIGHT:
tmpbox = Gtk.VBox()
self.systemlabel.set_angle( 90 )
self.button_box.reorder_child( self.button_icon, 0 )
@ -726,19 +724,19 @@ class MenuWin( object ):
self.button_icon.show()
# This code calculates width and height for the button_box
# and takes the orientation in account
if self.applet.get_orient() == mateapplet.ORIENT_UP or self.applet.get_orient() == mateapplet.ORIENT_DOWN:
if self.hideIcon:
self.applet.set_size_request( self.systemlabel.size_request()[0] + 2, -1 )
else:
self.applet.set_size_request( self.systemlabel.size_request()[0] + self.button_icon.size_request()[0] + 5, self.button_icon.size_request()[1] )
else:
if self.hideIcon:
self.applet.set_size_request( self.button_icon.size_request()[0], self.systemlabel.size_request()[1] + 2 )
else:
self.applet.set_size_request( self.button_icon.size_request()[0], self.systemlabel.size_request()[1] + self.button_icon.size_request()[1] + 5 )
#if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN:
# if self.hideIcon:
# self.applet.set_size_request( self.systemlabel.size_request()[0] + 2, -1 )
# else:
# self.applet.set_size_request( self.systemlabel.size_request()[0] + self.button_icon.size_request()[0] + 5, self.button_icon.size_request()[1] )
#else:
# if self.hideIcon:
# self.applet.set_size_request( self.button_icon.size_request()[0], self.systemlabel.size_request()[1] + 2 )
# else:
# self.applet.set_size_request( self.button_icon.size_request()[0], self.systemlabel.size_request()[1] + self.button_icon.size_request()[1] + 5 )
def gconfEntriesChanged( self, *args ):
self.getGconfEntries()
def reloadSettings( self, *args ):
self.loadSettings()
self.updateButton()
def showAboutDialog( self, uicomponent, verb ):
@ -811,7 +809,7 @@ class MenuWin( object ):
screenHeight = Gdk.Screen.height()
screenWidth = Gdk.Screen.width()
if self.applet.get_orient() == mateapplet.ORIENT_UP or self.applet.get_orient() == mateapplet.ORIENT_DOWN:
if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN:
if entryX + ourWidth < screenWidth or entryX + entryWidth / 2 < screenWidth / 2:
# Align to the left of the entry
newX = entryX

View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="com.linuxmint.mintmenu">
<key type="b" name="hide-applet-icon">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="use-custom-color">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="tooltips-enabled">
<default>true</default>
<summary></summary>
<description></description>
</key>
<key type="b" name="start-with-favorites">
<default>false</default>
<summary></summary>
<description></description>
</key>
<key type="i" name="applet-icon-size">
<default>22</default>
<summary></summary>
<description></description>
</key>
<key type="i" name="border-width">
<default>1</default>
<summary></summary>
<description></description>
</key>
<key type="i" name="opacity">
<default>98</default>
<summary></summary>
<description></description>
</key>
<key type="i" name="offset">
<default>0</default>
<summary></summary>
<description></description>
</key>
<key type="s" name="applet-text">
<default>"Menu"</default>
<summary></summary>
<description></description>
</key>
<key type="s" name="theme-name">
<default>"default"</default>
<summary></summary>
<description></description>
</key>
<key type="s" name="hot-key">
<default>"ControlSuper_L"</default>
<summary></summary>
<description></description>
</key>
<key type="s" name="applet-icon">
<default>"/usr/lib/linuxmint/mintMenu/visualisation-logo.png"</default>
<summary></summary>
<description></description>
</key>
<key type="as" name="plugins-list">
<default>['places', 'system_management', 'newpane', 'applications']</default>
<summary></summary>
<description></description>
</key>
<key type="s" name="custom-color">
<default>"#EEEEEE"</default>
<summary></summary>
<description></description>
</key>
<key type="s" name="custom-heading-color">
<default>"#001155"</default>
<summary></summary>
<description></description>
</key>
<key type="s" name="custom-border-color">
<default>"#001155"</default>
<summary></summary>
<description></description>
</key>
</schema>
</schemalist>