2000-02-26 11:41:06 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
2000-01-05 23:47:06 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimphelpui.c
|
2003-10-27 18:56:06 +08:00
|
|
|
* Copyright (C) 2000-2003 Michael Natterer <mitch@gimp.org>
|
2000-01-05 23:47:06 +08:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2000-02-26 11:41:06 +08:00
|
|
|
* version 2 of the License, or (at your option) any later version.
|
2003-08-24 03:35:05 +08:00
|
|
|
*
|
2000-02-26 11:41:06 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-08-24 03:35:05 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-01-05 23:47:06 +08:00
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2000-05-31 07:38:46 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2002-09-27 02:43:05 +08:00
|
|
|
#include <gtk/gtk.h>
|
2003-08-24 03:35:05 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2002-09-27 02:43:05 +08:00
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "gimpwidgetstypes.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2000-01-11 23:48:00 +08:00
|
|
|
#include "gimpdialog.h"
|
2000-01-05 23:47:06 +08:00
|
|
|
#include "gimphelpui.h"
|
2003-05-25 22:23:43 +08:00
|
|
|
#include "gimpwidgets-private.h"
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2000-01-07 06:26:10 +08:00
|
|
|
|
2001-08-01 07:28:56 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
2002-09-27 02:43:05 +08:00
|
|
|
GIMP_WIDGET_HELP_TYPE_HELP = 0xff
|
2001-08-01 07:28:56 +08:00
|
|
|
} GimpWidgetHelpType;
|
|
|
|
|
|
|
|
|
2007-11-09 19:17:00 +08:00
|
|
|
/* local variables */
|
|
|
|
|
|
|
|
static gboolean tooltips_enabled = TRUE;
|
|
|
|
static gboolean tooltips_enable_called = FALSE;
|
|
|
|
|
|
|
|
|
2000-01-05 23:47:06 +08:00
|
|
|
/* local function prototypes */
|
2002-09-27 02:43:05 +08:00
|
|
|
|
2004-03-10 21:13:44 +08:00
|
|
|
static const gchar * gimp_help_get_help_data (GtkWidget *widget,
|
|
|
|
GtkWidget **help_widget,
|
|
|
|
gpointer *ret_data);
|
|
|
|
static gboolean gimp_help_callback (GtkWidget *widget,
|
|
|
|
GimpWidgetHelpType help_type,
|
|
|
|
GimpHelpFunc help_func);
|
|
|
|
|
|
|
|
static gboolean gimp_context_help_idle_start (gpointer widget);
|
|
|
|
static gboolean gimp_context_help_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
gpointer data);
|
2005-12-08 04:36:13 +08:00
|
|
|
static gboolean gimp_context_help_key_press (GtkWidget *widget,
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
gpointer data);
|
2004-03-10 21:13:44 +08:00
|
|
|
static gboolean gimp_context_help_idle_show_help (gpointer data);
|
2001-08-01 07:28:56 +08:00
|
|
|
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2000-02-26 22:28:08 +08:00
|
|
|
/**
|
|
|
|
* gimp_help_enable_tooltips:
|
|
|
|
*
|
|
|
|
* This function calls gtk_tooltips_enable().
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-01-05 23:47:06 +08:00
|
|
|
void
|
|
|
|
gimp_help_enable_tooltips (void)
|
|
|
|
{
|
2007-11-09 19:17:00 +08:00
|
|
|
if (! tooltips_enable_called)
|
|
|
|
{
|
|
|
|
tooltips_enable_called = TRUE;
|
|
|
|
tooltips_enabled = TRUE;
|
|
|
|
}
|
2000-01-05 23:47:06 +08:00
|
|
|
}
|
|
|
|
|
2000-02-26 22:28:08 +08:00
|
|
|
/**
|
|
|
|
* gimp_help_disable_tooltips:
|
|
|
|
*
|
|
|
|
* This function calls gtk_tooltips_disable().
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-01-05 23:47:06 +08:00
|
|
|
void
|
|
|
|
gimp_help_disable_tooltips (void)
|
|
|
|
{
|
2007-11-09 19:17:00 +08:00
|
|
|
if (! tooltips_enable_called)
|
|
|
|
{
|
|
|
|
tooltips_enable_called = TRUE;
|
|
|
|
tooltips_enabled = FALSE;
|
|
|
|
}
|
2000-01-05 23:47:06 +08:00
|
|
|
}
|
|
|
|
|
2003-11-19 09:12:20 +08:00
|
|
|
/**
|
|
|
|
* gimp_standard_help_func:
|
|
|
|
* @help_id: A unique help identifier.
|
|
|
|
* @help_data: The @help_data passed to gimp_help_connect().
|
|
|
|
*
|
|
|
|
* This is the standard GIMP help function which does nothing but calling
|
|
|
|
* gimp_help(). It is the right function to use in almost all cases.
|
|
|
|
**/
|
2003-05-25 20:13:57 +08:00
|
|
|
void
|
2003-08-24 03:35:05 +08:00
|
|
|
gimp_standard_help_func (const gchar *help_id,
|
2003-11-19 09:12:20 +08:00
|
|
|
gpointer help_data)
|
2003-05-25 20:13:57 +08:00
|
|
|
{
|
2003-05-25 22:23:43 +08:00
|
|
|
if (! _gimp_standard_help_func)
|
2003-05-25 20:13:57 +08:00
|
|
|
{
|
2004-05-12 16:13:33 +08:00
|
|
|
g_warning ("%s: you must call gimp_widgets_init() before using "
|
|
|
|
"the help system", G_STRFUNC);
|
2003-05-25 20:13:57 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-11-19 09:12:20 +08:00
|
|
|
(* _gimp_standard_help_func) (help_id, help_data);
|
2003-05-25 20:13:57 +08:00
|
|
|
}
|
|
|
|
|
2000-02-26 22:28:08 +08:00
|
|
|
/**
|
2001-08-01 07:28:56 +08:00
|
|
|
* gimp_help_connect:
|
2000-02-26 22:28:08 +08:00
|
|
|
* @widget: The widget you want to connect the help accelerator for. Will
|
|
|
|
* be a #GtkWindow in most cases.
|
|
|
|
* @help_func: The function which will be called if the user presses "F1".
|
2003-11-19 09:12:20 +08:00
|
|
|
* @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.
|
2000-02-26 22:28:08 +08:00
|
|
|
*
|
2000-02-27 20:34:13 +08:00
|
|
|
* Note that this function is automatically called by all libgimp dialog
|
|
|
|
* constructors. You only have to call it for windows/dialogs you created
|
|
|
|
* "manually".
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-01-05 23:47:06 +08:00
|
|
|
void
|
2001-08-01 07:28:56 +08:00
|
|
|
gimp_help_connect (GtkWidget *widget,
|
2004-10-04 21:17:41 +08:00
|
|
|
GimpHelpFunc help_func,
|
|
|
|
const gchar *help_id,
|
2003-08-24 03:35:05 +08:00
|
|
|
gpointer help_data)
|
2000-01-05 23:47:06 +08:00
|
|
|
{
|
2003-10-27 18:56:06 +08:00
|
|
|
static gboolean initialized = FALSE;
|
|
|
|
|
2002-09-27 02:43:05 +08:00
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
g_return_if_fail (help_func != NULL);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2003-10-27 18:56:06 +08:00
|
|
|
/* set up the help signals
|
2000-11-18 08:25:42 +08:00
|
|
|
*/
|
2003-10-27 18:56:06 +08:00
|
|
|
if (! initialized)
|
2000-01-05 23:47:06 +08:00
|
|
|
{
|
2001-08-01 07:28:56 +08:00
|
|
|
GtkBindingSet *binding_set;
|
|
|
|
|
2002-09-27 02:43:05 +08:00
|
|
|
binding_set =
|
|
|
|
gtk_binding_set_by_class (g_type_class_peek (GTK_TYPE_WIDGET));
|
2001-08-01 07:28:56 +08:00
|
|
|
|
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_F1, 0,
|
2007-10-09 22:46:45 +08:00
|
|
|
"show-help", 1,
|
2004-10-04 21:17:41 +08:00
|
|
|
GTK_TYPE_WIDGET_HELP_TYPE,
|
|
|
|
GIMP_WIDGET_HELP_TYPE_HELP);
|
2001-08-01 07:28:56 +08:00
|
|
|
gtk_binding_entry_add_signal (binding_set, GDK_KP_F1, 0,
|
2007-10-09 22:46:45 +08:00
|
|
|
"show-help", 1,
|
2004-10-04 21:17:41 +08:00
|
|
|
GTK_TYPE_WIDGET_HELP_TYPE,
|
|
|
|
GIMP_WIDGET_HELP_TYPE_HELP);
|
2001-08-01 07:28:56 +08:00
|
|
|
|
2003-10-27 18:56:06 +08:00
|
|
|
initialized = TRUE;
|
2000-01-07 06:26:10 +08:00
|
|
|
}
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2003-08-24 03:35:05 +08:00
|
|
|
gimp_help_set_help_data (widget, NULL, help_id);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (widget), "gimp-help-data", help_data);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_connect (widget, "show-help",
|
2001-07-31 19:33:13 +08:00
|
|
|
G_CALLBACK (gimp_help_callback),
|
2001-08-01 07:28:56 +08:00
|
|
|
help_func);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
gtk_widget_add_events (widget, GDK_BUTTON_PRESS_MASK);
|
|
|
|
}
|
|
|
|
|
2000-02-26 22:28:08 +08:00
|
|
|
/**
|
|
|
|
* gimp_help_set_help_data:
|
2003-11-19 09:12:20 +08:00
|
|
|
* @widget: The #GtkWidget you want to set a @tooltip and/or @help_id for.
|
2003-02-07 05:17:12 +08:00
|
|
|
* @tooltip: The text for this widget's tooltip (or %NULL).
|
2003-08-24 03:35:05 +08:00
|
|
|
* @help_id: The @help_id for the #GtkTipsQuery tooltips inspector.
|
2000-02-26 22:28:08 +08:00
|
|
|
*
|
2008-03-28 17:37:12 +08:00
|
|
|
* The reason why we don't use gtk_widget_set_tooltip_text() is that
|
|
|
|
* elements in the GIMP user interface should, if possible, also have
|
|
|
|
* a @help_id set for context-sensitive help.
|
2000-02-27 20:34:13 +08:00
|
|
|
*
|
2003-11-19 09:12:20 +08:00
|
|
|
* This function can be called with #NULL for @tooltip. Use this feature
|
2003-08-24 03:35:05 +08:00
|
|
|
* if you want to set a help link for a widget which shouldn't have
|
2000-02-27 20:34:13 +08:00
|
|
|
* a visible tooltip.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-01-05 23:47:06 +08:00
|
|
|
void
|
2000-01-11 23:48:00 +08:00
|
|
|
gimp_help_set_help_data (GtkWidget *widget,
|
2004-10-04 21:17:41 +08:00
|
|
|
const gchar *tooltip,
|
|
|
|
const gchar *help_id)
|
2000-01-05 23:47:06 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
|
2007-11-22 21:59:06 +08:00
|
|
|
if (tooltips_enabled)
|
|
|
|
gtk_widget_set_tooltip_text (widget, tooltip);
|
|
|
|
|
|
|
|
g_object_set_qdata (G_OBJECT (widget), GIMP_HELP_ID, (gpointer) help_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_help_set_help_data_with_markup:
|
|
|
|
* @widget: The #GtkWidget you want to set a @tooltip and/or @help_id for.
|
|
|
|
* @tooltip: The markup for this widget's tooltip (or %NULL).
|
|
|
|
* @help_id: The @help_id for the #GtkTipsQuery tooltips inspector.
|
|
|
|
*
|
|
|
|
* Just like gimp_help_set_help_data(), but it allows to pass text which
|
|
|
|
* is marked up with
|
|
|
|
* <link linkend="PangoMarkupFormat">Pango text markup language</link>.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.6
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_help_set_help_data_with_markup (GtkWidget *widget,
|
|
|
|
const gchar *tooltip,
|
|
|
|
const gchar *help_id)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
|
2007-11-09 19:17:00 +08:00
|
|
|
if (tooltips_enabled)
|
|
|
|
gtk_widget_set_tooltip_markup (widget, tooltip);
|
2005-12-29 09:33:38 +08:00
|
|
|
|
2007-11-09 19:17:00 +08:00
|
|
|
g_object_set_qdata (G_OBJECT (widget), GIMP_HELP_ID, (gpointer) help_id);
|
2000-01-05 23:47:06 +08:00
|
|
|
}
|
|
|
|
|
2000-02-26 22:28:08 +08:00
|
|
|
/**
|
|
|
|
* gimp_context_help:
|
2003-10-27 18:56:06 +08:00
|
|
|
* @widget: Any #GtkWidget on the screen.
|
2000-02-26 22:28:08 +08:00
|
|
|
*
|
2003-10-27 18:56:06 +08:00
|
|
|
* This function invokes the context help inspector.
|
2000-02-27 20:34:13 +08:00
|
|
|
*
|
|
|
|
* The mouse cursor will turn turn into a question mark and the user can
|
|
|
|
* click on any widget of the application which started the inspector.
|
|
|
|
*
|
2003-08-24 03:35:05 +08:00
|
|
|
* If the widget the user clicked on has a @help_id string attached
|
|
|
|
* (see gimp_help_set_help_data()), the corresponding help page will
|
2000-02-27 20:34:13 +08:00
|
|
|
* be displayed. Otherwise the help system will ascend the widget hierarchy
|
2003-08-24 03:35:05 +08:00
|
|
|
* until it finds an attached @help_id string (which should be the
|
2000-02-27 20:34:13 +08:00
|
|
|
* case at least for every window/dialog).
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-01-05 23:47:06 +08:00
|
|
|
void
|
2003-10-27 18:56:06 +08:00
|
|
|
gimp_context_help (GtkWidget *widget)
|
2000-01-05 23:47:06 +08:00
|
|
|
{
|
2003-10-27 18:56:06 +08:00
|
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
|
|
|
|
|
|
|
gimp_help_callback (widget, GTK_WIDGET_HELP_WHATS_THIS, NULL);
|
2000-01-05 23:47:06 +08:00
|
|
|
}
|
|
|
|
|
2004-05-03 23:54:54 +08:00
|
|
|
/**
|
|
|
|
* gimp_help_id_quark:
|
|
|
|
*
|
|
|
|
* This function returns the #GQuark which should be used as key when
|
2004-07-09 05:41:39 +08:00
|
|
|
* attaching help IDs to widgets and objects.
|
2004-05-03 23:54:54 +08:00
|
|
|
*
|
|
|
|
* Return value: The #GQuark.
|
2004-05-05 09:15:46 +08:00
|
|
|
*
|
|
|
|
* Since: GIMP 2.2
|
2004-05-03 23:54:54 +08:00
|
|
|
**/
|
|
|
|
GQuark
|
|
|
|
gimp_help_id_quark (void)
|
|
|
|
{
|
|
|
|
static GQuark quark = 0;
|
|
|
|
|
|
|
|
if (! quark)
|
|
|
|
quark = g_quark_from_static_string ("gimp-help-id");
|
|
|
|
|
|
|
|
return quark;
|
|
|
|
}
|
|
|
|
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2002-09-27 02:43:05 +08:00
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static const gchar *
|
|
|
|
gimp_help_get_help_data (GtkWidget *widget,
|
2003-08-24 03:35:05 +08:00
|
|
|
GtkWidget **help_widget,
|
|
|
|
gpointer *ret_data)
|
2002-09-27 02:43:05 +08:00
|
|
|
{
|
2007-11-09 19:17:00 +08:00
|
|
|
gchar *help_id = NULL;
|
|
|
|
gpointer help_data = NULL;
|
2002-09-27 02:43:05 +08:00
|
|
|
|
|
|
|
for (; widget; widget = widget->parent)
|
|
|
|
{
|
2007-11-09 19:17:00 +08:00
|
|
|
help_id = g_object_get_qdata (G_OBJECT (widget), GIMP_HELP_ID);
|
2003-08-24 03:35:05 +08:00
|
|
|
help_data = g_object_get_data (G_OBJECT (widget), "gimp-help-data");
|
|
|
|
|
|
|
|
if (help_id)
|
2002-09-27 02:43:05 +08:00
|
|
|
{
|
|
|
|
if (help_widget)
|
|
|
|
*help_widget = widget;
|
|
|
|
|
2003-08-24 03:35:05 +08:00
|
|
|
if (ret_data)
|
|
|
|
*ret_data = help_data;
|
|
|
|
|
|
|
|
return (const gchar *) help_id;
|
2002-09-27 02:43:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-19 09:12:20 +08:00
|
|
|
if (help_widget)
|
|
|
|
*help_widget = NULL;
|
|
|
|
|
|
|
|
if (ret_data)
|
|
|
|
*ret_data = NULL;
|
|
|
|
|
2002-09-27 02:43:05 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2001-08-01 07:28:56 +08:00
|
|
|
gimp_help_callback (GtkWidget *widget,
|
2004-10-04 21:17:41 +08:00
|
|
|
GimpWidgetHelpType help_type,
|
|
|
|
GimpHelpFunc help_func)
|
2000-01-05 23:47:06 +08:00
|
|
|
{
|
2001-08-01 07:28:56 +08:00
|
|
|
switch (help_type)
|
|
|
|
{
|
|
|
|
case GIMP_WIDGET_HELP_TYPE_HELP:
|
2002-09-27 02:43:05 +08:00
|
|
|
if (help_func)
|
|
|
|
{
|
2007-11-09 19:17:00 +08:00
|
|
|
gchar *help_id = NULL;
|
|
|
|
gpointer help_data = NULL;
|
2001-08-01 07:28:56 +08:00
|
|
|
|
2007-11-09 19:17:00 +08:00
|
|
|
help_id = g_object_get_qdata (G_OBJECT (widget), GIMP_HELP_ID);
|
2003-08-24 03:35:05 +08:00
|
|
|
help_data = g_object_get_data (G_OBJECT (widget), "gimp-help-data");
|
2001-08-01 07:28:56 +08:00
|
|
|
|
2004-10-04 21:17:41 +08:00
|
|
|
(* help_func) (help_id, help_data);
|
2002-09-27 02:43:05 +08:00
|
|
|
}
|
|
|
|
return TRUE;
|
2001-08-01 07:28:56 +08:00
|
|
|
|
2002-09-27 02:43:05 +08:00
|
|
|
case GTK_WIDGET_HELP_WHATS_THIS:
|
2003-10-27 18:56:06 +08:00
|
|
|
g_idle_add (gimp_context_help_idle_start, widget);
|
2002-09-27 02:43:05 +08:00
|
|
|
return TRUE;
|
2001-08-01 07:28:56 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2002-09-27 02:43:05 +08:00
|
|
|
|
|
|
|
return FALSE;
|
2000-01-05 23:47:06 +08:00
|
|
|
}
|
|
|
|
|
2003-10-27 18:56:06 +08:00
|
|
|
/* Do all the actual context help calls in idle functions and check for
|
2000-01-05 23:47:06 +08:00
|
|
|
* some widget holding a grab before starting the query because strange
|
|
|
|
* things happen if (1) the help browser pops up while the query has
|
|
|
|
* grabbed the pointer or (2) the query grabs the pointer while some
|
2007-06-06 16:44:52 +08:00
|
|
|
* other part of GIMP has grabbed it (e.g. a tool, eek)
|
2000-01-05 23:47:06 +08:00
|
|
|
*/
|
|
|
|
|
2002-09-27 02:43:05 +08:00
|
|
|
static gboolean
|
2003-10-27 18:56:06 +08:00
|
|
|
gimp_context_help_idle_start (gpointer widget)
|
2000-01-05 23:47:06 +08:00
|
|
|
{
|
2003-10-27 18:56:06 +08:00
|
|
|
if (! gtk_grab_get_current ())
|
|
|
|
{
|
|
|
|
GtkWidget *invisible;
|
|
|
|
GdkCursor *cursor;
|
|
|
|
GdkGrabStatus status;
|
2000-01-05 23:47:06 +08:00
|
|
|
|
2003-10-27 18:56:06 +08:00
|
|
|
invisible = gtk_invisible_new_for_screen (gtk_widget_get_screen (widget));
|
|
|
|
gtk_widget_show (invisible);
|
2002-09-27 02:43:05 +08:00
|
|
|
|
2003-10-27 18:56:06 +08:00
|
|
|
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (invisible),
|
|
|
|
GDK_QUESTION_ARROW);
|
|
|
|
|
|
|
|
status = gdk_pointer_grab (invisible->window, TRUE,
|
|
|
|
GDK_BUTTON_PRESS_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK |
|
|
|
|
GDK_ENTER_NOTIFY_MASK |
|
|
|
|
GDK_LEAVE_NOTIFY_MASK,
|
|
|
|
NULL, cursor,
|
|
|
|
GDK_CURRENT_TIME);
|
|
|
|
|
|
|
|
gdk_cursor_unref (cursor);
|
|
|
|
|
|
|
|
if (status != GDK_GRAB_SUCCESS)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (invisible);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-12-08 04:36:13 +08:00
|
|
|
if (gdk_keyboard_grab (invisible->window, TRUE,
|
|
|
|
GDK_CURRENT_TIME) != GDK_GRAB_SUCCESS)
|
|
|
|
{
|
|
|
|
gdk_display_pointer_ungrab (gtk_widget_get_display (invisible),
|
|
|
|
GDK_CURRENT_TIME);
|
|
|
|
gtk_widget_destroy (invisible);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-10-27 18:56:06 +08:00
|
|
|
gtk_grab_add (invisible);
|
|
|
|
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_connect (invisible, "button-press-event",
|
2003-10-27 18:56:06 +08:00
|
|
|
G_CALLBACK (gimp_context_help_button_press),
|
|
|
|
NULL);
|
2005-12-08 04:36:13 +08:00
|
|
|
g_signal_connect (invisible, "key-press-event",
|
|
|
|
G_CALLBACK (gimp_context_help_key_press),
|
|
|
|
NULL);
|
2003-10-27 18:56:06 +08:00
|
|
|
}
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-09-27 02:43:05 +08:00
|
|
|
static gboolean
|
2003-10-27 18:56:06 +08:00
|
|
|
gimp_context_help_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
gpointer data)
|
2000-01-05 23:47:06 +08:00
|
|
|
{
|
2005-12-08 04:36:13 +08:00
|
|
|
GtkWidget *event_widget = gtk_get_event_widget ((GdkEvent *) bevent);
|
2003-10-27 18:56:06 +08:00
|
|
|
|
|
|
|
if (event_widget && bevent->button == 1 && bevent->type == GDK_BUTTON_PRESS)
|
|
|
|
{
|
2005-12-08 04:36:13 +08:00
|
|
|
GdkDisplay *display = gtk_widget_get_display (widget);
|
|
|
|
|
2003-10-27 18:56:06 +08:00
|
|
|
gtk_grab_remove (widget);
|
2005-12-08 04:36:13 +08:00
|
|
|
gdk_display_keyboard_ungrab (display, bevent->time);
|
|
|
|
gdk_display_pointer_ungrab (display, bevent->time);
|
2003-10-27 18:56:06 +08:00
|
|
|
gtk_widget_destroy (widget);
|
|
|
|
|
|
|
|
if (event_widget != widget)
|
|
|
|
g_idle_add (gimp_context_help_idle_show_help, event_widget);
|
|
|
|
}
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-12-08 04:36:13 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_context_help_key_press (GtkWidget *widget,
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
if (kevent->keyval == GDK_Escape)
|
|
|
|
{
|
|
|
|
GdkDisplay *display = gtk_widget_get_display (widget);
|
|
|
|
|
|
|
|
gtk_grab_remove (widget);
|
|
|
|
gdk_display_keyboard_ungrab (display, kevent->time);
|
|
|
|
gdk_display_pointer_ungrab (display, kevent->time);
|
|
|
|
gtk_widget_destroy (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-09-27 02:43:05 +08:00
|
|
|
static gboolean
|
2003-10-27 18:56:06 +08:00
|
|
|
gimp_context_help_idle_show_help (gpointer data)
|
2000-01-05 23:47:06 +08:00
|
|
|
{
|
2003-10-27 18:56:06 +08:00
|
|
|
GtkWidget *help_widget;
|
|
|
|
const gchar *help_id = NULL;
|
|
|
|
gpointer help_data = NULL;
|
|
|
|
|
|
|
|
help_id = gimp_help_get_help_data (GTK_WIDGET (data), &help_widget,
|
|
|
|
&help_data);
|
|
|
|
|
|
|
|
if (help_id)
|
|
|
|
gimp_standard_help_func (help_id, help_data);
|
2000-01-05 23:47:06 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|