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

View File

@ -474,7 +474,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">1</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -490,7 +490,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">2</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -506,7 +506,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">3</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
@ -519,6 +519,21 @@
<property name="halign">start</property> <property name="halign">start</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</object> </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> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>

View File

@ -47,6 +47,9 @@ class mintMenuConfig(object):
self.showApplicationsPlugin = self.builder.get_object("showApplicationsPlugin") self.showApplicationsPlugin = self.builder.get_object("showApplicationsPlugin")
self.showSystemPlugin = self.builder.get_object("showSystemPlugin") self.showSystemPlugin = self.builder.get_object("showSystemPlugin")
self.showPlacesPlugin = self.builder.get_object("showPlacesPlugin") self.showPlacesPlugin = self.builder.get_object("showPlacesPlugin")
self.showTooltips = self.builder.get_object("showToolTips")
self.swapGeneric = self.builder.get_object("swapGeneric") self.swapGeneric = self.builder.get_object("swapGeneric")
self.hover = self.builder.get_object("hover") self.hover = self.builder.get_object("hover")
self.hoverDelay = self.builder.get_object("hoverDelay") self.hoverDelay = self.builder.get_object("hoverDelay")
@ -153,6 +156,7 @@ class mintMenuConfig(object):
self.showSystemPlugin.connect("toggled", self.setPluginsLayout) self.showSystemPlugin.connect("toggled", self.setPluginsLayout)
self.showPlacesPlugin.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-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) 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: for item in addedCategories:
try: try:
item["button"] = CategoryButton(item["icon"], categoryIconSize, [item["name"]], item["filter"]) item["button"] = CategoryButton(item["icon"], categoryIconSize, [item["name"]], item["filter"])
self.mintMenuWin.setTooltip(item["button"], item["tooltip"])
if self.categories_mouse_over: if self.categories_mouse_over:
startId = item["button"].connect("enter", self.StartFilter, item["filter"]) startId = item["button"].connect("enter", self.StartFilter, item["filter"])

View File

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