Merge pull request #74 from hordepfo/themes-fixed

Themes fixed
This commit is contained in:
Clement Lefebvre 2014-04-02 12:23:32 +01:00
commit fbf13f70cc
2 changed files with 54 additions and 57 deletions

View File

@ -93,8 +93,20 @@ 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 )
self.panelSettings = Gio.Settings.new("org.mate.panel")
self.panelSettings.connect( "changed::tooltips-enabled", self.toggleTooltipsEnabled )
self.settings.connect( "changed::plugins-list", self.RegenPlugins )
self.settings.connect( "changed::start-with-favorites", self.toggleStartWithFavorites )
self.settings.connect( "changed::tooltips-enabled", self.toggleTooltipsEnabled )
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 )
self.getSetGSettingEntries() self.getSetGSettingEntries()
self.SetupMintMenuBorder()
self.tooltips = Gtk.Tooltips() self.tooltips = Gtk.Tooltips()
if self.globalEnableTooltips and self.enableTooltips: if self.globalEnableTooltips and self.enableTooltips:
@ -103,21 +115,6 @@ class MainWindow( object ):
self.tooltips.disable() self.tooltips.disable()
self.PopulatePlugins(); self.PopulatePlugins();
self.settings.connect( "changed::plugins-list", self.RegenPlugins )
self.settings.connect( "changed::start-with-favorites", self.toggleStartWithFavorites )
globalsettings = Gio.Settings.new("org.mate.panel")
globalsettings.connect( "changed::tooltips-enabled", self.toggleTooltipsEnabled )
self.settings.connect( "changed::tooltips-enabled", self.toggleTooltipsEnabled )
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 )
self.firstTime = True; self.firstTime = True;
def on_window1_destroy (self, widget, data=None): def on_window1_destroy (self, widget, data=None):
@ -154,9 +151,7 @@ class MainWindow( object ):
def toggleUseCustomColor( self, settings, key, args = None ): def toggleUseCustomColor( self, settings, key, args = None ):
self.usecustomcolor = settings.get_boolean(key) self.usecustomcolor = settings.get_boolean(key)
self.SetupMintMenuBorder() self.loadTheme()
self.SetPaneColors( self.panesToColor )
self.SetHeadingStyle( self.headingsToColor )
def toggleCustomBorderColor( self, settings, key, args = None ): def toggleCustomBorderColor( self, settings, key, args = None ):
self.custombordercolor = settings.get_string(key) self.custombordercolor = settings.get_string(key)
@ -184,14 +179,13 @@ class MainWindow( object ):
self.enableTooltips = self.settings.get_boolean( "tooltips-enabled" ) self.enableTooltips = self.settings.get_boolean( "tooltips-enabled" )
self.startWithFavorites = self.settings.get_boolean( "start-with-favorites" ) self.startWithFavorites = self.settings.get_boolean( "start-with-favorites" )
mate_settings = Gio.Settings.new("org.mate.panel") self.globalEnableTooltips = self.panelSettings.get_boolean( "tooltips-enabled" )
self.globalEnableTooltips = mate_settings.get_boolean( "tooltips-enabled" )
def SetupMintMenuBorder( self ): def SetupMintMenuBorder( self, defaultStyle = None ):
if self.usecustomcolor: if self.usecustomcolor:
self.window.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.custombordercolor ) ) self.window.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.custombordercolor ) )
# else: elif defaultStyle is not None:
# self.window.modify_bg( Gtk.StateType.NORMAL, self.window.rc_get_style().bg[ Gtk.StateType.SELECTED ] ) self.window.modify_bg( Gtk.StateType.NORMAL, defaultStyle.lookup_color('bg_color')[1] )
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 ):
@ -222,10 +216,9 @@ class MainWindow( object ):
PluginPane.show() PluginPane.show()
PaneLadder = Gtk.VBox( False, 0 ) PaneLadder = Gtk.VBox( False, 0 )
PluginPane.add( PaneLadder ) PluginPane.add( PaneLadder )
self.SetPaneColors( [ PluginPane ] )
ImageBox = Gtk.EventBox() ImageBox = Gtk.EventBox()
self.SetPaneColors( [ ImageBox ] )
ImageBox.show() ImageBox.show()
self.panesToColor.extend( [ PluginPane, ImageBox ] )
seperatorImage = GdkPixbuf.Pixbuf.new_from_file( self.dottedfile ) seperatorImage = GdkPixbuf.Pixbuf.new_from_file( self.dottedfile )
@ -279,9 +272,7 @@ class MainWindow( object ):
print u"Unable to load " + plugin + " plugin :-(" print u"Unable to load " + plugin + " plugin :-("
self.SetPaneColors( [MyPlugin.content_holder] ) self.panesToColor.append( MyPlugin.content_holder )
MyPlugin.content_holder.show() MyPlugin.content_holder.show()
VBox1 = Gtk.VBox( False, 0 ) VBox1 = Gtk.VBox( False, 0 )
@ -290,14 +281,14 @@ class MainWindow( object ):
Align1 = Gtk.Alignment.new( 0, 0, 0, 0 ) Align1 = Gtk.Alignment.new( 0, 0, 0, 0 )
Align1.set_padding( 10, 5, 10, 0 ) Align1.set_padding( 10, 5, 10, 0 )
Align1.add( Label1 ) Align1.add( Label1 )
self.SetHeadingStyle( [Label1] ) self.headingsToColor.append( Label1 )
Align1.show() Align1.show()
Label1.show() Label1.show()
if not hasattr( MyPlugin, 'sticky' ) or MyPlugin.sticky == True: if not hasattr( MyPlugin, 'sticky' ) or MyPlugin.sticky == True:
heading = Gtk.EventBox() heading = Gtk.EventBox()
Align1.set_padding( 0, 0, 10, 0 ) Align1.set_padding( 0, 0, 10, 0 )
self.SetPaneColors( [heading] ) heading.set_visible_window( False )
heading.set_size_request( MyPlugin.width, 30 ) heading.set_size_request( MyPlugin.width, 30 )
else: else:
heading = Gtk.HBox() heading = Gtk.HBox()
@ -326,7 +317,9 @@ class MainWindow( object ):
if hasattr( MyPlugin, 'height' ): if hasattr( MyPlugin, 'height' ):
MyPlugin.content_holder.set_size_request( -1, MyPlugin.height ) MyPlugin.content_holder.set_size_request( -1, MyPlugin.height )
if hasattr( MyPlugin, 'itemstocolor' ): if hasattr( MyPlugin, 'itemstocolor' ):
self.SetPaneColors( MyPlugin.itemstocolor ) self.panesToColor.extend( MyPlugin.itemstocolor )
if hasattr( MyPlugin, 'headingstocolor' ):
self.headingsToColor.extend( MyPlugin.headingstocolor )
except: except:
# create traceback # create traceback
info = sys.exc_info() info = sys.exc_info()
@ -344,9 +337,8 @@ class MainWindow( object ):
PluginPane = Gtk.EventBox() PluginPane = Gtk.EventBox()
PaneLadder = Gtk.VBox( False, 0 ) PaneLadder = Gtk.VBox( False, 0 )
PluginPane.add( PaneLadder ) PluginPane.add( PaneLadder )
self.SetPaneColors( [PluginPane] )
ImageBox = Gtk.EventBox() ImageBox = Gtk.EventBox()
self.SetPaneColors( [ImageBox] ) self.panesToColor.extend( [ PluginPane, ImageBox ] )
ImageBox.show() ImageBox.show()
PluginPane.show_all() PluginPane.show_all()
@ -368,22 +360,30 @@ class MainWindow( object ):
self.tooltips.disable() self.tooltips.disable()
#print u"Loading", (time.time() - start), "s" #print u"Loading", (time.time() - start), "s"
def SetPaneColors( self, items ): # A little hacky but works
for item in items: def getDefaultStyle( self ):
if item not in self.panesToColor: widget = Gtk.EventBox()
self.panesToColor.append( item ) widget.show()
return Gtk.rc_get_style(widget)
def loadTheme( self ):
defaultStyle = self.getDefaultStyle()
self.SetPaneColors( self.panesToColor, defaultStyle )
self.SetupMintMenuBorder( defaultStyle )
self.SetHeadingStyle( self.headingsToColor )
def SetPaneColors( self, items, defaultStyle = None ):
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: # TODO: Changing background color isn't working for pixmaps! The following does not work:
# for item in items: item.get_style().bg_pixmap[Gtk.StateType.NORMAL] = None
# item.modify_bg( Gtk.StateType.NORMAL, self.paneholder.rc_get_style().bg[ Gtk.StateType.NORMAL ] ) elif defaultStyle is not None:
for item in items:
item.modify_bg( Gtk.StateType.NORMAL, defaultStyle.lookup_color('bg_color')[1] )
item.get_style().bg_pixmap[Gtk.StateType.NORMAL] = defaultStyle.bg_pixmap[Gtk.StateType.NORMAL]
def SetHeadingStyle( self, items ): def SetHeadingStyle( self, items ):
for item in items:
if item not in self.headingsToColor:
self.headingsToColor.append( item )
if self.usecustomcolor: if self.usecustomcolor:
color = self.customheadingcolor color = self.customheadingcolor
else: else:
@ -425,6 +425,7 @@ class MainWindow( object ):
self.getSetGSettingEntries() self.getSetGSettingEntries()
self.PopulatePlugins() self.PopulatePlugins()
self.loadTheme()
#print NAME+u" reloaded" #print NAME+u" reloaded"
@ -497,8 +498,8 @@ class MenuWin( object ):
self.settings.connect( "changed::hot-key", self.hotkeyChanged ) self.settings.connect( "changed::hot-key", self.hotkeyChanged )
self.loadSettings() self.loadSettings()
mate_settings = Gio.Settings.new("org.mate.interface") self.mate_settings = Gio.Settings.new("org.mate.interface")
mate_settings.connect( "changed::gtk-theme", self.changeTheme ) self.mate_settings.connect( "changed::gtk-theme", self.changeTheme )
self.createPanelButton() self.createPanelButton()
@ -514,6 +515,8 @@ class MenuWin( object ):
self.mainwin.window.connect( "size-allocate", lambda *args: self.positionMenu() ) self.mainwin.window.connect( "size-allocate", lambda *args: self.positionMenu() )
self.mainwin.window.set_name("mintmenu") # Name used in Gtk RC files self.mainwin.window.set_name("mintmenu") # Name used in Gtk RC files
self.applyTheme()
self.mainwin.loadTheme()
if self.mainwin.icon: if self.mainwin.icon:
Gtk.Window.set_default_icon_name( self.mainwin.icon ) Gtk.Window.set_default_icon_name( self.mainwin.icon )
@ -616,12 +619,11 @@ class MenuWin( object ):
def changeTheme(self, *args): def changeTheme(self, *args):
self.reloadSettings() self.reloadSettings()
self.applyTheme() self.applyTheme()
self.mainwin.RegenPlugins() self.mainwin.loadTheme()
def applyTheme(self): def applyTheme(self):
style_settings = Gtk.Settings.get_default() style_settings = Gtk.Settings.get_default()
mate_settings = Gio.Settings.new("org.mate.interface") desktop_theme = self.mate_settings.get_string('gtk-theme')
desktop_theme = mate_settings.get_string('gtk-theme')
if self.theme_name == "default": if self.theme_name == "default":
style_settings.set_property("gtk-theme-name", desktop_theme) style_settings.set_property("gtk-theme-name", desktop_theme)
else: else:

View File

@ -250,7 +250,7 @@ class pluginclass( object ):
self.builder.get_object("label7").set_text(_("All applications")) self.builder.get_object("label7").set_text(_("All applications"))
self.builder.get_object("label2").set_text(_("Applications")) self.builder.get_object("label2").set_text(_("Applications"))
self.mintMenuWin.SetHeadingStyle( [self.builder.get_object("label6"),self.builder.get_object("label2")] ) self.headingstocolor = [self.builder.get_object("label6"),self.builder.get_object("label2")]
self.numApps = 0 self.numApps = 0
# These properties are NECESSARY to maintain consistency # These properties are NECESSARY to maintain consistency
@ -265,7 +265,7 @@ class pluginclass( object ):
self.content_holder =self.builder.get_object( "Applications" ) self.content_holder =self.builder.get_object( "Applications" )
# Items to get custom colors # Items to get custom colors
self.itemstocolor = [self.builder.get_object( "viewport1" ),self.builder.get_object( "viewport2" ),self.builder.get_object( "viewport3" ),self.builder.get_object( "notebook2" ) ] self.itemstocolor = [self.builder.get_object( "viewport1" ),self.builder.get_object( "viewport2" ),self.builder.get_object( "viewport3" ) ]
# Unset all timers # Unset all timers
self.filterTimer = None self.filterTimer = None
@ -648,7 +648,6 @@ class pluginclass( object ):
separator.set_visible_window(False) separator.set_visible_window(False)
separator.set_size_request(-1, 20) separator.set_size_request(-1, 20)
separator.type = "separator" separator.type = "separator"
self.mintMenuWin.SetPaneColors( [ separator ] )
separator.show_all() separator.show_all()
self.applicationsBox.add(separator) self.applicationsBox.add(separator)
self.suggestions.append(separator) self.suggestions.append(separator)
@ -727,7 +726,6 @@ class pluginclass( object ):
last_separator.set_visible_window(False) last_separator.set_visible_window(False)
last_separator.set_size_request(-1, 20) last_separator.set_size_request(-1, 20)
last_separator.type = "separator" last_separator.type = "separator"
self.mintMenuWin.SetPaneColors( [ last_separator ] )
last_separator.show_all() last_separator.show_all()
self.applicationsBox.add(last_separator) self.applicationsBox.add(last_separator)
self.suggestions.append(last_separator) self.suggestions.append(last_separator)
@ -783,7 +781,6 @@ class pluginclass( object ):
last_separator.set_visible_window(False) last_separator.set_visible_window(False)
last_separator.set_size_request(-1, 20) last_separator.set_size_request(-1, 20)
last_separator.type = "separator" last_separator.type = "separator"
self.mintMenuWin.SetPaneColors( [ last_separator ] )
last_separator.show_all() last_separator.show_all()
self.applicationsBox.add(last_separator) self.applicationsBox.add(last_separator)
self.suggestions.append(last_separator) self.suggestions.append(last_separator)
@ -1357,7 +1354,6 @@ class pluginclass( object ):
space.connect( "button-press-event", self.favPopup ) space.connect( "button-press-event", self.favPopup )
space.type = "space" space.type = "space"
self.mintMenuWin.SetPaneColors( [ space ] )
space.show() space.show()
return space return space
@ -1367,7 +1363,6 @@ class pluginclass( object ):
separator.set_size_request( -1, 20 ) separator.set_size_request( -1, 20 )
separator.type = "separator" separator.type = "separator"
self.mintMenuWin.SetPaneColors( [ separator ] )
separator.show_all() separator.show_all()
box = Gtk.EventBox() box = Gtk.EventBox()
box.type = "separator" box.type = "separator"