app: list all tool-group tools in tool-button tooltip
In tool-group GimpToolButton tooltips, in addition to showing the
description of the currently-active tool, list the other tools in
the group as well, to improve discoverability.
(cherry picked from commit 4d83c7a3fc
)
This commit is contained in:
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
#include "actions/tools-commands.h"
|
#include "actions/tools-commands.h"
|
||||||
|
|
||||||
|
#include "gimpaccellabel.h"
|
||||||
#include "gimpaction.h"
|
#include "gimpaction.h"
|
||||||
#include "gimpdock.h"
|
#include "gimpdock.h"
|
||||||
#include "gimptoolbox.h"
|
#include "gimptoolbox.h"
|
||||||
@ -48,6 +49,8 @@
|
|||||||
#include "gimpwidgets-utils.h"
|
#include "gimpwidgets-utils.h"
|
||||||
#include "gimpwindowstrategy.h"
|
#include "gimpwindowstrategy.h"
|
||||||
|
|
||||||
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
#define ARROW_SIZE 0.125 /* * 100% */
|
#define ARROW_SIZE 0.125 /* * 100% */
|
||||||
#define ARROW_BORDER 3 /* px */
|
#define ARROW_BORDER 3 /* px */
|
||||||
@ -72,6 +75,8 @@ struct _GimpToolButtonPrivate
|
|||||||
|
|
||||||
GtkWidget *palette;
|
GtkWidget *palette;
|
||||||
|
|
||||||
|
GtkWidget *tooltip_widget;
|
||||||
|
|
||||||
GtkWidget *menu;
|
GtkWidget *menu;
|
||||||
GHashTable *menu_items;
|
GHashTable *menu_items;
|
||||||
gint menu_idle_id;
|
gint menu_idle_id;
|
||||||
@ -99,6 +104,11 @@ static void gimp_tool_button_hierarchy_changed (GtkWidget *w
|
|||||||
GtkWidget *previous_toplevel);
|
GtkWidget *previous_toplevel);
|
||||||
static gboolean gimp_tool_button_expose (GtkWidget *widget,
|
static gboolean gimp_tool_button_expose (GtkWidget *widget,
|
||||||
GdkEventExpose *event);
|
GdkEventExpose *event);
|
||||||
|
static gboolean gimp_tool_button_query_tooltip (GtkWidget *widget,
|
||||||
|
gint x,
|
||||||
|
gint y,
|
||||||
|
gboolean keyboard_mode,
|
||||||
|
GtkTooltip *tooltip);
|
||||||
|
|
||||||
static void gimp_tool_button_toggled (GtkToggleToolButton *toggle_tool_button);
|
static void gimp_tool_button_toggled (GtkToggleToolButton *toggle_tool_button);
|
||||||
|
|
||||||
@ -194,6 +204,7 @@ gimp_tool_button_class_init (GimpToolButtonClass *klass)
|
|||||||
|
|
||||||
widget_class->hierarchy_changed = gimp_tool_button_hierarchy_changed;
|
widget_class->hierarchy_changed = gimp_tool_button_hierarchy_changed;
|
||||||
widget_class->expose_event = gimp_tool_button_expose;
|
widget_class->expose_event = gimp_tool_button_expose;
|
||||||
|
widget_class->query_tooltip = gimp_tool_button_query_tooltip;
|
||||||
|
|
||||||
toggle_tool_button_class->toggled = gimp_tool_button_toggled;
|
toggle_tool_button_class->toggled = gimp_tool_button_toggled;
|
||||||
|
|
||||||
@ -434,6 +445,201 @@ gimp_tool_button_expose (GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
gimp_tool_button_query_tooltip_add_tool (GimpToolButton *tool_button,
|
||||||
|
GtkTable *table,
|
||||||
|
gint row,
|
||||||
|
GimpToolInfo *tool_info,
|
||||||
|
const gchar *label_str,
|
||||||
|
GtkIconSize icon_size)
|
||||||
|
{
|
||||||
|
GimpUIManager *ui_manager;
|
||||||
|
GimpAction *action = NULL;
|
||||||
|
GtkWidget *label;
|
||||||
|
GtkWidget *image;
|
||||||
|
|
||||||
|
ui_manager = gimp_dock_get_ui_manager (
|
||||||
|
GIMP_DOCK (tool_button->priv->toolbox));
|
||||||
|
|
||||||
|
if (ui_manager)
|
||||||
|
{
|
||||||
|
gchar *name;
|
||||||
|
|
||||||
|
name = gimp_tool_info_get_action_name (tool_info);
|
||||||
|
|
||||||
|
action = gimp_ui_manager_find_action (ui_manager, "tools", name);
|
||||||
|
|
||||||
|
g_free (name);
|
||||||
|
}
|
||||||
|
|
||||||
|
image = gtk_image_new_from_icon_name (
|
||||||
|
gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info)),
|
||||||
|
icon_size);
|
||||||
|
gtk_table_attach (table,
|
||||||
|
image,
|
||||||
|
0, 1,
|
||||||
|
row, row + 1,
|
||||||
|
GTK_FILL, 0,
|
||||||
|
0, 0);
|
||||||
|
gtk_widget_show (image);
|
||||||
|
|
||||||
|
label = gtk_label_new (label_str);
|
||||||
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||||
|
gtk_table_attach (table,
|
||||||
|
label,
|
||||||
|
1, 2,
|
||||||
|
row, row + 1,
|
||||||
|
GTK_EXPAND | GTK_FILL, 0,
|
||||||
|
0, 0);
|
||||||
|
gtk_widget_show (label);
|
||||||
|
|
||||||
|
if (action)
|
||||||
|
{
|
||||||
|
GtkWidget *accel_label;
|
||||||
|
|
||||||
|
accel_label = gimp_accel_label_new (action);
|
||||||
|
gtk_label_set_xalign (GTK_LABEL (accel_label), 1.0);
|
||||||
|
gtk_table_attach (table,
|
||||||
|
accel_label,
|
||||||
|
2, 3,
|
||||||
|
row, row + 1,
|
||||||
|
GTK_FILL, 0,
|
||||||
|
0, 0);
|
||||||
|
gtk_widget_show (accel_label);
|
||||||
|
}
|
||||||
|
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gimp_tool_button_query_tooltip (GtkWidget *widget,
|
||||||
|
gint x,
|
||||||
|
gint y,
|
||||||
|
gboolean keyboard_mode,
|
||||||
|
GtkTooltip *tooltip)
|
||||||
|
{
|
||||||
|
GimpToolButton *tool_button = GIMP_TOOL_BUTTON (widget);
|
||||||
|
|
||||||
|
if (! tool_button->priv->tooltip_widget)
|
||||||
|
{
|
||||||
|
GimpToolInfo *tool_info;
|
||||||
|
GtkWidget *table;
|
||||||
|
GtkWidget *label;
|
||||||
|
gchar **tooltip_labels;
|
||||||
|
GtkIconSize icon_size = GTK_ICON_SIZE_MENU;
|
||||||
|
gint row = 0;
|
||||||
|
|
||||||
|
tool_info = gimp_tool_button_get_tool_info (tool_button);
|
||||||
|
|
||||||
|
if (! tool_info)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (tool_button->priv->palette)
|
||||||
|
{
|
||||||
|
icon_size = gtk_tool_palette_get_icon_size (
|
||||||
|
GTK_TOOL_PALETTE (tool_button->priv->palette));
|
||||||
|
}
|
||||||
|
|
||||||
|
table = gtk_table_new (2, 3, FALSE);
|
||||||
|
gtk_table_set_row_spacings (GTK_TABLE (table), 4);
|
||||||
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
||||||
|
gtk_table_set_col_spacing (GTK_TABLE (table), 1, 32);
|
||||||
|
gtk_widget_show (table);
|
||||||
|
|
||||||
|
tool_button->priv->tooltip_widget = g_object_ref_sink (table);
|
||||||
|
|
||||||
|
tooltip_labels = g_strsplit (tool_info->tooltip, ": ", 2);
|
||||||
|
|
||||||
|
label = gimp_tool_button_query_tooltip_add_tool (tool_button,
|
||||||
|
GTK_TABLE (table),
|
||||||
|
row++,
|
||||||
|
tool_info,
|
||||||
|
tooltip_labels[0],
|
||||||
|
icon_size);
|
||||||
|
gimp_label_set_attributes (GTK_LABEL (label),
|
||||||
|
PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
if (tooltip_labels[0])
|
||||||
|
{
|
||||||
|
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 0);
|
||||||
|
|
||||||
|
label = gtk_label_new (tooltip_labels[1]);
|
||||||
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||||
|
gtk_table_attach (GTK_TABLE (table),
|
||||||
|
label,
|
||||||
|
1, 2,
|
||||||
|
row, row + 1,
|
||||||
|
GTK_FILL | GTK_EXPAND, 0,
|
||||||
|
0, 0);
|
||||||
|
gtk_widget_show (label);
|
||||||
|
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_strfreev (tooltip_labels);
|
||||||
|
|
||||||
|
if (GIMP_IS_TOOL_GROUP (tool_button->priv->tool_item))
|
||||||
|
{
|
||||||
|
GimpContainer *children;
|
||||||
|
gint n_children;
|
||||||
|
|
||||||
|
children = gimp_viewable_get_children (
|
||||||
|
GIMP_VIEWABLE (tool_button->priv->tool_item));
|
||||||
|
|
||||||
|
n_children = gimp_container_get_n_children (children);
|
||||||
|
|
||||||
|
if (n_children > 1)
|
||||||
|
{
|
||||||
|
GtkWidget *label;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
gtk_table_resize (GTK_TABLE (table), row + n_children, 3);
|
||||||
|
|
||||||
|
gtk_table_set_row_spacing (GTK_TABLE (table), 1, 12);
|
||||||
|
|
||||||
|
label = gtk_label_new (_("Also in group:"));
|
||||||
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
||||||
|
gimp_label_set_attributes (GTK_LABEL (label),
|
||||||
|
PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
|
||||||
|
-1);
|
||||||
|
gtk_table_attach (GTK_TABLE (table),
|
||||||
|
label,
|
||||||
|
0, 3,
|
||||||
|
row, row + 1,
|
||||||
|
GTK_FILL | GTK_EXPAND, 0,
|
||||||
|
0, 0);
|
||||||
|
gtk_widget_show (label);
|
||||||
|
|
||||||
|
row++;
|
||||||
|
|
||||||
|
for (i = 0; i < n_children; i++)
|
||||||
|
{
|
||||||
|
GimpToolInfo *other_tool_info;
|
||||||
|
|
||||||
|
other_tool_info = GIMP_TOOL_INFO (
|
||||||
|
gimp_container_get_child_by_index (children, i));
|
||||||
|
|
||||||
|
if (other_tool_info != tool_info)
|
||||||
|
{
|
||||||
|
gimp_tool_button_query_tooltip_add_tool (
|
||||||
|
tool_button,
|
||||||
|
GTK_TABLE (table),
|
||||||
|
row++,
|
||||||
|
other_tool_info,
|
||||||
|
other_tool_info->label,
|
||||||
|
icon_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_tooltip_set_custom (tooltip, tool_button->priv->tooltip_widget);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_tool_button_toggled (GtkToggleToolButton *toggle_tool_button)
|
gimp_tool_button_toggled (GtkToggleToolButton *toggle_tool_button)
|
||||||
{
|
{
|
||||||
@ -666,6 +872,8 @@ gimp_tool_button_tool_add (GimpContainer *container,
|
|||||||
index = gimp_container_get_child_index (container, GIMP_OBJECT (tool_info));
|
index = gimp_container_get_child_index (container, GIMP_OBJECT (tool_info));
|
||||||
|
|
||||||
gimp_tool_button_add_menu_item (tool_button, tool_info, index);
|
gimp_tool_button_add_menu_item (tool_button, tool_info, index);
|
||||||
|
|
||||||
|
gimp_tool_button_update (tool_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -674,6 +882,8 @@ gimp_tool_button_tool_remove (GimpContainer *container,
|
|||||||
GimpToolButton *tool_button)
|
GimpToolButton *tool_button)
|
||||||
{
|
{
|
||||||
gimp_tool_button_remove_menu_item (tool_button, tool_info);
|
gimp_tool_button_remove_menu_item (tool_button, tool_info);
|
||||||
|
|
||||||
|
gimp_tool_button_update (tool_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -684,6 +894,8 @@ gimp_tool_button_tool_reorder (GimpContainer *container,
|
|||||||
{
|
{
|
||||||
gimp_tool_button_remove_menu_item (tool_button, tool_info);
|
gimp_tool_button_remove_menu_item (tool_button, tool_info);
|
||||||
gimp_tool_button_add_menu_item (tool_button, tool_info, new_index);
|
gimp_tool_button_add_menu_item (tool_button, tool_info, new_index);
|
||||||
|
|
||||||
|
gimp_tool_button_update (tool_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -692,6 +904,8 @@ gimp_tool_button_icon_size_notify (GtkToolPalette *palette,
|
|||||||
GimpToolButton *tool_button)
|
GimpToolButton *tool_button)
|
||||||
{
|
{
|
||||||
gimp_tool_button_reconstruct_menu (tool_button);
|
gimp_tool_button_reconstruct_menu (tool_button);
|
||||||
|
|
||||||
|
gimp_tool_button_update (tool_button);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -790,23 +1004,19 @@ static void
|
|||||||
gimp_tool_button_update (GimpToolButton *tool_button)
|
gimp_tool_button_update (GimpToolButton *tool_button)
|
||||||
{
|
{
|
||||||
GimpToolInfo *tool_info;
|
GimpToolInfo *tool_info;
|
||||||
GimpAction *action;
|
|
||||||
|
|
||||||
tool_info = gimp_tool_button_get_tool_info (tool_button);
|
tool_info = gimp_tool_button_get_tool_info (tool_button);
|
||||||
action = gimp_tool_button_get_action (tool_button, tool_info);
|
|
||||||
|
|
||||||
gtk_tool_button_set_icon_name (
|
gtk_tool_button_set_icon_name (
|
||||||
GTK_TOOL_BUTTON (tool_button),
|
GTK_TOOL_BUTTON (tool_button),
|
||||||
tool_info ? gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info)) :
|
tool_info ? gimp_viewable_get_icon_name (GIMP_VIEWABLE (tool_info)) :
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
g_clear_object (&tool_button->priv->tooltip_widget);
|
||||||
|
|
||||||
if (! tool_button->priv->menu || ! tool_button->priv->show_menu_on_hover)
|
if (! tool_button->priv->menu || ! tool_button->priv->show_menu_on_hover)
|
||||||
{
|
{
|
||||||
if (action)
|
if (tool_info)
|
||||||
{
|
|
||||||
gimp_widget_set_accel_help (GTK_WIDGET (tool_button), action);
|
|
||||||
}
|
|
||||||
else if (tool_info)
|
|
||||||
{
|
{
|
||||||
gimp_help_set_help_data (GTK_WIDGET (tool_button),
|
gimp_help_set_help_data (GTK_WIDGET (tool_button),
|
||||||
tool_info->tooltip, tool_info->help_id);
|
tool_info->tooltip, tool_info->help_id);
|
||||||
|
@ -622,6 +622,7 @@ app/widgets/gimptoolbox-color-area.c
|
|||||||
app/widgets/gimptoolbox-dnd.c
|
app/widgets/gimptoolbox-dnd.c
|
||||||
app/widgets/gimptoolbox-image-area.c
|
app/widgets/gimptoolbox-image-area.c
|
||||||
app/widgets/gimptoolbox-indicator-area.c
|
app/widgets/gimptoolbox-indicator-area.c
|
||||||
|
app/widgets/gimptoolbutton.c
|
||||||
app/widgets/gimptooleditor.c
|
app/widgets/gimptooleditor.c
|
||||||
app/widgets/gimptooloptionseditor.c
|
app/widgets/gimptooloptionseditor.c
|
||||||
app/widgets/gimptoolpalette.c
|
app/widgets/gimptoolpalette.c
|
||||||
|
Reference in New Issue
Block a user