Fix broken thumbnail butto tooltips

This commit is contained in:
Ingo Weyrich 2019-07-29 15:21:23 +02:00
parent f523149582
commit 0f0dc03849
5 changed files with 19 additions and 12 deletions

View File

@ -168,10 +168,12 @@ void BatchQueueEntry::getIconSize (int& w, int& h) const
}
Glib::ustring BatchQueueEntry::getToolTip (int x, int y) const
std::tuple<Glib::ustring, bool> BatchQueueEntry::getToolTip (int x, int y) const
{
// get the parent class' tooltip first
Glib::ustring tooltip = ThumbBrowserEntryBase::getToolTip(x, y);
Glib::ustring tooltip;
bool useMarkup;
std::tie(tooltip, useMarkup) = ThumbBrowserEntryBase::getToolTip(x, y);
// add the saving param options
if (!outFileName.empty()) {
@ -198,7 +200,7 @@ Glib::ustring BatchQueueEntry::getToolTip (int x, int y) const
}
}
return tooltip;
return std::make_tuple(std::move(tooltip), useMarkup);
}

View File

@ -70,7 +70,7 @@ public:
std::vector<Glib::RefPtr<Gdk::Pixbuf>> getIconsOnImageArea () override;
void getIconSize (int& w, int& h) const override;
Glib::ustring getToolTip (int x, int y) const override;
std::tuple<Glib::ustring, bool> getToolTip (int x, int y) const override;
// bqentryupdatelistener interface
void updateImage (guint8* img, int w, int h, int origw, int origh, guint8* newOPreview) override;

View File

@ -745,20 +745,24 @@ void ThumbBrowserBase::Internal::on_realize()
bool ThumbBrowserBase::Internal::on_query_tooltip (int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip)
{
// Gtk signals automatically acquire the GUI (i.e. this method is enclosed by gdk_thread_enter and gdk_thread_leave)
Glib::ustring ttip = "";
Glib::ustring ttip;
boolean useMarkup = false;
{
MYREADERLOCK(l, parent->entryRW);
for (size_t i = 0; i < parent->fd.size(); i++)
if (parent->fd[i]->drawable && parent->fd[i]->inside (x, y)) {
ttip = parent->fd[i]->getToolTip (x, y);
std::tie(ttip, useMarkup) = parent->fd[i]->getToolTip (x, y);
break;
}
}
if (!ttip.empty()) {
tooltip->set_text(ttip);
if (useMarkup) {
tooltip->set_markup(ttip);
} else {
tooltip->set_text(ttip);
}
return true;
} else {
return false;

View File

@ -724,7 +724,7 @@ bool ThumbBrowserEntryBase::releaseNotify (int button, int type, int bstate, int
return buttonSet ? buttonSet->releaseNotify (x, y) : false;
}
Glib::ustring ThumbBrowserEntryBase::getToolTip (int x, int y) const
std::tuple<Glib::ustring, bool> ThumbBrowserEntryBase::getToolTip (int x, int y) const
{
Glib::ustring tooltip;
@ -734,6 +734,7 @@ Glib::ustring ThumbBrowserEntryBase::getToolTip (int x, int y) const
// Always show the filename in the tooltip since the filename in the thumbnail could be truncated.
// If "Show Exif info" is disabled, also show Exif info in the tooltip.
bool useMarkup = !tooltip.empty();
if (inside(x, y) && tooltip.empty()) {
tooltip = dispname;
@ -748,7 +749,7 @@ Glib::ustring ThumbBrowserEntryBase::getToolTip (int x, int y) const
}
}
return tooltip;
return std::make_tuple(std::move(tooltip), useMarkup);
}

View File

@ -19,7 +19,7 @@
#pragma once
#include <atomic>
#include <tuple>
#include <gtkmm.h>
#include "cursormanager.h"
@ -190,7 +190,7 @@ public:
virtual bool motionNotify (int x, int y);
virtual bool pressNotify (int button, int type, int bstate, int x, int y);
virtual bool releaseNotify (int button, int type, int bstate, int x, int y);
virtual Glib::ustring getToolTip (int x, int y) const;
virtual std::tuple<Glib::ustring, bool> getToolTip (int x, int y) const;
inline ThumbBrowserEntryBase* getOriginal() const
{