Re: Tooltips progress

On Thu, 1 Jun 2006, Michael Natterer wrote:

On Wed, 2006-05-31 at 22:08 +0200, Kristian Rietveld wrote:

Currently, we are using the following query-tooltips signal:

  gboolean (*query_tooltip)     (GtkWidget           *widget,
                                 gint                 x,
                                 gint                 y,
                                 GtkTooltip          *tooltip);

But if a user sets a custom using gtk_widget_set_custom_window(), we don't
have to pass a GtkTooltip around.  So currently I just set the tooltip
field to NULL, so the user knows he has to use his own custom tooltip
window (and we assume he has a reference to that).  Is this okay or do
we want to change this?  We could also move the _set_custom_window()
functions into GtkTooltip for example.

I would very much appreciate if the GtkTooltip object also kept track
of the custom window. IMHO it makes no sense to handle this differently.

the widget is meant to do that:
void            gtk_widget_set_tooltip_window   (GtkWidget      *widget,
                                                 GtkWindow      *custom_window);
GtkWindow*      gtk_widget_get_tooltip_window   (GtkWidget      *widget);
for reasons outlined in a previous reply from me to kris.

gtk_tooltip_set_markup() vs. gtk_tooltip_set_window()

simply feels much better than the asymmetry in

gtk_tooltip_set_markup() vs. gtk_widget_set_tooltip_window()

well, you'd not use GtkTooltip at all if you used gtk_widget_set_tooltip_window() before. in that way,
the "asymmetry" simply reflects your usage.

The current approach even limits the new tooltip system's use cases,
since you have to set the custom window *outside* the callback. There
is no way to decide *in* the callback if a standard tooltip is
sufficient, or if a custom window is needed.

i don't think it'd be clear that/if the custom window will be available
in the GtkTooltip object again upon the next ::query-tooltip()
emission. especially since users are not supposed to access GtkTooltip
objects/structures in anyway *outside* of ::query-tooltip(), as outlined

also, passing GtkTooltip as NULL is meant to be as a clear indication
that the user has to tinker with gtk_widget_get_tooltip_window()
instead of the tooltip object. this avoids ambiguities like:

static gboolean
query_tooltip (GtkWidget           *widget,
               gint                 x,
               gint                 y,
               GtkTooltip          *tooltip)
  gtk_tooltip_set_markup (tooltip, "See Me?");
  g_object_new (GTK_TYPE_BUTTON,
                "parent", gtk_widget_get_tooltip_window(),
                "label", "Can You Click Me?",
  gtk_tooltip_set_icon (tooltip, messup_pixbuf);

what's the tooltip code supposed to do here?

and yes, the API basically enforces that you decide per widget if
an own tooltip window is needed or not. but i don't think that is
a strong limitation, we have been discussing usage cases quite some
in thise thread and nothing required to defer this decision into
the callback (and no existing tooltip code i know of requires this
so giving the benefits in API (and implementation) this provides,
i think it is a reasonable limitation to make.

Another problem is the assymetry in getting the relevant data to the
callback. With markup, the GtkTooltip can be queried for the markup,
if it's a custom window, you have to get it to the callback somehow.

Kris just forgot the getter for the custom window on the widget,
so signal handler user_data is left alone.

In your example code it's passed as user_data, but user_data is
often not available since it's needed for other things, so you
have to add a "GtkWidget *tooltip_window" to the "other thing".
If "other thing" is e.g. the application toplevel window, which
of the sub-widget's tooltips should it keep? All of them? People
will in many cases end up attaching the tooltip window to the

I also fail to see why the "has-tooltip" property has to be
set to TRUE, even tho a tooltip window was set on the widget.

i think this can be come by if we implement:
- gtk_widget_set_tooltip_window() should automatically set:
  GtkWidget::has-tooltip = (custom_window != NULL ||
                            GtkWidget::tooltip-markup != "");
- setting GtkWidget::tooltip-markup should automatically set:
  GtkWidget::has-tooltip = (custom_window != NULL ||
                            GtkWidget::tooltip-markup != "");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]