Fix tooltips and make them optional, remove category tooltips in apps

Ported from https://github.com/linuxmint/mintmenu/pull/226
This commit is contained in:
Clement Lefebvre 2019-05-14 16:49:40 +01:00
parent 65c9c3e003
commit 1984d57525
5 changed files with 29 additions and 30 deletions

View File

@ -73,9 +73,6 @@ class MainWindow(object):
plugindir = os.path.join(os.path.expanduser("~"), ".linuxmint/mintMenu/plugins")
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)
@ -86,12 +83,9 @@ class MainWindow(object):
self.getSetGSettingEntries()
self.tooltipsWidgets = []
if self.globalEnableTooltips and self.enableTooltips:
self.tooltipsEnable()
else:
self.tooltipsEnable(False)
self.PopulatePlugins()
self.toggleTooltipsEnabled(self.settings, "tooltips-enabled")
self.firstTime = True
@classmethod
@ -105,16 +99,10 @@ class MainWindow(object):
if hasattr(plugin, "wake"):
plugin.wake()
def toggleTooltipsEnabled(self, settings, key, args = None):
if key == "tooltips-enabled":
self.globalEnableTooltips = settings.get_boolean(key)
else:
self.enableTooltips = settings.get_boolean(key)
if self.globalEnableTooltips and self.enableTooltips:
self.tooltipsEnable()
else:
self.tooltipsEnable(False)
def toggleTooltipsEnabled(self, settings, key, args=None):
enableTooltips = settings.get_boolean(key)
for widget in self.tooltipsWidgets:
widget.set_has_tooltip(enableTooltips)
def toggleStartWithFavorites(self, settings, key):
self.startWithFavorites = settings.get_boolean(key)
@ -133,7 +121,6 @@ class MainWindow(object):
def getSetGSettingEntries(self):
self.dottedfile = os.path.join(self.path, "dotted.png")
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")
@ -142,8 +129,6 @@ class MainWindow(object):
self.enableTooltips = self.settings.get_boolean("tooltips-enabled")
self.startWithFavorites = self.settings.get_boolean("start-with-favorites")
self.globalEnableTooltips = self.panelSettings.get_boolean("tooltips-enabled")
def PopulatePlugins(self):
self.panesToColor = []
self.headingsToColor = []
@ -294,7 +279,6 @@ class MainWindow(object):
self.paneholder.pack_start(ImageBox, False, False, 0)
self.paneholder.pack_start(PluginPane, False, False, 0)
self.tooltipsEnable(False)
# A little bit hacky but works.
@staticmethod
@ -342,10 +326,6 @@ class MainWindow(object):
markup = '<span size="12000" weight="bold" color="%s">%s</span>' % (color, text)
item.set_markup(markup)
def tooltipsEnable(self, enable = True):
for widget in self.tooltipsWidgets:
widget.set_has_tooltip(enable)
def setTooltip(self, widget, tip):
self.tooltipsWidgets.append(widget)
widget.set_tooltip_text(tip)
@ -373,6 +353,7 @@ class MainWindow(object):
self.getSetGSettingEntries()
self.PopulatePlugins()
self.toggleTooltipsEnabled(self.settings, "tooltips-enabled")
self.loadTheme()
#print NAME+u" reloaded"

View File

@ -474,7 +474,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
<child>
@ -490,7 +490,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>
<child>
@ -506,7 +506,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
<property name="position">2</property>
</packing>
</child>
<child>
@ -519,6 +519,21 @@
<property name="halign">start</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="showToolTips">
<property name="label" translatable="yes">Show tooltips</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>

View File

@ -47,6 +47,9 @@ class mintMenuConfig(object):
self.showApplicationsPlugin = self.builder.get_object("showApplicationsPlugin")
self.showSystemPlugin = self.builder.get_object("showSystemPlugin")
self.showPlacesPlugin = self.builder.get_object("showPlacesPlugin")
self.showTooltips = self.builder.get_object("showToolTips")
self.swapGeneric = self.builder.get_object("swapGeneric")
self.hover = self.builder.get_object("hover")
self.hoverDelay = self.builder.get_object("hoverDelay")
@ -153,6 +156,7 @@ class mintMenuConfig(object):
self.showSystemPlugin.connect("toggled", self.setPluginsLayout)
self.showPlacesPlugin.connect("toggled", self.setPluginsLayout)
self.bindGSettingsValueToWidget(self.settings, "bool", "tooltips-enabled", self.showTooltips, "toggled", self.showTooltips.set_active, self.showTooltips.get_active)
self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-computer", self.computertoggle, "toggled", self.computertoggle.set_active, self.computertoggle.get_active)
self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-home-folder", self.homefoldertoggle, "toggled", self.homefoldertoggle.set_active, self.homefoldertoggle.get_active)

View File

@ -1480,7 +1480,6 @@ class pluginclass(object):
for item in addedCategories:
try:
item["button"] = CategoryButton(item["icon"], categoryIconSize, [item["name"]], item["filter"])
self.mintMenuWin.setTooltip(item["button"], item["tooltip"])
if self.categories_mouse_over:
startId = item["button"].connect("enter", self.StartFilter, item["filter"])

View File

@ -15,7 +15,7 @@
</key>
<key type="b" name="tooltips-enabled">
<default>true</default>
<default>false</default>
<summary></summary>
<description></description>
</key>