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

removed most functions. Show the help page in an idle function to avoid

2000-01-05  Michael Natterer  <mitch@gimp.org>

	* app/gimphelp.[ch]: removed most functions. Show the help page in
	an idle function to avoid confusion with calling the temporary
	help browser procedure in the middle of the "gimp_help" PDB call.
	(I beleive this should work, so this is maybe a workaround for
	some other bug).

	* app/gimpui.[ch]: removed the dialog functions.

	* libgimp/Makefile.am
	* libgimp/gimpdialog.[ch]
	* libgimp/gimphelp.c
	* libgimp/gimphelpui.[ch]: new files. Moved most of the help
	functions and the dialog constructors to libgimp and libgimpui.

	* libgimp/gimp.h: declaration of the "gimp_help*" functions.

	* libgimp/gimpui.h: include "gimpdialog.h" and "gimphelpui.h".

	* plug-ins/common/grid.c: use the dialog constructor. It's now
	possible to show the plugin's help with "F1".
parent 43136b7c
2000-01-05 Michael Natterer <mitch@gimp.org>
* app/gimphelp.[ch]: removed most functions. Show the help page in
an idle function to avoid confusion with calling the temporary
help browser procedure in the middle of the "gimp_help" PDB call.
(I beleive this should work, so this is maybe a workaround for
some other bug).
* app/gimpui.[ch]: removed the dialog functions.
* libgimp/Makefile.am
* libgimp/gimpdialog.[ch]
* libgimp/gimphelp.c
* libgimp/gimphelpui.[ch]: new files. Moved most of the help
functions and the dialog constructors to libgimp and libgimpui.
* libgimp/gimp.h: declaration of the "gimp_help*" functions.
* libgimp/gimpui.h: include "gimpdialog.h" and "gimphelpui.h".
* plug-ins/common/grid.c: use the dialog constructor. It's now
possible to show the plugin's help with "F1".
Wed Jan 5 13:51:19 CET 2000 Sven Neumann <sven@gimp.org>
* app/main.c: removed i18n tags from error messages in the
......
......@@ -24,7 +24,6 @@
#include <unistd.h>
#endif
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "gimphelp.h"
......@@ -38,56 +37,16 @@
#define DEBUG_HELP
/* local function prototypes */
static gint gimp_idle_help (gpointer help_data);
static void gimp_help_internal (gchar *current_locale,
gchar *help_data);
static void gimp_help_netscape (gchar *current_locale,
gchar *help_data);
static void gimp_help_callback (GtkWidget *widget,
gpointer data);
static gint gimp_help_tips_query_idle_show_help (gpointer data);
static gint gimp_help_tips_query_widget_selected (GtkWidget *tips_query,
GtkWidget *widget,
const gchar *tip_text,
const gchar *tip_private,
GdkEventButton *event,
gpointer func_data);
static gint gimp_help_tips_query_idle_start (gpointer tips_query);
static void gimp_help_tips_query_start (GtkWidget *widget,
gpointer tips_query);
/* local variables */
static GtkTooltips * tool_tips = NULL;
static GtkWidget * tips_query = NULL;
/**********************/
/* public functions */
/**********************/
void
gimp_help_init (void)
{
tool_tips = gtk_tooltips_new ();
}
void
gimp_help_free (void)
{
gtk_object_destroy (GTK_OBJECT (tool_tips));
gtk_object_unref (GTK_OBJECT (tool_tips));
}
void
gimp_help_enable_tooltips (void)
{
gtk_tooltips_enable (tool_tips);
}
void
gimp_help_disable_tooltips (void)
{
gtk_tooltips_disable (tool_tips);
}
/* The standard help function */
void
gimp_standard_help_func (gchar *help_data)
......@@ -95,136 +54,54 @@ gimp_standard_help_func (gchar *help_data)
gimp_help (help_data);
}
/* the main help function */
void
gimp_help_connect_help_accel (GtkWidget *widget,
GimpHelpFunc help_func,
gchar *help_data)
gimp_help (gchar *help_data)
{
GtkAccelGroup *accel_group;
if (!help_func)
return;
/* set up the help signals and tips query widget */
if (!tips_query)
if (use_help)
{
tips_query = gtk_tips_query_new ();
gtk_widget_set (tips_query,
"GtkTipsQuery::emit_always", TRUE,
NULL);
gtk_signal_connect (GTK_OBJECT (tips_query), "widget_selected",
GTK_SIGNAL_FUNC (gimp_help_tips_query_widget_selected),
NULL);
/* FIXME: EEEEEEEEEEEEEEEEEEEEK, this is very ugly and forbidden...
* does anyone know a way to do this tips query stuff without
* having to attach to some parent widget???
*/
tips_query->parent = widget;
gtk_widget_realize (tips_query);
gtk_object_class_user_signal_new (GTK_OBJECT (widget)->klass,
"tips_query",
GTK_RUN_LAST,
gtk_signal_default_marshaller,
GTK_TYPE_NONE,
0,
NULL);
gtk_object_class_user_signal_new (GTK_OBJECT (widget)->klass,
"help",
GTK_RUN_LAST,
gtk_signal_default_marshaller,
GTK_TYPE_NONE,
0,
NULL);
}
gimp_help_set_help_data (widget, NULL, help_data);
gtk_signal_connect (GTK_OBJECT (widget), "help",
GTK_SIGNAL_FUNC (gimp_help_callback),
(gpointer) help_func);
gtk_signal_connect (GTK_OBJECT (widget), "tips_query",
GTK_SIGNAL_FUNC (gimp_help_tips_query_start),
(gpointer) tips_query);
gtk_widget_add_events (widget, GDK_BUTTON_PRESS_MASK);
/* a new accelerator group for this widget */
accel_group = gtk_accel_group_new ();
/* FIXME: does not work for some reason...
gtk_widget_add_accelerator (widget, "help", accel_group,
GDK_F1, 0, GTK_ACCEL_LOCKED);
gtk_widget_add_accelerator (widget, "tips_query", accel_group,
GDK_F1, GDK_SHIFT_MASK, GTK_ACCEL_LOCKED);
*/
/* ...while using this internal stuff works */
gtk_accel_group_add (accel_group, GDK_F1, 0, 0,
GTK_OBJECT (widget), "help");
gtk_accel_group_add (accel_group, GDK_F1, GDK_SHIFT_MASK, 0,
GTK_OBJECT (widget), "tips_query");
if (help_data)
help_data = g_strdup (help_data);
gtk_accel_group_attach (accel_group, GTK_OBJECT (widget));
gtk_idle_add ((GtkFunction) gimp_idle_help, (gpointer) help_data);
}
}
void
gimp_help_set_help_data (GtkWidget *widget,
gchar *tooltip,
gchar *help_data)
{
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
if (tooltip)
gtk_tooltips_set_tip (tool_tips, widget, tooltip, help_data);
else if (help_data)
gtk_object_set_data (GTK_OBJECT (widget), "gimp_help_data", help_data);
}
/*********************/
/* local functions */
/*********************/
/* the main help function */
void
gimp_help (gchar *help_data)
static gint
gimp_idle_help (gpointer help_data)
{
static gchar *current_locale = "C";
if (help_data == NULL && help_browser != HELP_BROWSER_GIMP)
help_data = "welcome.html";
help_data = g_strdup ("welcome.html");
#ifdef DEBUG_HELP
g_print ("Help Page: %s\n", help_data);
g_print ("Help Page: %s\n", (gchar *) help_data);
#endif /* DEBUG_HELP */
switch (help_browser)
{
case HELP_BROWSER_GIMP:
gimp_help_internal (current_locale, help_data);
gimp_help_internal (current_locale, (gchar *) help_data);
break;
case HELP_BROWSER_NETSCAPE:
gimp_help_netscape (current_locale, help_data);
gimp_help_netscape (current_locale, (gchar *) help_data);
break;
default:
break;
}
}
void
gimp_context_help (void)
{
if (tips_query)
gimp_help_tips_query_start (NULL, tips_query);
}
if (help_data)
g_free (help_data);
/*********************/
/* local functions */
/*********************/
return FALSE;
}
void
gimp_help_internal (gchar *current_locale,
......@@ -304,136 +181,3 @@ gimp_help_netscape (gchar *current_locale,
g_free (url);
}
static void
gimp_help_callback (GtkWidget *widget,
gpointer data)
{
GimpHelpFunc help_function;
gchar *help_data;
help_function = (GimpHelpFunc) data;
help_data = (gchar *) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_help_data");
if (help_function && use_help)
(* help_function) (help_data);
}
/* Do all the actual GtkTipsQuery calls in idle functions and check for
* 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
* other part of the gimp has grabbed it (e.g. a tool, eek)
*/
static gint
gimp_help_tips_query_idle_show_help (gpointer data)
{
GtkWidget *event_widget;
GtkWidget *toplevel_widget;
GtkWidget *widget;
GtkTooltipsData *tooltips_data;
gchar *help_data = NULL;
event_widget = GTK_WIDGET (data);
toplevel_widget = gtk_widget_get_toplevel (event_widget);
/* search for help_data in this widget's parent containers */
for (widget = event_widget; widget; widget = widget->parent)
{
if ((tooltips_data = gtk_tooltips_data_get (widget)) &&
tooltips_data->tip_private)
{
help_data = tooltips_data->tip_private;
}
else
{
help_data = (gchar *) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_help_data");
}
if (help_data || widget == toplevel_widget)
break;
}
if (! help_data)
return FALSE;
if (help_data[0] == '#')
{
gchar *help_index;
if (widget == toplevel_widget)
return FALSE;
help_index = help_data;
help_data = NULL;
for (widget = widget->parent; widget; widget = widget->parent)
{
if ((tooltips_data = gtk_tooltips_data_get (widget)) &&
tooltips_data->tip_private)
{
help_data = tooltips_data->tip_private;
}
else
{
help_data = (gchar *) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_help_data");
}
if (help_data)
break;
}
if (help_data)
{
gchar *help_text;
help_text = g_strconcat (help_data, help_index, NULL);
gimp_help (help_text);
g_free (help_text);
}
}
else
{
gimp_help (help_data);
}
return FALSE;
}
static gint
gimp_help_tips_query_widget_selected (GtkWidget *tips_query,
GtkWidget *widget,
const gchar *tip_text,
const gchar *tip_private,
GdkEventButton *event,
gpointer func_data)
{
if (use_help && widget)
gtk_idle_add ((GtkFunction) gimp_help_tips_query_idle_show_help,
(gpointer) widget);
return TRUE;
}
static gint
gimp_help_tips_query_idle_start (gpointer tips_query)
{
if (! gtk_grab_get_current ())
gtk_tips_query_start_query (GTK_TIPS_QUERY (tips_query));
return FALSE;
}
static void
gimp_help_tips_query_start (GtkWidget *widget,
gpointer tips_query)
{
if (use_help && ! GTK_TIPS_QUERY (tips_query)->in_query)
gtk_idle_add ((GtkFunction) gimp_help_tips_query_idle_start, tips_query);
}
......@@ -23,38 +23,18 @@
#include <gtk/gtk.h>
#include "libgimp/gimphelpui.h"
enum
{
HELP_BROWSER_GIMP,
HELP_BROWSER_NETSCAPE
};
typedef void (* GimpHelpFunc) (gchar *);
void gimp_help_init (void);
void gimp_help_free (void);
void gimp_help_enable_tooltips (void);
void gimp_help_disable_tooltips (void);
/* the standard help function */
void gimp_standard_help_func (gchar *help_data);
/* connect the "F1" accelerator of a window */
void gimp_help_connect_help_accel (GtkWidget *widget,
GimpHelpFunc help_func,
gchar *help_data);
/* set help data for non-window widgets */
void gimp_help_set_help_data (GtkWidget *widget,
gchar *tool_tip,
gchar *help_data);
void gimp_standard_help_func (gchar *help_data);
/* the main help function */
void gimp_help (gchar *help_data);
/* activate the context help inspector */
void gimp_context_help (void);
void gimp_help (gchar *help_data);
#endif /* __GIMP_HELP_H__ */
......@@ -30,237 +30,6 @@
* Widget Constructors...
*/
/* local callbacks of gimp_dialog_new () */
static gint
gimp_dialog_delete_callback (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
GtkSignalFunc cancel_callback;
GtkWidget *cancel_widget;
cancel_callback =
(GtkSignalFunc) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_dialog_cancel_callback");
cancel_widget =
(GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget),
"gimp_dialog_cancel_widget");
/* the cancel callback has to destroy the dialog */
if (cancel_callback)
(* cancel_callback) (cancel_widget, data);
return TRUE;
}
/*
static void
gimp_dialog_realize_callback (GtkWidget *widget,
gpointer data)
{
static GdkPixmap *wilber_pixmap = NULL;
static GdkBitmap *wilber_mask = NULL;
GtkStyle *style;
style = gtk_widget_get_style (widget);
if (wilber_pixmap == NULL)
wilber_pixmap =
gdk_pixmap_create_from_xpm_d (widget->window,
&wilber_mask,
&style->bg[GTK_STATE_NORMAL],
gimp_xpm);
gdk_window_set_icon (widget->window, NULL,
wilber_pixmap, wilber_mask);
}
*/
GtkWidget *
gimp_dialog_new (const gchar *title,
const gchar *wmclass_name,
GimpHelpFunc help_func,
gchar *help_data,
GtkWindowPosition position,
gint allow_shrink,
gint allow_grow,
gint auto_shrink,
/* specify action area buttons as va_list:
* gchar *label,
* GtkSignalFunc callback,
* gpointer data,
* GtkWidget **widget_ptr,
* gboolean default_action,
* gboolean connect_delete,
*/
...)
{
GtkWidget *dialog;
va_list args;
va_start (args, auto_shrink);
dialog = gimp_dialog_newv (title,
wmclass_name,
help_func,
help_data,
position,
allow_shrink,
allow_grow,
auto_shrink,
args);
va_end (args);
return dialog;
}
GtkWidget *
gimp_dialog_newv (const gchar *title,
const gchar *wmclass_name,
GimpHelpFunc help_func,
gchar *help_data,
GtkWindowPosition position,
gint allow_shrink,
gint allow_grow,
gint auto_shrink,
va_list args)
{
GtkWidget *dialog;
g_return_val_if_fail (title != NULL, NULL);
g_return_val_if_fail (wmclass_name != NULL, NULL);
dialog = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (dialog), wmclass_name, "Gimp");
gtk_window_set_title (GTK_WINDOW (dialog), title);
gtk_window_set_position (GTK_WINDOW (dialog), position);
gtk_window_set_policy (GTK_WINDOW (dialog),
allow_shrink, allow_grow, auto_shrink);
/* prepare the action_area */
gimp_dialog_create_action_areav (GTK_DIALOG (dialog), args);
/* the realize callback sets the WM icon */
/*
gtk_signal_connect (GTK_OBJECT (dialog), "realize",
(GtkSignalFunc) gimp_dialog_realize_callback,
NULL);
*/
/* connect the "F1" help key */
if (help_func)
gimp_help_connect_help_accel (dialog, help_func, help_data);
return dialog;
}
void
gimp_dialog_create_action_area (GtkDialog *dialog,
/* specify action area buttons as va_list:
* gchar *label,
* GtkSignalFunc callback,
* gpointer data,
* GtkWidget **widget_ptr,
* gboolean default_action,
* gboolean connect_delete,
*/
...)
{
va_list args;
va_start (args, dialog);
gimp_dialog_create_action_areav (dialog, args);
va_end (args);
}
void
gimp_dialog_create_action_areav (GtkDialog *dialog,
va_list args)
{
GtkWidget *hbbox;
GtkWidget *button;
/* action area variables */
gchar *label;
GtkSignalFunc callback;
gpointer data;
GtkWidget **widget_ptr;
gboolean default_action;
gboolean connect_delete;
gboolean delete_connected = FALSE;
g_return_if_fail (dialog != NULL);
g_return_if_fail (GTK_IS_DIALOG (dialog));
/* prepare the action_area */
label = va_arg (args, gchar*);
if (label)
{
gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 2);
gtk_box_set_homogeneous (GTK_BOX (dialog->action_area), FALSE);
hbbox = gtk_hbutton_box_new ();
gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4);
gtk_box_pack_end (GTK_BOX (dialog->action_area), hbbox, FALSE, FALSE, 0);
gtk_widget_show (hbbox);
}
/* the action_area buttons */
while (label)
{
callback = va_arg (args, GtkSignalFunc);
data = va_arg (args, gpointer);
widget_ptr = va_arg (args, gpointer);
default_action = va_arg (args, gboolean);
connect_delete = va_arg (args, gboolean);
button = gtk_button_new_with_label (label);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
/* pass data as user_data if data != NULL, or the dialog otherwise */
if (callback)
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (callback),
data ? data : dialog);
if (widget_ptr)
*widget_ptr = button;
if (connect_delete && callback && !delete_connected)
{
gtk_object_set_data (GTK_OBJECT (dialog),
"gimp_dialog_cancel_callback",
callback);
gtk_object_set_data (GTK_OBJECT (dialog),
"gimp_dialog_cancel_widget",
button);
/* catch the WM delete event */
gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
(GdkEventFunc) gimp_dialog_delete_callback,
data ? data : dialog);
delete_connected = TRUE;
}
if (default_action)
gtk_widget_grab_default (button);
gtk_widget_show (button);
label = va_arg (args, gchar*);
}
}
GtkWidget *
gimp_option_menu_new (GtkSignalFunc menu_item_callback,
gpointer initial, /* user_data */
......
......@@ -25,6 +25,7 @@
#include "gimphelp.h"
#include "libgimp/gimpdialog.h"
#include "libgimp/gimpunit.h"
/* typedefs */
......@@ -33,55 +34,6 @@ typedef void (* GimpQueryFunc) (GtkWidget *, gpointer, gpointer);
/* widget constructors */
GtkWidget * gimp_dialog_new (const gchar *title,
const gchar *wmclass_name,
GimpHelpFunc help_func,
gchar *help_data,
GtkWindowPosition position,
gint allow_shrink,
gint allow_grow,
gint auto_shrink,
/* specify action area buttons
* as va_list:
* gchar *label,
* GtkSignalFunc callback,
* gpointer data,
* GtkWidget **widget_ptr,
* gboolean default_action,
* gboolean connect_delete,
*/
...);
GtkWidget * gimp_dialog_newv (const gchar *title,
const gchar *wmclass_name,
GimpHelpFunc help_func,
gchar *help_data,
GtkWindowPosition position,
gint allow_shrink,
gint allow_grow,
gint auto_shrink,
va_list args);
void gimp_dialog_create_action_area (GtkDialog *dialog,
/* specify action area buttons
* as va_list:
* gchar *label,
* GtkSignalFunc callback,
* gpointer data,
* GtkWidget **widget_ptr,
* gboolean default_action,
* gboolean connect_delete,
*/
...);
void gimp_dialog_create_action_areav (GtkDialog *dialog,
va_list args);
GtkWidget * gimp_option_menu_new (GtkSignalFunc menu_item_callback,
gpointer initial, /* user_data */
......
......@@ -24,7 +24,6 @@
#include <unistd.h>
#endif
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "gimphelp.h"
......@@ -38,56 +37,16 @@
#define DEBUG_HELP
/* local function prototypes */
static gint gimp_idle_help (gpointer help_data);
static void gimp_help_internal (gchar *current_locale,
gchar *help_data);
static void gimp_help_netscape (gchar *current_locale,
gchar *help_data);
static void gimp_help_callback (GtkWidget *widget,
gpointer data);
static gint gimp_help_tips_query_idle_show_help (gpointer data);
static gint gimp_help_tips_query_widget_selected (GtkWidget *tips_query,
GtkWidget *widget,
const gchar *tip_text,
const gchar *tip_private,
GdkEventButton *event,
gpointer func_data);
static gint gimp_help_tips_query_idle_start (gpointer tips_query);