Commit ec5cbbac authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

mis-named and mis-placed function that sets a widget's tooltip to the

2005-09-16  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpwidgets-utils.[ch] (gimp_widget_set_accel_help):
	mis-named and mis-placed function that sets a widget's tooltip to
	the action's tooltip plus the action's keyboard shortcut.

	* app/widgets/gimptoolbox.c: at least the code is not here any
	more.

	* app/actions/tools-actions.c: use tool_info->help, not ->blurb
	as the action's tooltip so the above works.
parent 2e0757fd
2005-09-16 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpwidgets-utils.[ch] (gimp_widget_set_accel_help):
mis-named and mis-placed function that sets a widget's tooltip to
the action's tooltip plus the action's keyboard shortcut.
* app/widgets/gimptoolbox.c: at least the code is not here any
more.
* app/actions/tools-actions.c: use tool_info->help, not ->blurb
as the action's tooltip so the above works.
2005-09-13 Karine Delvare <kdelvare@nerim.net>
* app/tools/gimpcroptool.c
......
......@@ -510,7 +510,7 @@ tools_actions_setup (GimpActionGroup *group)
entry.stock_id = stock_id;
entry.label = tool_info->menu_path;
entry.accelerator = tool_info->menu_accel;
entry.tooltip = tool_info->blurb;
entry.tooltip = tool_info->help;
entry.help_id = tool_info->help_id;
entry.value = identifier;
......
......@@ -585,59 +585,6 @@ gimp_toolbox_new (GimpDialogFactory *dialog_factory,
/* private functions */
static gboolean
gimp_toolbox_button_accel_find_func (GtkAccelKey *key,
GClosure *closure,
gpointer data)
{
return (GClosure *) data == closure;
}
static void
gimp_toolbox_button_accel_changed (GtkAccelGroup *accel_group,
guint unused1,
GdkModifierType unused2,
GClosure *accel_closure,
GtkWidget *tool_button)
{
GClosure *button_closure;
button_closure = g_object_get_data (G_OBJECT (tool_button),
"toolbox-accel-closure");
if (accel_closure == button_closure)
{
GimpToolInfo *tool_info;
GtkAccelKey *accel_key;
gchar *tooltip;
tool_info = g_object_get_data (G_OBJECT (tool_button), TOOL_INFO_DATA_KEY);
accel_key = gtk_accel_group_find (accel_group,
gimp_toolbox_button_accel_find_func,
accel_closure);
if (accel_key &&
accel_key->accel_key &&
accel_key->accel_flags & GTK_ACCEL_VISIBLE)
{
tooltip = g_strconcat (tool_info->help,
" ",
gimp_get_accel_string (accel_key->accel_key,
accel_key->accel_mods),
NULL);
}
else
{
tooltip = g_strdup (tool_info->help);
}
gimp_help_set_help_data (tool_button, tooltip, tool_info->help_id);
g_free (tooltip);
}
}
static void
toolbox_separator_expand (GimpToolbox *toolbox)
{
......@@ -730,7 +677,6 @@ toolbox_create_tools (GimpToolbox *toolbox,
const gchar *identifier;
gchar *tmp;
gchar *name;
GClosure *accel_closure = NULL;
identifier = gimp_object_get_name (GIMP_OBJECT (tool_info));
......@@ -744,32 +690,10 @@ toolbox_create_tools (GimpToolbox *toolbox,
g_free (name);
if (action)
accel_closure = gimp_action_get_accel_closure (action);
if (accel_closure)
{
GtkAccelGroup *accel_group;
g_object_set_data (G_OBJECT (button), "toolbox-accel-closure",
accel_closure);
accel_group =
gtk_accel_group_from_accel_closure (accel_closure);
g_signal_connect_object (accel_group, "accel-changed",
G_CALLBACK (gimp_toolbox_button_accel_changed),
button, 0);
gimp_toolbox_button_accel_changed (accel_group,
0, 0,
accel_closure,
button);
}
gimp_widget_set_accel_help (button, action);
else
{
gimp_help_set_help_data (button,
tool_info->help, tool_info->help_id);
}
gimp_help_set_help_data (button,
tool_info->help, tool_info->help_id);
}
}
......
......@@ -925,3 +925,103 @@ gimp_action_get_accel_closure (GtkAction *action)
return closure;
}
static gboolean
gimp_widget_accel_find_func (GtkAccelKey *key,
GClosure *closure,
gpointer data)
{
return (GClosure *) data == closure;
}
static void
gimp_widget_accel_changed (GtkAccelGroup *accel_group,
guint unused1,
GdkModifierType unused2,
GClosure *accel_closure,
GtkWidget *widget)
{
GClosure *widget_closure;
widget_closure = g_object_get_data (G_OBJECT (widget), "gimp-accel-closure");
if (accel_closure == widget_closure)
{
GtkAction *action;
GtkAccelKey *accel_key;
gchar *orig_tooltip;
gchar *tooltip;
const gchar *help_id;
action = g_object_get_data (G_OBJECT (widget), "gimp-accel-action");
g_object_get (action, "tooltip", &orig_tooltip, NULL);
help_id = g_object_get_qdata (G_OBJECT (action), GIMP_HELP_ID);
accel_key = gtk_accel_group_find (accel_group,
gimp_widget_accel_find_func,
accel_closure);
if (accel_key &&
accel_key->accel_key &&
accel_key->accel_flags & GTK_ACCEL_VISIBLE)
{
tooltip = g_strconcat (orig_tooltip,
" ",
gimp_get_accel_string (accel_key->accel_key,
accel_key->accel_mods),
NULL);
}
else
{
tooltip = g_strdup (orig_tooltip);
}
gimp_help_set_help_data (widget, tooltip, help_id);
g_free (tooltip);
g_free (orig_tooltip);
}
}
void
gimp_widget_set_accel_help (GtkWidget *widget,
GtkAction *action)
{
GClosure *accel_closure = NULL;
accel_closure = gimp_action_get_accel_closure (action);
if (accel_closure)
{
GtkAccelGroup *accel_group;
g_object_set_data (G_OBJECT (widget), "gimp-accel-closure",
accel_closure);
g_object_set_data (G_OBJECT (widget), "gimp-accel-action",
action);
accel_group = gtk_accel_group_from_accel_closure (accel_closure);
g_signal_connect_object (accel_group, "accel-changed",
G_CALLBACK (gimp_widget_accel_changed),
widget, 0);
gimp_widget_accel_changed (accel_group,
0, 0,
accel_closure,
widget);
}
else
{
gchar *tooltip;
gchar *help_id;
g_object_get (action, "tooltip", &tooltip, NULL);
help_id = g_object_get_qdata (G_OBJECT (tooltip), GIMP_HELP_ID);
gimp_help_set_help_data (widget, tooltip, help_id);
g_free (tooltip);
}
}
......@@ -85,5 +85,8 @@ void gimp_toggle_button_set_visible (GtkToggleButton *toggle,
GClosure * gimp_action_get_accel_closure (GtkAction *action);
void gimp_widget_set_accel_help (GtkWidget *widget,
GtkAction *action);
#endif /* __GIMP_WIDGETS_UTILS_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment