From 49ce5c2aa5f1a954789d622e2d0ccb5bd3b8407e Mon Sep 17 00:00:00 2001 From: Jehan Date: Sat, 24 Aug 2024 23:03:04 +0200 Subject: [PATCH] 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. --- app/actions/dashboard-commands.c | 2 +- app/actions/error-console-commands.c | 2 +- app/actions/gradients-commands.c | 2 +- app/display/gimpdisplayshell.c | 2 +- app/widgets/gimpdockbook.c | 2 +- app/widgets/gimpdockwindow.c | 2 +- app/widgets/gimpfiledialog.c | 2 +- app/widgets/gimpitemtreeview.c | 20 +++----------------- app/widgets/gimplayertreeview.c | 4 ++-- app/widgets/gimpmenu.c | 2 +- app/widgets/gimpsettingsbox.c | 2 +- app/widgets/gimptoolbox.c | 2 +- libgimpwidgets/gimpdialog.c | 2 +- libgimpwidgets/gimphelpui.c | 12 ++++++++++-- libgimpwidgets/gimphelpui.h | 1 + plug-ins/common/animation-play.c | 2 +- plug-ins/common/unit-editor.c | 2 +- plug-ins/imagemap/imap_main.c | 2 +- plug-ins/print/print-page-layout.c | 2 +- 19 files changed, 31 insertions(+), 36 deletions(-) diff --git a/app/actions/dashboard-commands.c b/app/actions/dashboard-commands.c index fa902fb769..f4a995a3ea 100644 --- a/app/actions/dashboard-commands.c +++ b/app/actions/dashboard-commands.c @@ -248,7 +248,7 @@ dashboard_log_record_cmd_callback (GimpAction *action, G_CALLBACK (gtk_true), 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); dialogs_attach_dialog (G_OBJECT (dashboard), LOG_RECORD_KEY, dialog); diff --git a/app/actions/error-console-commands.c b/app/actions/error-console-commands.c index 0612051784..fa983b0d88 100644 --- a/app/actions/error-console-commands.c +++ b/app/actions/error-console-commands.c @@ -128,7 +128,7 @@ error_console_save_cmd_callback (GimpAction *action, G_CALLBACK (gtk_true), NULL); - gimp_help_connect (dialog, gimp_standard_help_func, + gimp_help_connect (dialog, NULL, gimp_standard_help_func, GIMP_HELP_ERRORS_DIALOG, NULL, NULL); } diff --git a/app/actions/gradients-commands.c b/app/actions/gradients-commands.c index b5011170e9..09a8ed057c 100644 --- a/app/actions/gradients-commands.c +++ b/app/actions/gradients-commands.c @@ -112,7 +112,7 @@ gradients_save_as_pov_ray_cmd_callback (GimpAction *action, g_object_ref (gradient), 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); dialogs_attach_dialog (G_OBJECT (gradient), diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 201f77efca..e4fc112e20 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -429,7 +429,7 @@ gimp_display_shell_init (GimpDisplayShell *shell) G_CALLBACK (gimp_display_shell_events), 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); } diff --git a/app/widgets/gimpdockbook.c b/app/widgets/gimpdockbook.c index 4572fe9eb3..97fb67fad4 100644 --- a/app/widgets/gimpdockbook.c +++ b/app/widgets/gimpdockbook.c @@ -663,7 +663,7 @@ gimp_dockbook_new (GimpMenuFactory *menu_factory) "", 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); return GTK_WIDGET (dockbook); diff --git a/app/widgets/gimpdockwindow.c b/app/widgets/gimpdockwindow.c index ea3c8e7172..a78e1f7b4b 100644 --- a/app/widgets/gimpdockwindow.c +++ b/app/widgets/gimpdockwindow.c @@ -451,7 +451,7 @@ gimp_dock_window_constructed (GObject *object) "context", dock_window->p->context, 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); if (dock_window->p->auto_follow_active) diff --git a/app/widgets/gimpfiledialog.c b/app/widgets/gimpfiledialog.c index 89ec87dd7c..2f1c69eb7c 100644 --- a/app/widgets/gimpfiledialog.c +++ b/app/widgets/gimpfiledialog.c @@ -349,7 +349,7 @@ gimp_file_dialog_constructed (GObject *object) 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, dialog, NULL); diff --git a/app/widgets/gimpitemtreeview.c b/app/widgets/gimpitemtreeview.c index c1279a8a82..8bd6e281c6 100644 --- a/app/widgets/gimpitemtreeview.c +++ b/app/widgets/gimpitemtreeview.c @@ -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_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 */ item_view->priv->effects_visible_button = gtk_toggle_button_new (); 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, GTK_ICON_SIZE_SMALL_TOOLBAR); 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, _("Toggle the visibility of all filters."), GIMP_HELP_LAYER_EFFECTS); @@ -797,8 +792,6 @@ gimp_item_tree_view_constructed (GObject *object) item_view->priv->effects_edit_button = gtk_button_new_from_icon_name (GIMP_ICON_EDIT, 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, _("Edit the selected filter."), GIMP_HELP_LAYER_EFFECTS); @@ -812,8 +805,6 @@ gimp_item_tree_view_constructed (GObject *object) item_view->priv->effects_raise_button = gtk_button_new_from_icon_name (GIMP_ICON_GO_UP, 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, _("Raise filter one step up in the stack."), GIMP_HELP_LAYER_EFFECTS); @@ -827,8 +818,6 @@ gimp_item_tree_view_constructed (GObject *object) item_view->priv->effects_lower_button = gtk_button_new_from_icon_name (GIMP_ICON_GO_DOWN, 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, _("Lower filter one step down in the stack."), GIMP_HELP_LAYER_EFFECTS); @@ -842,8 +831,6 @@ gimp_item_tree_view_constructed (GObject *object) item_view->priv->effects_merge_button = gtk_button_new_from_icon_name (GIMP_ICON_LAYER_MERGE_DOWN, 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, _("Merge all active filters down."), GIMP_HELP_LAYER_EFFECTS); @@ -857,8 +844,6 @@ gimp_item_tree_view_constructed (GObject *object) item_view->priv->effects_remove_button = gtk_button_new_from_icon_name (GIMP_ICON_EDIT_DELETE, 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, _("Remove the selected filter."), 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_container_add (GTK_CONTAINER (item_view->priv->effects_popover), 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, FALSE, FALSE, 0); 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), view); - gimp_help_connect (toggle, gimp_standard_help_func, help_id, NULL, NULL); - gimp_help_set_help_data (toggle, tooltip, help_id); + gimp_help_connect (toggle, tooltip, gimp_standard_help_func, help_id, NULL, NULL); gtk_widget_style_get (GTK_WIDGET (view), "button-icon-size", &icon_size, diff --git a/app/widgets/gimplayertreeview.c b/app/widgets/gimplayertreeview.c index 1687727629..93a0124275 100644 --- a/app/widgets/gimplayertreeview.c +++ b/app/widgets/gimplayertreeview.c @@ -285,7 +285,7 @@ gimp_layer_tree_view_init (GimpLayerTreeView *view) g_signal_connect (view->priv->layer_mode_box, "notify::layer-mode", G_CALLBACK (gimp_layer_tree_view_layer_mode_box_callback), 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); /* Opacity scale */ @@ -294,7 +294,7 @@ gimp_layer_tree_view_init (GimpLayerTreeView *view) 1.0, 10.0, 0.0); scale = gimp_spin_scale_new (view->priv->opacity_adjustment, _("Opacity"), 1); 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_item_tree_view_add_options (GIMP_ITEM_TREE_VIEW (view), NULL, scale); diff --git a/app/widgets/gimpmenu.c b/app/widgets/gimpmenu.c index 349a5e60dc..7f11546087 100644 --- a/app/widgets/gimpmenu.c +++ b/app/widgets/gimpmenu.c @@ -154,7 +154,7 @@ gimp_menu_init (GimpMenu *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); } diff --git a/app/widgets/gimpsettingsbox.c b/app/widgets/gimpsettingsbox.c index 21a5bf3998..f0d845fc82 100644 --- a/app/widgets/gimpsettingsbox.c +++ b/app/widgets/gimpsettingsbox.c @@ -778,7 +778,7 @@ gimp_settings_box_file_dialog (GimpSettingsBox *box, gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog), 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); /* allow callbacks to add widgets to the dialog */ diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c index 7c8c73298e..e809c0566c 100644 --- a/app/widgets/gimptoolbox.c +++ b/app/widgets/gimptoolbox.c @@ -185,7 +185,7 @@ gimp_toolbox_init (GimpToolbox *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); } diff --git a/libgimpwidgets/gimpdialog.c b/libgimpwidgets/gimpdialog.c index 0c16806966..da6004f123 100644 --- a/libgimpwidgets/gimpdialog.c +++ b/libgimpwidgets/gimpdialog.c @@ -186,7 +186,7 @@ gimp_dialog_constructed (GObject *object) G_OBJECT_CLASS (parent_class)->constructed (object); if (private->help_func) - gimp_help_connect (GTK_WIDGET (object), + gimp_help_connect (GTK_WIDGET (object), NULL, private->help_func, private->help_id, object, NULL); diff --git a/libgimpwidgets/gimphelpui.c b/libgimpwidgets/gimphelpui.c index a1800f3c71..df36b0eb9c 100644 --- a/libgimpwidgets/gimphelpui.c +++ b/libgimpwidgets/gimphelpui.c @@ -105,6 +105,8 @@ gimp_standard_help_func (const gchar *help_id, * gimp_help_connect: * @widget: The widget you want to connect the help accelerator for. * 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_id: The @help_id 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 * constructors. You only have to call it for windows/dialogs you created * "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 gimp_help_connect (GtkWidget *widget, + const gchar *tooltip, GimpHelpFunc help_func, const gchar *help_id, gpointer help_data, @@ -147,7 +155,7 @@ gimp_help_connect (GtkWidget *widget, 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", help_data, help_data_destroy); @@ -162,7 +170,7 @@ gimp_help_connect (GtkWidget *widget, /** * gimp_help_set_help_data: * @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. * * The reason why we don't use gtk_widget_set_tooltip_text() is that diff --git a/libgimpwidgets/gimphelpui.h b/libgimpwidgets/gimphelpui.h index a1313a10f2..db3f33dc1b 100644 --- a/libgimpwidgets/gimphelpui.h +++ b/libgimpwidgets/gimphelpui.h @@ -38,6 +38,7 @@ void gimp_standard_help_func (const gchar *help_id, /* connect the help callback of a window */ void gimp_help_connect (GtkWidget *widget, + const gchar *tooltip, GimpHelpFunc help_func, const gchar *help_id, gpointer help_data, diff --git a/plug-ins/common/animation-play.c b/plug-ins/common/animation-play.c index e5542c51d9..b0c34044a1 100644 --- a/plug-ins/common/animation-play.c +++ b/plug-ins/common/animation-play.c @@ -757,7 +757,7 @@ build_dialog (GimpPlay *play, ACTIONS, G_N_ELEMENTS (ACTIONS), 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); gtk_container_add (GTK_CONTAINER (window), main_vbox); diff --git a/plug-ins/common/unit-editor.c b/plug-ins/common/unit-editor.c index aeb249393f..b9968cf46f 100644 --- a/plug-ins/common/unit-editor.c +++ b/plug-ins/common/unit-editor.c @@ -221,7 +221,7 @@ on_app_activate (GApplication *gapp, gpointer user_data) self->window = GTK_WINDOW (gtk_application_window_new (self->app)); gtk_window_set_title (self->window, _("Unit Editor")); 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, self->window, NULL); diff --git a/plug-ins/imagemap/imap_main.c b/plug-ins/imagemap/imap_main.c index 0d3b3e5179..22a557661b 100644 --- a/plug-ins/imagemap/imap_main.c +++ b/plug-ins/imagemap/imap_main.c @@ -1487,7 +1487,7 @@ dialog (GimpImap *imap) gtk_window_set_resizable (GTK_WINDOW (imap->dlg), TRUE); 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); diff --git a/plug-ins/print/print-page-layout.c b/plug-ins/print/print-page-layout.c index 0d5122d6f5..01412646f9 100644 --- a/plug-ins/print/print-page-layout.c +++ b/plug-ins/print/print-page-layout.c @@ -200,7 +200,7 @@ print_page_layout_gui (PrintData *data, G_CALLBACK (update_custom_widget), 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; }