app, libgimpwidgets, plug-ins: add `tooltip` arg to gimp_help_connect().

As Cheesequake noted in !1673, there may be cases where one would want
to run gimp_help_connect() while also setting a tooltip. So they also
run gimp_help_set_help_data(), even though the latter is implied by the
former. Worse, it makes the order matter too much because if you call
gimp_help_connect() after gimp_help_set_help_data(), the tooltip would
be removed.

Now the reason is that gimp_help_connect() was clearly made to be run on
windows whereas gimp_help_set_help_data() was for other widgets, which
usually don't need to react to F1. Yet the previous commit does add
F1-connect for the lock buttons, which kind of makes sense. So why not
just add this tooltip argument.

As a side fix, I am removing a bunch of gimp_help_connect() on each
button in the layers effect popover. Just run it once on the top
container.
This commit is contained in:
Jehan 2024-08-24 23:03:04 +02:00
parent aad228cfeb
commit 49ce5c2aa5
19 changed files with 31 additions and 36 deletions

View File

@ -248,7 +248,7 @@ dashboard_log_record_cmd_callback (GimpAction *action,
G_CALLBACK (gtk_true), G_CALLBACK (gtk_true),
NULL); NULL);
gimp_help_connect (dialog, gimp_standard_help_func, gimp_help_connect (dialog, NULL, gimp_standard_help_func,
GIMP_HELP_DASHBOARD_LOG_RECORD, NULL, NULL); GIMP_HELP_DASHBOARD_LOG_RECORD, NULL, NULL);
dialogs_attach_dialog (G_OBJECT (dashboard), LOG_RECORD_KEY, dialog); dialogs_attach_dialog (G_OBJECT (dashboard), LOG_RECORD_KEY, dialog);

View File

@ -128,7 +128,7 @@ error_console_save_cmd_callback (GimpAction *action,
G_CALLBACK (gtk_true), G_CALLBACK (gtk_true),
NULL); NULL);
gimp_help_connect (dialog, gimp_standard_help_func, gimp_help_connect (dialog, NULL, gimp_standard_help_func,
GIMP_HELP_ERRORS_DIALOG, NULL, NULL); GIMP_HELP_ERRORS_DIALOG, NULL, NULL);
} }

View File

@ -112,7 +112,7 @@ gradients_save_as_pov_ray_cmd_callback (GimpAction *action,
g_object_ref (gradient), g_object_ref (gradient),
G_CONNECT_SWAPPED); G_CONNECT_SWAPPED);
gimp_help_connect (dialog, gimp_standard_help_func, gimp_help_connect (dialog, NULL, gimp_standard_help_func,
GIMP_HELP_GRADIENT_SAVE_AS_POV, NULL, NULL); GIMP_HELP_GRADIENT_SAVE_AS_POV, NULL, NULL);
dialogs_attach_dialog (G_OBJECT (gradient), dialogs_attach_dialog (G_OBJECT (gradient),

View File

@ -429,7 +429,7 @@ gimp_display_shell_init (GimpDisplayShell *shell)
G_CALLBACK (gimp_display_shell_events), G_CALLBACK (gimp_display_shell_events),
shell); shell);
gimp_help_connect (GTK_WIDGET (shell), gimp_standard_help_func, gimp_help_connect (GTK_WIDGET (shell), NULL, gimp_standard_help_func,
GIMP_HELP_IMAGE_WINDOW, NULL, NULL); GIMP_HELP_IMAGE_WINDOW, NULL, NULL);
} }

View File

@ -663,7 +663,7 @@ gimp_dockbook_new (GimpMenuFactory *menu_factory)
"<Dockable>", "<Dockable>",
dockbook); dockbook);
gimp_help_connect (GTK_WIDGET (dockbook), gimp_dockbook_help_func, gimp_help_connect (GTK_WIDGET (dockbook), NULL, gimp_dockbook_help_func,
GIMP_HELP_DOCK, dockbook, NULL); GIMP_HELP_DOCK, dockbook, NULL);
return GTK_WIDGET (dockbook); return GTK_WIDGET (dockbook);

View File

@ -451,7 +451,7 @@ gimp_dock_window_constructed (GObject *object)
"context", dock_window->p->context, "context", dock_window->p->context,
NULL); NULL);
gimp_help_connect (GTK_WIDGET (dock_window), gimp_standard_help_func, gimp_help_connect (GTK_WIDGET (dock_window), NULL, gimp_standard_help_func,
GIMP_HELP_DOCK, NULL, NULL); GIMP_HELP_DOCK, NULL, NULL);
if (dock_window->p->auto_follow_active) if (dock_window->p->auto_follow_active)

View File

@ -349,7 +349,7 @@ gimp_file_dialog_constructed (GObject *object)
if (dialog->help_id) if (dialog->help_id)
{ {
gimp_help_connect (GTK_WIDGET (dialog), gimp_help_connect (GTK_WIDGET (dialog), NULL,
gimp_file_dialog_help_func, dialog->help_id, gimp_file_dialog_help_func, dialog->help_id,
dialog, NULL); dialog, NULL);

View File

@ -771,9 +771,6 @@ gimp_item_tree_view_constructed (GObject *object)
item_view->priv->effects_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, button_spacing); item_view->priv->effects_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, button_spacing);
item_view->priv->effects_options = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, button_spacing); item_view->priv->effects_options = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, button_spacing);
gimp_help_connect (item_view->priv->effects_filters, gimp_standard_help_func,
GIMP_HELP_LAYER_EFFECTS, NULL, NULL);
/* Effects Buttons */ /* Effects Buttons */
item_view->priv->effects_visible_button = gtk_toggle_button_new (); item_view->priv->effects_visible_button = gtk_toggle_button_new ();
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item_view->priv->effects_visible_button), gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item_view->priv->effects_visible_button),
@ -781,8 +778,6 @@ gimp_item_tree_view_constructed (GObject *object)
image = gtk_image_new_from_icon_name (GIMP_ICON_VISIBLE, image = gtk_image_new_from_icon_name (GIMP_ICON_VISIBLE,
GTK_ICON_SIZE_SMALL_TOOLBAR); GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_container_add (GTK_CONTAINER (item_view->priv->effects_visible_button), image); gtk_container_add (GTK_CONTAINER (item_view->priv->effects_visible_button), image);
gimp_help_connect (item_view->priv->effects_visible_button, gimp_standard_help_func,
GIMP_HELP_LAYER_EFFECTS, NULL, NULL);
gimp_help_set_help_data (item_view->priv->effects_visible_button, gimp_help_set_help_data (item_view->priv->effects_visible_button,
_("Toggle the visibility of all filters."), _("Toggle the visibility of all filters."),
GIMP_HELP_LAYER_EFFECTS); GIMP_HELP_LAYER_EFFECTS);
@ -797,8 +792,6 @@ gimp_item_tree_view_constructed (GObject *object)
item_view->priv->effects_edit_button = item_view->priv->effects_edit_button =
gtk_button_new_from_icon_name (GIMP_ICON_EDIT, gtk_button_new_from_icon_name (GIMP_ICON_EDIT,
GTK_ICON_SIZE_SMALL_TOOLBAR); GTK_ICON_SIZE_SMALL_TOOLBAR);
gimp_help_connect (item_view->priv->effects_edit_button, gimp_standard_help_func,
GIMP_HELP_LAYER_EFFECTS, NULL, NULL);
gimp_help_set_help_data (item_view->priv->effects_edit_button, gimp_help_set_help_data (item_view->priv->effects_edit_button,
_("Edit the selected filter."), _("Edit the selected filter."),
GIMP_HELP_LAYER_EFFECTS); GIMP_HELP_LAYER_EFFECTS);
@ -812,8 +805,6 @@ gimp_item_tree_view_constructed (GObject *object)
item_view->priv->effects_raise_button = item_view->priv->effects_raise_button =
gtk_button_new_from_icon_name (GIMP_ICON_GO_UP, gtk_button_new_from_icon_name (GIMP_ICON_GO_UP,
GTK_ICON_SIZE_SMALL_TOOLBAR); GTK_ICON_SIZE_SMALL_TOOLBAR);
gimp_help_connect (item_view->priv->effects_raise_button, gimp_standard_help_func,
GIMP_HELP_LAYER_EFFECTS, NULL, NULL);
gimp_help_set_help_data (item_view->priv->effects_raise_button, gimp_help_set_help_data (item_view->priv->effects_raise_button,
_("Raise filter one step up in the stack."), _("Raise filter one step up in the stack."),
GIMP_HELP_LAYER_EFFECTS); GIMP_HELP_LAYER_EFFECTS);
@ -827,8 +818,6 @@ gimp_item_tree_view_constructed (GObject *object)
item_view->priv->effects_lower_button = item_view->priv->effects_lower_button =
gtk_button_new_from_icon_name (GIMP_ICON_GO_DOWN, gtk_button_new_from_icon_name (GIMP_ICON_GO_DOWN,
GTK_ICON_SIZE_SMALL_TOOLBAR); GTK_ICON_SIZE_SMALL_TOOLBAR);
gimp_help_connect (item_view->priv->effects_lower_button, gimp_standard_help_func,
GIMP_HELP_LAYER_EFFECTS, NULL, NULL);
gimp_help_set_help_data (item_view->priv->effects_lower_button, gimp_help_set_help_data (item_view->priv->effects_lower_button,
_("Lower filter one step down in the stack."), _("Lower filter one step down in the stack."),
GIMP_HELP_LAYER_EFFECTS); GIMP_HELP_LAYER_EFFECTS);
@ -842,8 +831,6 @@ gimp_item_tree_view_constructed (GObject *object)
item_view->priv->effects_merge_button = item_view->priv->effects_merge_button =
gtk_button_new_from_icon_name (GIMP_ICON_LAYER_MERGE_DOWN, gtk_button_new_from_icon_name (GIMP_ICON_LAYER_MERGE_DOWN,
GTK_ICON_SIZE_SMALL_TOOLBAR); GTK_ICON_SIZE_SMALL_TOOLBAR);
gimp_help_connect (item_view->priv->effects_merge_button, gimp_standard_help_func,
GIMP_HELP_LAYER_EFFECTS, NULL, NULL);
gimp_help_set_help_data (item_view->priv->effects_merge_button, gimp_help_set_help_data (item_view->priv->effects_merge_button,
_("Merge all active filters down."), _("Merge all active filters down."),
GIMP_HELP_LAYER_EFFECTS); GIMP_HELP_LAYER_EFFECTS);
@ -857,8 +844,6 @@ gimp_item_tree_view_constructed (GObject *object)
item_view->priv->effects_remove_button = item_view->priv->effects_remove_button =
gtk_button_new_from_icon_name (GIMP_ICON_EDIT_DELETE, gtk_button_new_from_icon_name (GIMP_ICON_EDIT_DELETE,
GTK_ICON_SIZE_SMALL_TOOLBAR); GTK_ICON_SIZE_SMALL_TOOLBAR);
gimp_help_connect (item_view->priv->effects_remove_button, gimp_standard_help_func,
GIMP_HELP_LAYER_EFFECTS, NULL, NULL);
gimp_help_set_help_data (item_view->priv->effects_remove_button, gimp_help_set_help_data (item_view->priv->effects_remove_button,
_("Remove the selected filter."), _("Remove the selected filter."),
GIMP_HELP_LAYER_EFFECTS); GIMP_HELP_LAYER_EFFECTS);
@ -881,6 +866,8 @@ gimp_item_tree_view_constructed (GObject *object)
gtk_popover_set_modal (GTK_POPOVER (item_view->priv->effects_popover), TRUE); gtk_popover_set_modal (GTK_POPOVER (item_view->priv->effects_popover), TRUE);
gtk_container_add (GTK_CONTAINER (item_view->priv->effects_popover), gtk_container_add (GTK_CONTAINER (item_view->priv->effects_popover),
item_view->priv->effects_filters); item_view->priv->effects_filters);
gimp_help_connect (item_view->priv->effects_filters, NULL,
gimp_standard_help_func, GIMP_HELP_LAYER_EFFECTS, NULL, NULL);
gtk_box_pack_start (GTK_BOX (item_view->priv->effects_filters), label, gtk_box_pack_start (GTK_BOX (item_view->priv->effects_filters), label,
FALSE, FALSE, 0); FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (item_view->priv->effects_filters), gtk_box_pack_start (GTK_BOX (item_view->priv->effects_filters),
@ -1313,8 +1300,7 @@ gimp_item_tree_view_add_lock (GimpItemTreeView *view,
G_CALLBACK (gimp_item_tree_view_lock_button_release), G_CALLBACK (gimp_item_tree_view_lock_button_release),
view); view);
gimp_help_connect (toggle, gimp_standard_help_func, help_id, NULL, NULL); gimp_help_connect (toggle, tooltip, gimp_standard_help_func, help_id, NULL, NULL);
gimp_help_set_help_data (toggle, tooltip, help_id);
gtk_widget_style_get (GTK_WIDGET (view), gtk_widget_style_get (GTK_WIDGET (view),
"button-icon-size", &icon_size, "button-icon-size", &icon_size,

View File

@ -285,7 +285,7 @@ gimp_layer_tree_view_init (GimpLayerTreeView *view)
g_signal_connect (view->priv->layer_mode_box, "notify::layer-mode", g_signal_connect (view->priv->layer_mode_box, "notify::layer-mode",
G_CALLBACK (gimp_layer_tree_view_layer_mode_box_callback), G_CALLBACK (gimp_layer_tree_view_layer_mode_box_callback),
view); view);
gimp_help_connect (view->priv->layer_mode_box, gimp_standard_help_func, gimp_help_connect (view->priv->layer_mode_box, NULL, gimp_standard_help_func,
GIMP_HELP_LAYER_DIALOG_PAINT_MODE_MENU, NULL, NULL); GIMP_HELP_LAYER_DIALOG_PAINT_MODE_MENU, NULL, NULL);
/* Opacity scale */ /* Opacity scale */
@ -294,7 +294,7 @@ gimp_layer_tree_view_init (GimpLayerTreeView *view)
1.0, 10.0, 0.0); 1.0, 10.0, 0.0);
scale = gimp_spin_scale_new (view->priv->opacity_adjustment, _("Opacity"), 1); scale = gimp_spin_scale_new (view->priv->opacity_adjustment, _("Opacity"), 1);
gimp_spin_scale_set_constrain_drag (GIMP_SPIN_SCALE (scale), TRUE); gimp_spin_scale_set_constrain_drag (GIMP_SPIN_SCALE (scale), TRUE);
gimp_help_connect (scale, gimp_standard_help_func, gimp_help_connect (scale, NULL, gimp_standard_help_func,
GIMP_HELP_LAYER_DIALOG_OPACITY_SCALE, NULL, NULL); GIMP_HELP_LAYER_DIALOG_OPACITY_SCALE, NULL, NULL);
gimp_item_tree_view_add_options (GIMP_ITEM_TREE_VIEW (view), gimp_item_tree_view_add_options (GIMP_ITEM_TREE_VIEW (view),
NULL, scale); NULL, scale);

View File

@ -154,7 +154,7 @@ gimp_menu_init (GimpMenu *menu)
gimp_menu_shell_init (GIMP_MENU_SHELL (menu)); gimp_menu_shell_init (GIMP_MENU_SHELL (menu));
gimp_help_connect (GTK_WIDGET (menu), gimp_menu_help_fun, gimp_help_connect (GTK_WIDGET (menu), NULL, gimp_menu_help_fun,
GIMP_HELP_MAIN, menu, NULL); GIMP_HELP_MAIN, menu, NULL);
} }

View File

@ -778,7 +778,7 @@ gimp_settings_box_file_dialog (GimpSettingsBox *box,
gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog), gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog),
private->last_file, NULL); private->last_file, NULL);
gimp_help_connect (private->file_dialog, gimp_standard_help_func, gimp_help_connect (private->file_dialog, NULL, gimp_standard_help_func,
private->help_id, NULL, NULL); private->help_id, NULL, NULL);
/* allow callbacks to add widgets to the dialog */ /* allow callbacks to add widgets to the dialog */

View File

@ -185,7 +185,7 @@ gimp_toolbox_init (GimpToolbox *toolbox)
{ {
toolbox->p = gimp_toolbox_get_instance_private (toolbox); toolbox->p = gimp_toolbox_get_instance_private (toolbox);
gimp_help_connect (GTK_WIDGET (toolbox), gimp_standard_help_func, gimp_help_connect (GTK_WIDGET (toolbox), NULL, gimp_standard_help_func,
GIMP_HELP_TOOLBOX, NULL, NULL); GIMP_HELP_TOOLBOX, NULL, NULL);
} }

View File

@ -186,7 +186,7 @@ gimp_dialog_constructed (GObject *object)
G_OBJECT_CLASS (parent_class)->constructed (object); G_OBJECT_CLASS (parent_class)->constructed (object);
if (private->help_func) if (private->help_func)
gimp_help_connect (GTK_WIDGET (object), gimp_help_connect (GTK_WIDGET (object), NULL,
private->help_func, private->help_id, private->help_func, private->help_id,
object, NULL); object, NULL);

View File

@ -105,6 +105,8 @@ gimp_standard_help_func (const gchar *help_id,
* gimp_help_connect: * gimp_help_connect:
* @widget: The widget you want to connect the help accelerator for. * @widget: The widget you want to connect the help accelerator for.
* Will be a #GtkWindow in most cases. * Will be a #GtkWindow in most cases.
* @tooltip: (nullable): The text for this widget's tooltip. For windows, you
* usually want to set %NULL.
* @help_func: The function which will be called if the user presses "F1". * @help_func: The function which will be called if the user presses "F1".
* @help_id: The @help_id which will be passed to @help_func. * @help_id: The @help_id which will be passed to @help_func.
* @help_data: The @help_data pointer which will be passed to @help_func. * @help_data: The @help_data pointer which will be passed to @help_func.
@ -113,9 +115,15 @@ gimp_standard_help_func (const gchar *help_id,
* Note that this function is automatically called by all libgimp dialog * Note that this function is automatically called by all libgimp dialog
* constructors. You only have to call it for windows/dialogs you created * constructors. You only have to call it for windows/dialogs you created
* "manually". * "manually".
*
* Most of the time, what you want to call for non-windows widgets is
* simply [func@GimpUi.help_set_help_data]. Yet if you need to set up an
* @help_func, call `gimp_help_connect` instead. Note that `gimp_help_set_help_data`
* is implied, so you don't have to call it too.
**/ **/
void void
gimp_help_connect (GtkWidget *widget, gimp_help_connect (GtkWidget *widget,
const gchar *tooltip,
GimpHelpFunc help_func, GimpHelpFunc help_func,
const gchar *help_id, const gchar *help_id,
gpointer help_data, gpointer help_data,
@ -147,7 +155,7 @@ gimp_help_connect (GtkWidget *widget,
initialized = TRUE; initialized = TRUE;
} }
gimp_help_set_help_data (widget, NULL, help_id); gimp_help_set_help_data (widget, tooltip, help_id);
g_object_set_data_full (G_OBJECT (widget), "gimp-help-data", g_object_set_data_full (G_OBJECT (widget), "gimp-help-data",
help_data, help_data_destroy); help_data, help_data_destroy);
@ -162,7 +170,7 @@ gimp_help_connect (GtkWidget *widget,
/** /**
* gimp_help_set_help_data: * gimp_help_set_help_data:
* @widget: The #GtkWidget you want to set a @tooltip and/or @help_id for. * @widget: The #GtkWidget you want to set a @tooltip and/or @help_id for.
* @tooltip: The text for this widget's tooltip (or %NULL). * @tooltip: (nullable): The text for this widget's tooltip (or %NULL).
* @help_id: The @help_id for the #GtkTipsQuery tooltips inspector. * @help_id: The @help_id for the #GtkTipsQuery tooltips inspector.
* *
* The reason why we don't use gtk_widget_set_tooltip_text() is that * The reason why we don't use gtk_widget_set_tooltip_text() is that

View File

@ -38,6 +38,7 @@ void gimp_standard_help_func (const gchar *help_id,
/* connect the help callback of a window */ /* connect the help callback of a window */
void gimp_help_connect (GtkWidget *widget, void gimp_help_connect (GtkWidget *widget,
const gchar *tooltip,
GimpHelpFunc help_func, GimpHelpFunc help_func,
const gchar *help_id, const gchar *help_id,
gpointer help_data, gpointer help_data,

View File

@ -757,7 +757,7 @@ build_dialog (GimpPlay *play,
ACTIONS, G_N_ELEMENTS (ACTIONS), ACTIONS, G_N_ELEMENTS (ACTIONS),
play); play);
gimp_help_connect (window, gimp_standard_help_func, PLUG_IN_PROC, NULL, NULL); gimp_help_connect (window, NULL, gimp_standard_help_func, PLUG_IN_PROC, NULL, NULL);
main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), main_vbox); gtk_container_add (GTK_CONTAINER (window), main_vbox);

View File

@ -221,7 +221,7 @@ on_app_activate (GApplication *gapp, gpointer user_data)
self->window = GTK_WINDOW (gtk_application_window_new (self->app)); self->window = GTK_WINDOW (gtk_application_window_new (self->app));
gtk_window_set_title (self->window, _("Unit Editor")); gtk_window_set_title (self->window, _("Unit Editor"));
gtk_window_set_role (self->window, PLUG_IN_ROLE); gtk_window_set_role (self->window, PLUG_IN_ROLE);
gimp_help_connect (GTK_WIDGET (self->window), gimp_help_connect (GTK_WIDGET (self->window), NULL,
gimp_standard_help_func, PLUG_IN_PROC, gimp_standard_help_func, PLUG_IN_PROC,
self->window, NULL); self->window, NULL);

View File

@ -1487,7 +1487,7 @@ dialog (GimpImap *imap)
gtk_window_set_resizable (GTK_WINDOW (imap->dlg), TRUE); gtk_window_set_resizable (GTK_WINDOW (imap->dlg), TRUE);
main_set_title (NULL); main_set_title (NULL);
gimp_help_connect (imap->dlg, gimp_standard_help_func, PLUG_IN_PROC, NULL, NULL); gimp_help_connect (imap->dlg, NULL, gimp_standard_help_func, PLUG_IN_PROC, NULL, NULL);
gtk_window_set_position (GTK_WINDOW (imap->dlg), GTK_WIN_POS_MOUSE); gtk_window_set_position (GTK_WINDOW (imap->dlg), GTK_WIN_POS_MOUSE);

View File

@ -200,7 +200,7 @@ print_page_layout_gui (PrintData *data,
G_CALLBACK (update_custom_widget), G_CALLBACK (update_custom_widget),
main_hbox, 0); main_hbox, 0);
gimp_help_connect (main_hbox, gimp_standard_help_func, help, NULL, NULL); gimp_help_connect (main_hbox, NULL, gimp_standard_help_func, help, NULL, NULL);
return main_hbox; return main_hbox;
} }